]> www.ginac.de Git - ginac.git/blobdiff - ginac/structure.cpp
fixed a bug where quo() would call vector::reserve() with a negative argument
[ginac.git] / ginac / structure.cpp
index c084096c49ff3d8509924d87ef4174e0ff934c89..1122c212e730b0430ab06e82e476e3ef192f2b4e 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <iostream>
 #include <string>
 
 #include "structure.h"
 #include "archive.h"
-#include "debugmsg.h"
 #include "utils.h"
+#include "print.h"
 
 namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic)
 
 //////////
-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 DEFAULT_CTORS(structure)
@@ -44,36 +45,19 @@ DEFAULT_CTORS(structure)
 DEFAULT_ARCHIVING(structure)
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
-void structure::printraw(std::ostream & os) const
+void structure::print(const print_context & c, unsigned level) const
 {
-       debugmsg("structure printraw",LOGLEVEL_PRINT);
+       if (is_a<print_tree>(c)) {
 
-       os << class_name() << "(hash=" << hashvalue << ",flags=" << flags << ")";
-}
-
-void structure::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("structure print",LOGLEVEL_PRINT);
-
-       os << class_name() << "()";
-}
-
-void structure::printtree(std::ostream & os, unsigned indent) const
-{
-       debugmsg("structure printtree",LOGLEVEL_PRINT);
-
-       os << std::string(indent,' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
-          << std::endl;
-}
-
-void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
-{
-       debugmsg("structure print csrc",LOGLEVEL_PRINT);
+               c.s << std::string(level, ' ') << class_name()
+                   << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
+                   << std::endl;
 
-       os << "structure()";
+       } else
+               c.s << class_name() << "()";
 }
 
 // protected
@@ -82,7 +66,7 @@ DEFAULT_COMPARE(structure)
 
 bool structure::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, structure));
+       GINAC_ASSERT(is_a<structure>(other));
        return true; // all structures are the same
 }