Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ACEXML / parser / debug_validator / Debug_Element_Builder.cpp
blob976f7ccd10a288c4f7c5db096567aaf365862039
1 #include "ACEXML/common/SAXExceptions.h"
2 #include "ACEXML/parser/debug_validator/Debug_Element_Builder.h"
4 ACEXML_Debug_Element_Builder::ACEXML_Debug_Element_Builder ()
5 : type_ (UNDEFINED),
6 root_ (0)
10 ACEXML_Debug_Element_Builder::~ACEXML_Debug_Element_Builder ()
12 delete this->root_;
15 int
16 ACEXML_Debug_Element_Builder::setElementName (const ACEXML_Char *,
17 const ACEXML_Char *,
18 const ACEXML_Char *qName)
20 this->element_.set (qName, 0);
21 return 0;
24 int
25 ACEXML_Debug_Element_Builder::setContentType (CONTENT_TYPE type)
27 if (this->type_ == UNDEFINED)
29 this->type_ = type;
30 return 0;
33 ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Element type redefinition in Debug_Validator.")), -1);
36 int
37 ACEXML_Debug_Element_Builder::insertMixedElement (const ACEXML_Char *,
38 const ACEXML_Char *,
39 const ACEXML_Char *qName)
41 ACEXML_Element_Tree_Name_Node *node = 0;
43 // @@ We should "throw" an exception here instead of returning -1.
44 ACE_NEW_RETURN (node,
45 ACEXML_Element_Tree_Name_Node (qName),
46 -1);
48 if (this->root_ == 0)
49 // @@ Memory leak if fail?
50 ACE_NEW_RETURN (this->root_,
51 ACEXML_Element_Tree_List_Node (),
52 -1);
55 return this->root_->insert (node);
58 int
59 ACEXML_Debug_Element_Builder::startChildGroup ()
61 ACEXML_Element_Tree_List_Node *lnode = 0;
63 ACE_NEW_RETURN (lnode,
64 ACEXML_Element_Tree_List_Node (),
65 -1);
67 if (this->root_ == 0)
69 this->root_ = lnode;
71 else
73 // @@ check error?
74 this->root_->insert (lnode);
77 this->active_list_.push (lnode);
78 return 0;
81 int
82 ACEXML_Debug_Element_Builder::endChildGroup (CARDINALITY )
84 this->active_list_.pop ();
85 return 0;
88 int
89 ACEXML_Debug_Element_Builder::setChoice ()
91 this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::CHOICE);
92 return 0;
95 int
96 ACEXML_Debug_Element_Builder::setSequence ()
98 this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::SEQUENCE);
99 return 0;
103 ACEXML_Debug_Element_Builder::insertElement (const ACEXML_Char *,
104 const ACEXML_Char *,
105 const ACEXML_Char *qName)
107 ACEXML_Element_Tree_Name_Node *node = 0;
109 // @@ We should "throw" an exception here instead of returning -1.
110 ACE_NEW_RETURN (node,
111 ACEXML_Element_Tree_Name_Node (qName),
112 -1);
114 return this->active_list_.top ()->insert (node);
117 void
118 ACEXML_Debug_Element_Builder::dump ()
120 cout << "<!ELEMENT " << this->element_;
122 // @@ Also dump element contentspec here.
123 switch (this->type_)
125 case EMPTY:
126 cout << "EMPTY";
127 break;
128 case ANY:
129 cout << "ANY";
130 break;
131 case MIXED:
132 case CHILDREN:
133 // @@ Dump the content of this->root_
134 cout << "*** not implemented ***";
135 break;
136 default:
137 cout << "*** Unidentified element type ***";
138 break;
141 cout << ">" << endl;