Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Debug_Attributes_Builder.cpp

Go to the documentation of this file.
00001 // $Id: Debug_Attributes_Builder.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 #include "ACEXML/common/SAXExceptions.h"
00004 #include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h"
00005 
00006 ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder ()
00007   : type_ (ERROR_TYPE),
00008     default_decl_ (INVALID)
00009 {
00010 }
00011 
00012 ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs)
00013   : name_ (rhs.name_),
00014     type_ (rhs.type_),
00015     default_decl_ (rhs.default_decl_),
00016     default_value_ (rhs.default_value_),
00017     att_value_queue_ (rhs.att_value_queue_)
00018 {
00019 }
00020 
00021 ACEXML_Debug_Attribute_Builder::~ACEXML_Debug_Attribute_Builder ()
00022 {
00023 }
00024 
00025 int
00026 ACEXML_Debug_Attribute_Builder::setName (const ACEXML_Char *n)
00027 {
00028   this->name_.set (n, 0);
00029   return 0;
00030 }
00031 
00032 const ACEXML_Char *
00033 ACEXML_Debug_Attribute_Builder::getName (void)
00034 {
00035   return this->name_.fast_rep ();
00036 }
00037 
00038 int
00039 ACEXML_Debug_Attribute_Builder::setAttType (const ATT_TYPE type
00040                                             ACEXML_ENV_ARG_DECL)
00041   ACE_THROW_SPEC ((ACEXML_SAXException))
00042 {
00043   if (this->type_ == ERROR_TYPE)
00044     {
00045       this->type_ = type;
00046       return 0;
00047     }
00048   ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Attribute type redefinition in Debug Validator")), -1);
00049 
00050 }
00051 
00052 int
00053 ACEXML_Debug_Attribute_Builder::insertList (const ACEXML_Char *n
00054                                             ACEXML_ENV_ARG_DECL_NOT_USED)
00055   ACE_THROW_SPEC ((ACEXML_SAXException))
00056 {
00057   ACEXML_String str (n, 0, 0);
00058 
00059   this->att_value_queue_.enqueue_tail (str);
00060   return 0;
00061 }
00062 
00063 int
00064 ACEXML_Debug_Attribute_Builder::setDefault (const DEFAULT_DECL def,
00065                                             const ACEXML_Char *value
00066                                             ACEXML_ENV_ARG_DECL_NOT_USED)
00067    ACE_THROW_SPEC ((ACEXML_SAXException))
00068 {
00069   this->default_decl_ = def;
00070   this->default_value_.set (value, 0);
00071   return 0;
00072 }
00073 
00074 int
00075 ACEXML_Debug_Attribute_Builder::validAttr (void)
00076 {
00077   // @@ Not implemented.  Always return 1 (true) for now.
00078   return 1;
00079 }
00080 
00081 void
00082 ACEXML_Debug_Attribute_Builder::dump (void)
00083 {
00084   cout << this->name_ << " ";
00085 
00086   switch (this->type_)
00087     {
00088     case CDATA:
00089       cout << "CDATA ";
00090       break;
00091     case ID:
00092       cout << "ID ";
00093       break;
00094     case IDREF:
00095       cout << "IDREF ";
00096       break;
00097     case IDREFS:
00098       cout << "IDREFS ";
00099       break;
00100     case ENTITY:
00101       cout << "ENTITY ";
00102       break;
00103     case ENTITIES:
00104       cout << "ENTITIES ";
00105       break;
00106     case NMTOKEN:
00107       cout << "NMTOKEN ";
00108       break;
00109     case NMTOKENS:
00110       cout << "NMTOKENS ";
00111       break;
00112     case NOTATION:
00113       cout << "NOTATION ";
00114       // Fall thru
00115     case ENUMERATION:
00116       {
00117         cout << "(";
00118         ACEXML_STRING_QUEUE_ITERATOR iter (this->att_value_queue_);
00119         ACEXML_String *n = 0;
00120 
00121         while (iter.advance () != 0)
00122           {
00123             if (n == 0)
00124               cout << " | ";
00125             iter.next (n);
00126             cout << *n;
00127           }
00128         cout << ") ";
00129       }
00130       break;
00131     default:
00132       cout << "*** UNKNOWN TYPE ***";
00133       break;
00134     }
00135 
00136   switch (this->default_decl_)
00137     {
00138     case REQUIRED:
00139       cout << "#REQUIRED";
00140       break;
00141     case IMPLIED:
00142       cout << "#IMPLIED";
00143       break;
00144     case FIXED:
00145       cout << "#FIXED " << this->default_value_;
00146       break;
00147     default:
00148       cout << "**** UNDEFINED DEFAULT DECL ****";
00149       break;
00150     }
00151 }
00152 // ========================================
00153 
00154 ACEXML_Debug_Attributes_Builder::ACEXML_Debug_Attributes_Builder ()
00155 {
00156 }
00157 
00158 ACEXML_Debug_Attributes_Builder::~ACEXML_Debug_Attributes_Builder ()
00159 {
00160 }
00161 
00162 int
00163 ACEXML_Debug_Attributes_Builder::setElement (const ACEXML_Char *,
00164                                              const ACEXML_Char *,
00165                                              const ACEXML_Char *qName ACEXML_ENV_ARG_DECL_NOT_USED)
00166       ACE_THROW_SPEC ((ACEXML_SAXException))
00167 {
00168   this->element_name_.set (qName, 0);
00169   return 0;
00170 }
00171 
00172 ACEXML_Attribute_Def_Builder *
00173 ACEXML_Debug_Attributes_Builder::getAttribute_Def_Builder ()
00174 {
00175   ACEXML_Attribute_Def_Builder *tmp;
00176 
00177   ACE_NEW_RETURN (tmp,
00178                   ACEXML_Debug_Attribute_Builder (),
00179                   0);
00180   return tmp;
00181 }
00182 
00183 int
00184 ACEXML_Debug_Attributes_Builder::insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL)
00185 {
00186   ACEXML_Attribute_Def_Builder::VAR ptr (def);
00187 
00188   if (def != 0)
00189     {
00190       ACEXML_String attname (def->getName (), 0, 0);
00191       ACEXML_Debug_Attribute_Builder *ptr =
00192         ACE_dynamic_cast (ACEXML_Debug_Attribute_Builder *, def);
00193       this->attributes_.bind (attname, *ptr);
00194       return 0;
00195     }
00196   ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1);
00197 }
00198 
00199 void
00200 ACEXML_Debug_Attributes_Builder::dump (void)
00201 {
00202   // @@ Print print.
00203   cout << "<!ATTLIST " << this->element_name_ << endl;
00204 
00205   ACEXML_ATT_MAP_ITER iter (this->attributes_);
00206   ACEXML_ATT_MAP_ENTRY *item;
00207 
00208   while (iter.advance () != 0)
00209     {
00210       iter.next (item);
00211       cout << "\n\t";
00212       item->int_id_.dump ();
00213     }
00214   cout << ">" << endl;
00215 }

Generated on Mon Jun 16 13:23:19 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002