]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.pl
* Example: Don't confuse users with _ex0().
[ginac.git] / ginac / structure.pl
index 9a734c907acd0dac808457d4c4a3842c231cef49..901c5722d11da5b2f459d2d83c83a0cc3cc35b47 100755 (executable)
@@ -173,9 +173,7 @@ public:
        // functions overriding virtual functions from bases classes
 public:
        basic * duplicate() const;
-       void printraw(ostream & os) const;
-       void print(ostream & os, unsigned upper_precedence=0) const;
-       void printtree(ostream & os, unsigned indent) const;
+       void print(const print_context & c, unsigned level = 0) const;
        int nops() const;
        ex & let_op(int i);
        ex expand(unsigned options=0) const;
@@ -251,8 +249,10 @@ $implementation=<<END_OF_IMPLEMENTATION;
 ${input_structure}
 
 #include <iostream>
+#include <stdexcept>
 
 #include "${STRUCTURE}.h"
+#include "print.h"
 
 namespace GiNaC {
 
@@ -328,22 +328,10 @@ basic * ${STRUCTURE}::duplicate() const
        return new ${STRUCTURE}(*this);
 }
 
-void ${STRUCTURE}::printraw(ostream & os) const
+void ${STRUCTURE}::print(const print_context & c, unsigned level) const
 {
-       debugmsg("${STRUCTURE} printraw",LOGLEVEL_PRINT);
-       os << class_name() << "()";
-}
-
-void ${STRUCTURE}::print(ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("${STRUCTURE} print",LOGLEVEL_PRINT);
-       os << class_name() << "()";
-}
-
-void ${STRUCTURE}::printtree(ostream & os, unsigned indent) const
-{
-       debugmsg("${STRUCTURE} printtree",LOGLEVEL_PRINT);
-       os << "${STRUCTURE}()";
+       debugmsg("${STRUCTURE} print", LOGLEVEL_PRINT);
+       c.s << class_name() << "()";
 }
 
 int ${STRUCTURE}::nops() const
@@ -359,8 +347,7 @@ ex & ${STRUCTURE}::let_op(int i)
        switch (i) {
 ${let_op_statements}
        }
-       errormsg("${STRUCTURE}::let_op(): should not reach this point");
-       return *new ex(fail());
+       throw(std::runtime_error("${STRUCTURE}::let_op(): should not have reached this point"));
 }
 
 ex ${STRUCTURE}::expand(unsigned options) const