]> www.ginac.de Git - ginac.git/blobdiff - ginac/constant.cpp
* color.cpp: remove duplicated default args.
[ginac.git] / ginac / constant.cpp
index 5aad78d096ee0e86e11e56778f8c5dc67ed3bd78..c056a96a1d18b8664319aadefb36ea905547dbcd 100644 (file)
@@ -26,6 +26,7 @@
 #include "constant.h"
 #include "numeric.h"
 #include "ex.h"
+#include "print.h"
 #include "archive.h"
 #include "debugmsg.h"
 #include "utils.h"
@@ -126,32 +127,25 @@ void constant::archive(archive_node &n) const
 
 // public
 
-void constant::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("constant print",LOGLEVEL_PRINT);
-       os << name;
-}
-
-void constant::printraw(std::ostream & os) const
-{
-       debugmsg("constant printraw",LOGLEVEL_PRINT);
-       os << class_name() << "(" << name << ")";
-}
-
-void constant::printtree(std::ostream & os, unsigned indent) const
-{
-       debugmsg("constant printtree",LOGLEVEL_PRINT);
-       os << std::string(indent,' ') << name
-          << ", type=" << class_name()
-          << ", hash=" << hashvalue
-          << " (0x" << std::hex << hashvalue << std::dec << ")"
-          << ", flags=" << flags << std::endl;
-}
-
-void constant::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
-{
-       debugmsg("constant print csrc",LOGLEVEL_PRINT);
-       os << name;
+void constant::print(const print_context & c, unsigned level) const
+{
+       debugmsg("constant print", LOGLEVEL_PRINT);
+
+       if (is_of_type(c, print_tree)) {
+               c.s << std::string(level, ' ') << name << " (" << class_name() << ")"
+                   << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
+                   << std::endl;
+       } else if (is_of_type(c, print_latex)) {
+               if (name=="Pi")
+                       c.s << "\\pi";
+               else if (name=="Euler")
+                       c.s << "\\gamma_E";
+               else if (name=="Catalan")
+                       c.s << "G";
+               else
+                       c.s << "\\mbox{"+name+"}";
+       } else
+               c.s << name;
 }
 
 int constant::degree(const ex & s) const