1 /** @file structure.cpp
3 * Implementation of 'abstract' class structure. */
10 // default constructor, destructor, copy constructor assignment operator and helpers
15 structure::structure()
17 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
18 tinfo_key = TINFO_STRUCTURE;
21 structure::~structure()
23 debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
27 structure::structure(structure const & other)
29 debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
33 structure const & structure::operator=(structure const & other)
35 debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
45 void structure::copy(structure const & other)
50 void structure::destroy(bool call_parent)
52 if (call_parent) basic::destroy(call_parent);
62 // structures overriding virtual structures from bases classes
67 basic * structure::duplicate() const
69 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
70 return new structure(*this);
73 void structure::printraw(ostream & os) const
75 debugmsg("structure printraw",LOGLEVEL_PRINT);
77 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
80 void structure::print(ostream & os, unsigned upper_precedence) const
82 debugmsg("structure print",LOGLEVEL_PRINT);
87 void structure::printtree(ostream & os, unsigned indent) const
89 debugmsg("structure printtree",LOGLEVEL_PRINT);
91 os << string(indent,' ') << "structure "
92 << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
93 << ", flags=" << flags << endl;
96 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
98 debugmsg("structure print csrc",LOGLEVEL_PRINT);
105 int structure::compare_same_type(basic const & other) const
107 ASSERT(is_of_type(other, structure));
108 return 0; // all structures are the same
111 bool structure::is_equal_same_type(basic const & other) const
113 ASSERT(is_of_type(other, structure));
114 return true; // all structures are the same
118 // new virtual structures which can be overridden by derived classes
124 // non-virtual structures in this class
129 vector<registered_structure_info> & structure::registered_structures(void)
131 static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
137 unsigned structure::register_new(char const * nm)
139 registered_structure_info rsi={nm};
140 registered_structures().push_back(rsi);
141 return registered_structures().size()-1;
145 // static member variables
154 const structure some_structure;
155 type_info const & typeid_structure=typeid(some_structure);