OW_CIMXMLParser.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_CIMXMLPARSER_HPP_INCLUDE_GUARD_
00037 #define OW_CIMXMLPARSER_HPP_INCLUDE_GUARD_
00038 #include "OW_config.h"
00039 #include "OW_XMLPullParser.hpp"
00040 
00041 namespace OW_NAMESPACE
00042 {
00043 
00044 class OW_XML_API CIMXMLParser : public XMLPullParser
00045 {
00046 public:
00047    // These must be sorted alphabetically, except E_UNKNOWN, which must be last!!!!!!!!!!!!!!!!!!!!!!!!!
00048    enum tokenId
00049    {
00050       E_CIM                      ,
00051       E_CLASS                       ,
00052       E_CLASSNAME                ,
00053       E_CLASSPATH                ,
00054       E_DECLARATION                 ,
00055       E_DECLGROUP       ,
00056       E_DECLGROUP_WITHNAME       ,
00057       E_DECLGROUP_WITHPATH       ,
00058       E_ERROR                       ,
00059       E_EXPMETHODCALL               ,
00060       E_EXPMETHODRESPONSE           ,
00061       E_EXPPARAMVALUE            ,
00062       E_HOST                        ,
00063       E_IMETHODCALL                 ,
00064       E_IMETHODRESPONSE          ,
00065       E_IMPLICITKEY                 ,
00066       E_INSTANCE                    ,
00067       E_INSTANCENAME             ,
00068       E_INSTANCEPATH             ,
00069       E_IPARAMVALUE                 ,
00070       E_IRETURNVALUE             ,
00071       E_KEYBINDING                  ,
00072       E_KEYVALUE                    ,
00073       E_LOCALCLASSPATH              ,
00074       E_LOCALINSTANCEPATH           ,
00075       E_LOCALNAMESPACEPATH       ,
00076       E_MESSAGE                     ,
00077       E_METHOD                   ,
00078       E_METHODCALL                  ,
00079       E_METHODRESPONSE              ,
00080       E_MULTIEXPREQ              ,
00081       E_MULTIEXPRSP                 ,
00082       E_MULTIREQ                    ,
00083       E_MULTIRSP                    ,
00084       E_NAMESPACE                ,
00085       E_NAMESPACEPATH               ,
00086       E_OBJECTPATH                  ,
00087       E_PARAMETER                ,
00088       E_PARAMETER_ARRAY          ,
00089       E_PARAMETER_REFARRAY       ,
00090       E_PARAMETER_REFERENCE         ,
00091       E_PARAMVALUE                  ,
00092       E_PROPERTY                    ,
00093       E_PROPERTY_ARRAY              ,
00094       E_PROPERTY_REFERENCE             ,
00095       E_QUALIFIER                ,
00096       E_QUALIFIER_DECLARATION    ,
00097       E_RETURNVALUE                 ,
00098       E_SCOPE                       ,
00099       E_SIMPLEEXPREQ                ,
00100       E_SIMPLEEXPRSP             ,
00101       E_SIMPLEREQ                ,
00102       E_SIMPLERSP                ,
00103       E_VALUE                       ,
00104       E_VALUE_ARRAY                 ,
00105       E_VALUE_NAMEDINSTANCE         ,
00106       E_VALUE_NAMEDOBJECT           ,
00107       E_VALUE_OBJECT             ,
00108       E_VALUE_OBJECTWITHLOCALPATH   ,
00109       E_VALUE_OBJECTWITHPATH        ,
00110       E_VALUE_REFARRAY              ,
00111       E_VALUE_REFERENCE          ,
00112       E_UNKNOWN
00113    };
00114    CIMXMLParser(const String& str);
00115    CIMXMLParser(std::istream& sb);
00116    CIMXMLParser();
00117    void mustGetChildId(tokenId tId);
00118    void getNextId(tokenId beginTok, bool throwIfError = false);
00119    void mustGetNextId(tokenId beginTok)
00120    {
00121       getNextId(beginTok, true);
00122    }
00123    bool tokenIsId(tokenId tId) const
00124    {
00125       return XMLPullParser::tokenIs(g_elems[tId].name);
00126    }
00127    void mustTokenIsId(tokenId tId) const;
00128    tokenId getToken() const
00129    {
00130       return getTokenFromName(m_curTok.text.c_str());
00131    }
00132 
00133    typedef bool CIMXMLParser::*safe_bool;
00134    operator safe_bool () const
00135       {  return m_good ? &CIMXMLParser::m_good : 0; }
00136    bool operator!() const
00137       {  return !m_good; }
00138 
00139    // naming convention:
00140    // A_ for attribute name
00141    // AV_ for attribute value (expected)
00142    // P_ for {I,E}PARAMVALUE NAME attribute value
00143    static const char* const A_ASSOCCLASS;
00144    static const char* const A_CLASSNAME;
00145    static const char* const A_CLASSORIGIN;
00146    static const char* const A_DEEPINHERITANCE;
00147    static const char* const A_INCLUDECLASSORIGIN;
00148    static const char* const A_INCLUDEQUALIFIERS;
00149    static const char* const A_INSTANCENAME;
00150    static const char* const A_XML_LANG;
00151    static const char* const A_LOCALONLY;
00152    static const char* const A_MODIFIEDCLASS;
00153    static const char* const A_NAME;
00154    static const char* const A_NEWVALUE;
00155    static const char* const A_OBJECTNAME;
00156    static const char* const A_OVERRIDABLE;
00157    static const char* const A_PARAMTYPE;
00158    static const char* const A_PROPAGATED;
00159    static const char* const A_PROPERTYLIST;
00160    static const char* const A_PROPERTYNAME;
00161    static const char* const A_REFERENCECLASS;
00162    static const char* const A_RESULTCLASS;
00163    static const char* const A_RESULTROLE;
00164    static const char* const A_ROLE;
00165    static const char* const A_SUPERCLASS;
00166    static const char* const A_TOINSTANCE; // This is a bug in the spec, but we still support it for backward compatibility.
00167    static const char* const A_TOSUBCLASS;
00168    static const char* const A_TRANSLATABLE;
00169    static const char* const A_TYPE;
00170    static const char* const A_VALUETYPE;
00171    static const char* const A_CIMVERSION;
00172    static const char* const A_DTDVERSION;
00173    static const char* const A_ID;
00174    static const char* const A_PROTOCOLVERSION;
00175    static const char* const A_CODE;
00176    static const char* const A_DESCRIPTION;
00177    static const char* const A_ARRAYSIZE;
00178    static const char* const A_ISARRAY;
00179    static const char* const A_EMBEDDEDOBJECT;
00180    static const char* const AV_CIMVERSION20_VALUE;
00181    static const char* const AV_CIMVERSION21_VALUE;
00182    static const char* const AV_CIMVERSION22_VALUE;
00183    static const char* const AV_DTDVERSION20_VALUE;
00184    static const char* const AV_DTDVERSION21_VALUE;
00185    static const char* const AV_PROTOCOLVERSION10_VALUE;
00186    static const char* const AV_PROTOCOLVERSION11_VALUE;
00187    static const char* const AV_EMBEDDEDOBJECT_OBJECT_VALUE;
00188    static const char* const AV_EMBEDDEDOBJECT_INSTANCE_VALUE;
00189    static const char* const P_ClassName;
00190    static const char* const P_PropertyList;
00191    static const char* const P_DeepInheritance;
00192    static const char* const P_LocalOnly;
00193    static const char* const P_IncludeQualifiers;
00194    static const char* const P_IncludeClassOrigin;
00195    static const char* const P_ModifiedClass;
00196    static const char* const P_ModifiedInstance;
00197    static const char* const P_InstanceName;
00198    static const char* const P_PropertyName;
00199    static const char* const P_NewValue;
00200    static const char* const P_Role;
00201    static const char* const P_ResultRole;
00202    static const char* const P_ObjectName;
00203    static const char* const P_AssocClass;
00204    static const char* const P_ResultClass;
00205    static const char* const P_QueryLanguage;
00206    static const char* const P_Query;
00207    static const char* const P_QualifierName;
00208    static const char* const P_QualifierDeclaration;
00209 
00210 private:
00211    static tokenId getTokenFromName(const char* name);
00212    struct ElemEntry
00213    {
00214       const char* name;
00215       tokenId id;
00216    };
00217    
00218    static ElemEntry g_elems[];
00219    static bool elemEntryCompare(const ElemEntry& f1, const ElemEntry& f2);
00220    static ElemEntry* g_elemsEnd;
00221    // unimplemented
00222    CIMXMLParser(const CIMXMLParser& x);
00223    CIMXMLParser& operator=(const CIMXMLParser& x);
00224 
00225 };
00226 
00227 } // end namespace OW_NAMESPACE
00228 
00229 #endif

Generated on Thu Feb 9 08:47:56 2006 for openwbem by  doxygen 1.4.6