(file) Return to XmlReader.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/XmlReader.cpp between version 1.18 and 1.24.2.4

version 1.18, 2001/07/01 21:40:38 version 1.24.2.4, 2001/10/31 04:37:50
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 22 
Line 23 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //              (carolann_graves@hp.com)
   //
   //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 37 
Line 41 
 #include "CIMQualifierDecl.h" #include "CIMQualifierDecl.h"
 #include "CIMClass.h" #include "CIMClass.h"
 #include "CIMInstance.h" #include "CIMInstance.h"
   #include "CIMObject.h"
   #include "CIMParamValue.h"
  
   PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static const Uint32 MESSAGE_SIZE = 128; static const Uint32 MESSAGE_SIZE = 128;
Line 63 
Line 70 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   //  testXmlDeclaration ()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::testXmlDeclaration (
       XmlParser& parser,
       XmlEntry& entry)
   {
       if (!parser.next (entry) ||
           entry.type != XmlEntry::XML_DECLARATION ||
           strcmp (entry.text, "xml") != 0)
       {
           parser.putBack (entry);
           return false;
       }
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
 // expectStartTag() // expectStartTag()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 773 
Line 801 
 { {
     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):
  
 //SNIA      if (strlen(valueString)==0)
     if (strlen(valueString)==0) {      {
         switch (type) {          switch (type)
           {
             case CIMType::BOOLEAN: return CIMValue(false);             case CIMType::BOOLEAN: return CIMValue(false);
            case CIMType::STRING: return CIMValue(valueString);            case CIMType::STRING: return CIMValue(valueString);
            case CIMType::CHAR16: return CIMValue(Char16('\0'));            case CIMType::CHAR16: return CIMValue(Char16('\0'));
Line 791 
Line 820 
            case CIMType::REAL64: return CIMValue(Real64(0));            case CIMType::REAL64: return CIMValue(Real64(0));
         }         }
     }     }
 // end of SNIA  
  
     switch (type)     switch (type)
     {     {
Line 930 
Line 958 
  
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     // Get VALUE content:  
   
     const char* valueString = "";     const char* valueString = "";
     // cout << "DEBUG XMLReader:getValueElement " << __LINE__ ;  
  
     if (!empty)     if (!empty)
     {     {
         if (testContentOrCData(parser, entry))         if (testContentOrCData(parser, entry))
             valueString = entry.text;             valueString = entry.text;
         //cout << "DEBUG XMLReader:getValueElement " << __LINE__  
         //    <<  " valueString " << valueString ;  
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
  
     value = stringToValue(parser.getLine(), valueString,type);     value = stringToValue(parser.getLine(), valueString,type);
     //cout << "DEBUG XMLReader:getValueElement " << __LINE__  
     //  << " value " << value;  
     return true;     return true;
 } }
  
   //------------------------------------------------------------------------------
   //
   // getStringValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getStringValueElement(
       XmlParser& parser,
       String& str,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
               throw XmlValidationError(parser.getLine(),"Expected VALUE element");
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
   
       if (!empty)
       {
           if (testContentOrCData(parser, entry))
               valueString = entry.text;
   
           expectEndTag(parser, "VALUE");
       }
   
       str = valueString;
       return true;
   }
  
 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
 // //
Line 1735 
Line 1794 
 //     <!ATTLIST KEYVALUE //     <!ATTLIST KEYVALUE
 //         VALUETYPE (string|boolean|numeric)  'string'> //         VALUETYPE (string|boolean|numeric)  'string'>
 // //
 // ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed!  
 //  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getKeyValueElement( Boolean XmlReader::getKeyValueElement(
Line 1779 
Line 1836 
 //     <!ATTLIST KEYBINDING //     <!ATTLIST KEYBINDING
 //         %CIMName;> //         %CIMName;>
 // //
 // ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed!  
 //  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getKeyBindingElement( Boolean XmlReader::getKeyBindingElement(
Line 1797 
Line 1852 
     name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING");     name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING");
  
     if (!getKeyValueElement(parser, type, value))     if (!getKeyValueElement(parser, type, value))
         throw XmlValidationError(parser.getLine(), "Expected KEYVALUE element");      {
           CIMReference reference;
   
           if (!getValueReferenceElement(parser, reference))
           {
               throw XmlValidationError(parser.getLine(),
                         "Expected KEYVALUE or VALUE.REFERENCE element");
           }
   
           type = KeyBinding::REFERENCE;
           value = reference.toString();
       }
  
     expectEndTag(parser, "KEYBINDING");     expectEndTag(parser, "KEYBINDING");
     return true;     return true;
Line 1848 
Line 1914 
     return true;     return true;
 } }
  
   Boolean XmlReader::getInstanceNameElement(
       XmlParser& parser,
       CIMReference& instanceName)
   {
       String className;
       Array<KeyBinding> keyBindings;
   
       if (!XmlReader::getInstanceNameElement(parser, className, keyBindings))
           return false;
   
       instanceName.set(String(), String(), className, keyBindings);
       return true;
   }
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getInstancePathElement() // getInstancePathElement()
Line 2775 
Line 2855 
  
 Boolean XmlReader::getErrorElement( Boolean XmlReader::getErrorElement(
     XmlParser& parser,     XmlParser& parser,
     CIMException::Code& code,      CIMStatusCode& code,
     const char*& description,     const char*& description,
     Boolean required)     Boolean required)
 { {
Line 2798 
Line 2878 
         throw XmlValidationError(         throw XmlValidationError(
             parser.getLine(), "missing ERROR.CODE attribute");             parser.getLine(), "missing ERROR.CODE attribute");
  
     code = CIMException::Code(tmpCode);      code = CIMStatusCode(tmpCode);
  
     // Get ERROR.DESCRIPTION:     // Get ERROR.DESCRIPTION:
  
Line 2828 
Line 2908 
     if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH"))     if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH"))
         return false;         return false;
  
     if (testStartTag(parser, entry, "INSTANCEPATH"))  
     {  
         CIMReference reference;         CIMReference reference;
       Boolean isInstance = false;
  
         if (!XmlReader::getInstancePathElement(parser, reference))      if (XmlReader::getInstancePathElement(parser, reference))
           isInstance = true;
       else if (!XmlReader::getClassPathElement(parser, reference))
         {         {
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected INSTANCEPATH element");              "Expected INSTANCE element");
         }         }
  
         CIMInstance instance;      if (isInstance)
       {
           CIMInstance cimInstance;
  
         if (!XmlReader::getInstanceElement(parser, instance))          if (!XmlReader::getInstanceElement(parser, cimInstance))
         {         {
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected INSTANCE element");                  "Expected INSTANCEPATH or CLASSPATH element");
         }         }
           objectWithPath.set(reference, CIMObject(cimInstance));
     }     }
     if (testStartTag(parser, entry, "CLASSPATH"))      else
     {     {
         CIMReference reference;          CIMClass cimClass;
  
         if (!XmlReader::getClassPathElement(parser, reference))          if (!XmlReader::getClassElement(parser, cimClass))
         {         {
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected CLASSPATH element");                  "Expected CLASS element");
           }
           objectWithPath.set(reference, CIMObject(cimClass));
         }         }
  
         CIMClass cimClass;      expectEndTag(parser, "VALUE.OBJECTWITHPATH");
  
         if (!XmlReader::getClassElement(parser, cimClass))      return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // <objectName>: (CLASSNAME|INSTANCENAME)
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getObjectNameElement(
       XmlParser& parser,
       CIMReference& objectName)
   {
       String className;
       CIMReference instanceName;
   
       if (getClassNameElement(parser, className, false))
       {
           objectName.set(String(), String(), className);
           return true;
       }
       else if (getInstanceNameElement(parser, objectName))
           return true;
       else
         {         {
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected CLASS element");              "expected CLASSNAME or INSTANCENAME element");
       }
   
       return false;
         }         }
   
   //------------------------------------------------------------------------------
   //
   // <!ELEMENT OBJECTPATH (INSTANCEPATH|CLASSPATH)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getObjectPathElement(
       XmlParser& parser,
       CIMReference& objectPath)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "OBJECTPATH"))
           return false;
   
       if (getClassPathElement(parser, objectPath))
       {
           expectEndTag(parser, "OBJECTPATH");
           return true;
       }
       else if (getInstancePathElement(parser, objectPath))
       {
           expectEndTag(parser, "OBJECTPATH");
           return true;
     }     }
     else     else
     {     {
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Expected INSTANCEPATH or CLASSPATH element");              "expected INSTANCEPATH or CLASSPATH element");
     }     }
  
     expectEndTag(parser, "VALUE.OBJECTWITHPATH");      PEGASUS_UNREACHABLE ( return false; )
   }
   
   //------------------------------------------------------------------------------
   //
   // getEMethodCallStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getEMethodCallStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "EXPMETHODCALL"))
           return false;
   
       // Get EXPMETHODCALL.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing EXPMETHODCALL.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getEMethodResponseStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getEMethodResponseStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "EXPMETHODRESPONSE"))
           return false;
   
       // Get EXPMETHODRESPONSE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing EXPMETHODRESPONSE.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getMethodCallStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getMethodCallStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "METHODCALL"))
           return false;
   
       // Get METHODCALL.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing METHODCALL.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getMethodResponseStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getMethodResponseStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "METHODRESPONSE"))
           return false;
   
       // Get METHODRESPONSE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing METHODRESPONSE.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getParamValueTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParamValueTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "PARAMVALUE"))
           return false;
   
       // Get IPARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing PARAMVALUE.NAME attribute");
  
     return true;     return true;
 } }


Legend:
Removed from v.1.18  
changed lines
  Added in v.1.24.2.4

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2