Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / ACEXML / parser / debug_validator / Debug_Attributes_Builder.cpp
blob35a07e5b4333c55cf2f4e49e8a72cb5813adb636
1 #include "ACEXML/common/SAXExceptions.h"
2 #include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h"
4 ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder ()
5 : type_ (ERROR_TYPE),
6 default_decl_ (INVALID)
10 ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs)
11 : name_ (rhs.name_),
12 type_ (rhs.type_),
13 default_decl_ (rhs.default_decl_),
14 default_value_ (rhs.default_value_),
15 att_value_queue_ (rhs.att_value_queue_)
19 ACEXML_Debug_Attribute_Builder::~ACEXML_Debug_Attribute_Builder ()
23 int
24 ACEXML_Debug_Attribute_Builder::setName (const ACEXML_Char *n)
26 this->name_.set (n, 0);
27 return 0;
30 const ACEXML_Char *
31 ACEXML_Debug_Attribute_Builder::getName (void)
33 return this->name_.fast_rep ();
36 int
37 ACEXML_Debug_Attribute_Builder::setAttType (const ATT_TYPE type)
39 if (this->type_ == ERROR_TYPE)
41 this->type_ = type;
42 return 0;
44 ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Attribute type redefinition in Debug Validator")), -1);
48 int
49 ACEXML_Debug_Attribute_Builder::insertList (const ACEXML_Char *n)
51 ACEXML_String str (n, 0, 0);
53 this->att_value_queue_.enqueue_tail (str);
54 return 0;
57 int
58 ACEXML_Debug_Attribute_Builder::setDefault (const DEFAULT_DECL def,
59 const ACEXML_Char *value)
61 this->default_decl_ = def;
62 this->default_value_.set (value, 0);
63 return 0;
66 int
67 ACEXML_Debug_Attribute_Builder::validAttr (void)
69 // @@ Not implemented. Always return 1 (true) for now.
70 return 1;
73 void
74 ACEXML_Debug_Attribute_Builder::dump (void)
76 cout << this->name_ << " ";
78 switch (this->type_)
80 case CDATA:
81 cout << "CDATA ";
82 break;
83 case ID:
84 cout << "ID ";
85 break;
86 case IDREF:
87 cout << "IDREF ";
88 break;
89 case IDREFS:
90 cout << "IDREFS ";
91 break;
92 case ENTITY:
93 cout << "ENTITY ";
94 break;
95 case ENTITIES:
96 cout << "ENTITIES ";
97 break;
98 case NMTOKEN:
99 cout << "NMTOKEN ";
100 break;
101 case NMTOKENS:
102 cout << "NMTOKENS ";
103 break;
104 case NOTATION:
105 cout << "NOTATION ";
106 // Fall thru
107 case ENUMERATION:
109 cout << "(";
110 ACEXML_STRING_QUEUE_ITERATOR iter (this->att_value_queue_);
111 ACEXML_String *n = 0;
113 while (iter.advance () != 0)
115 if (n == 0)
116 cout << " | ";
117 iter.next (n);
118 cout << *n;
120 cout << ") ";
122 break;
123 default:
124 cout << "*** UNKNOWN TYPE ***";
125 break;
128 switch (this->default_decl_)
130 case REQUIRED:
131 cout << "#REQUIRED";
132 break;
133 case IMPLIED:
134 cout << "#IMPLIED";
135 break;
136 case FIXED:
137 cout << "#FIXED " << this->default_value_;
138 break;
139 default:
140 cout << "**** UNDEFINED DEFAULT DECL ****";
141 break;
144 // ========================================
146 ACEXML_Debug_Attributes_Builder::ACEXML_Debug_Attributes_Builder ()
150 ACEXML_Debug_Attributes_Builder::~ACEXML_Debug_Attributes_Builder ()
155 ACEXML_Debug_Attributes_Builder::setElement (const ACEXML_Char *,
156 const ACEXML_Char *,
157 const ACEXML_Char *qName)
159 this->element_name_.set (qName, 0);
160 return 0;
163 ACEXML_Attribute_Def_Builder *
164 ACEXML_Debug_Attributes_Builder::getAttribute_Def_Builder ()
166 ACEXML_Attribute_Def_Builder *tmp;
168 ACE_NEW_RETURN (tmp,
169 ACEXML_Debug_Attribute_Builder (),
171 return tmp;
175 ACEXML_Debug_Attributes_Builder::insertAttribute (
176 ACEXML_Attribute_Def_Builder *def)
178 ACEXML_Attribute_Def_Builder::VAR ptr (def);
180 if (def != 0)
182 ACEXML_String attname (def->getName (), 0, 0);
183 ACEXML_Debug_Attribute_Builder *ptr =
184 dynamic_cast<ACEXML_Debug_Attribute_Builder *> (def);
185 this->attributes_.bind (attname, *ptr);
186 return 0;
188 ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
191 void
192 ACEXML_Debug_Attributes_Builder::dump (void)
194 // @@ Print print.
195 cout << "<!ATTLIST " << this->element_name_ << endl;
197 ACEXML_ATT_MAP_ITER iter (this->attributes_);
198 ACEXML_ATT_MAP_ENTRY *item;
200 while (iter.advance () != 0)
202 iter.next (item);
203 cout << "\n\t";
204 item->int_id_.dump ();
206 cout << ">" << endl;