Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ACEXML / parser / debug_validator / Debug_Attributes_Builder.cpp
blob586b503cbecc218678adac9f58ad1a7149bf959c
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 ()
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);
47 int
48 ACEXML_Debug_Attribute_Builder::insertList (const ACEXML_Char *n)
50 ACEXML_String str (n, 0, 0);
52 this->att_value_queue_.enqueue_tail (str);
53 return 0;
56 int
57 ACEXML_Debug_Attribute_Builder::setDefault (const DEFAULT_DECL def,
58 const ACEXML_Char *value)
60 this->default_decl_ = def;
61 this->default_value_.set (value, 0);
62 return 0;
65 int
66 ACEXML_Debug_Attribute_Builder::validAttr ()
68 // @@ Not implemented. Always return 1 (true) for now.
69 return 1;
72 void
73 ACEXML_Debug_Attribute_Builder::dump ()
75 cout << this->name_ << " ";
77 switch (this->type_)
79 case CDATA:
80 cout << "CDATA ";
81 break;
82 case ID:
83 cout << "ID ";
84 break;
85 case IDREF:
86 cout << "IDREF ";
87 break;
88 case IDREFS:
89 cout << "IDREFS ";
90 break;
91 case ENTITY:
92 cout << "ENTITY ";
93 break;
94 case ENTITIES:
95 cout << "ENTITIES ";
96 break;
97 case NMTOKEN:
98 cout << "NMTOKEN ";
99 break;
100 case NMTOKENS:
101 cout << "NMTOKENS ";
102 break;
103 case NOTATION:
104 cout << "NOTATION ";
105 // Fall thru
106 case ENUMERATION:
108 cout << "(";
109 ACEXML_STRING_QUEUE_ITERATOR iter (this->att_value_queue_);
110 ACEXML_String *n = 0;
112 while (iter.advance () != 0)
114 if (n == 0)
115 cout << " | ";
116 iter.next (n);
117 cout << *n;
119 cout << ") ";
121 break;
122 default:
123 cout << "*** UNKNOWN TYPE ***";
124 break;
127 switch (this->default_decl_)
129 case REQUIRED:
130 cout << "#REQUIRED";
131 break;
132 case IMPLIED:
133 cout << "#IMPLIED";
134 break;
135 case FIXED:
136 cout << "#FIXED " << this->default_value_;
137 break;
138 default:
139 cout << "**** UNDEFINED DEFAULT DECL ****";
140 break;
143 // ========================================
145 ACEXML_Debug_Attributes_Builder::ACEXML_Debug_Attributes_Builder ()
149 ACEXML_Debug_Attributes_Builder::~ACEXML_Debug_Attributes_Builder ()
154 ACEXML_Debug_Attributes_Builder::setElement (const ACEXML_Char *,
155 const ACEXML_Char *,
156 const ACEXML_Char *qName)
158 this->element_name_.set (qName, 0);
159 return 0;
162 ACEXML_Attribute_Def_Builder *
163 ACEXML_Debug_Attributes_Builder::getAttribute_Def_Builder ()
165 ACEXML_Attribute_Def_Builder *tmp;
167 ACE_NEW_RETURN (tmp,
168 ACEXML_Debug_Attribute_Builder (),
170 return tmp;
174 ACEXML_Debug_Attributes_Builder::insertAttribute (
175 ACEXML_Attribute_Def_Builder *def)
177 ACEXML_Attribute_Def_Builder::VAR ptr (def);
179 if (def != 0)
181 ACEXML_String attname (def->getName (), 0, 0);
182 ACEXML_Debug_Attribute_Builder *ptr =
183 dynamic_cast<ACEXML_Debug_Attribute_Builder *> (def);
184 this->attributes_.bind (attname, *ptr);
185 return 0;
187 ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
190 void
191 ACEXML_Debug_Attributes_Builder::dump ()
193 // @@ Print print.
194 cout << "<!ATTLIST " << this->element_name_ << endl;
196 ACEXML_ATT_MAP_ITER iter (this->attributes_);
197 ACEXML_ATT_MAP_ENTRY *item;
199 while (iter.advance () != 0)
201 iter.next (item);
202 cout << "\n\t";
203 item->int_id_.dump ();
205 cout << ">" << endl;