(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.38 and 1.59

version 1.38, 2002/03/20 17:47:07 version 1.59, 2002/06/10 20:33:50
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
 // The Open Group, Tivoli Systems // 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
Line 29 
Line 29 
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
   #include <Pegasus/Common/Config.h>
 #include <cassert>  
 #include <cctype> #include <cctype>
 #include <cstdio> #include <cstdio>
 #include <cstdlib> #include <cstdlib>
   #if defined(PEGASUS_OS_TYPE_UNIX)
   #include <errno.h>
   #endif
 #include "CIMName.h" #include "CIMName.h"
 #include "XmlReader.h" #include "XmlReader.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
Line 42 
Line 44 
 #include "CIMClass.h" #include "CIMClass.h"
 #include "CIMInstance.h" #include "CIMInstance.h"
 #include "CIMObject.h" #include "CIMObject.h"
 #include "CIMNamedInstance.h"  
 #include "CIMParamValue.h" #include "CIMParamValue.h"
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 52 
Line 53 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // expectXmlDeclaration()  // getXmlDeclaration()
   //
   //     <?xml version="1.0" encoding="utf-8"?>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 void XmlReader::expectXmlDeclaration(  void XmlReader::getXmlDeclaration(
     XmlParser& parser,     XmlParser& parser,
     XmlEntry& entry)      const char*& xmlVersion,
       const char*& xmlEncoding)
 { {
       XmlEntry entry;
   
     if (!parser.next(entry) ||     if (!parser.next(entry) ||
         entry.type != XmlEntry::XML_DECLARATION ||         entry.type != XmlEntry::XML_DECLARATION ||
         strcmp(entry.text, "xml") != 0)         strcmp(entry.text, "xml") != 0)
Line 67 
Line 73 
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Expected <?xml ... ?> style declaration");             "Expected <?xml ... ?> style declaration");
     }     }
   
       if (!entry.getAttributeValue("version", xmlVersion))
           throw XmlValidationError(
               parser.getLine(), "missing xml.version attribute");
   
       if (!entry.getAttributeValue("encoding", xmlEncoding))
       {
           // ATTN-RK-P3-20020403:  Is there a default encoding?
       }
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 200 
Line 215 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // testEndTag>()  // testEndTag()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 584 
Line 599 
  
 Boolean XmlReader::stringToReal(const char* stringValue, Real64& x) Boolean XmlReader::stringToReal(const char* stringValue, Real64& x)
 { {
       //
       // Check the string against the DMTF-defined grammar
       //
     const char* p = stringValue;     const char* p = stringValue;
  
     if (!*p)     if (!*p)
Line 640 
Line 658 
     if (*p)     if (*p)
         return false;         return false;
  
       //
       // Do the conversion
       //
     char* end;     char* end;
       errno = 0;
     x = strtod(stringValue, &end);     x = strtod(stringValue, &end);
       if (*end || (errno == ERANGE))
       {
           return false;
       }
   
     return true;     return true;
 } }
  
   inline Uint8 _hexCharToNumeric(const char c)
   {
       Uint8 n;
   
       if (isdigit(c))
           n = (c - '0');
       else if (isupper(c))
           n = (c - 'A' + 10);
       else // if (islower(c))
           n = (c - 'a' + 10);
   
       return n;
   }
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringToSignedInteger // stringToSignedInteger
 // //
 //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" ) //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" )
   //    or
   //      [ "+" | "-" ] ( "0x" | "0X" ) 1*hexDigit
 // //
 // ATTN-B: handle conversion from hexadecimal.  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::stringToSignedInteger( Boolean XmlReader::stringToSignedInteger(
Line 661 
Line 703 
     x = 0;     x = 0;
     const char* p = stringValue;     const char* p = stringValue;
  
     if (!*p)      if (!p || !*p)
         return false;         return false;
  
     // Skip optional sign:     // Skip optional sign:
Line 671 
Line 713 
     if (negative || *p == '+')     if (negative || *p == '+')
         p++;         p++;
  
     // If the next thing is a zero, then it must be the last:  
   
     if (*p == '0')     if (*p == '0')
         return p[1] == '\0';      {
           if ( (p[1] == 'x') || (p[1] == 'X') )
     // Expect a positive decimal digit:          {
               // Convert a hexadecimal string
  
     const char* first = p;              // Skip over the "0x"
               p+=2;
  
     if (!isdigit(*p) || *p == '0')              // At least one hexadecimal digit is required
               if (!isxdigit(*p))
         return false;         return false;
  
     p++;              // Build the Sint64 as a negative number, regardless of the
               // eventual sign (negative numbers can be bigger than positive ones)
  
     // Expect zero or more digits:              // Add on each digit, checking for overflow errors
               while (isxdigit(*p))
               {
                   // Make sure we won't overflow when we multiply by 16
                   if (x < PEGASUS_LLONG_MIN/16)
                   {
                       return false;
                   }
                   x = x << 4;
  
     while (isdigit(*p))                  // Make sure we don't overflow when we add the next digit
         p++;                  Sint64 newDigit = Sint64(_hexCharToNumeric(*p++));
                   if (PEGASUS_LLONG_MIN - x > -newDigit)
                   {
                       return false;
                   }
                   x = x - newDigit;
               }
  
               // If we found a non-hexadecimal digit, report an error
     if (*p)     if (*p)
         return false;         return false;
  
     const char* last = p;              // Return the integer to positive, if necessary, checking for an
               // overflow error
               if (!negative)
               {
                   if (x == PEGASUS_LLONG_MIN)
                   {
                       return false;
                   }
                   x = -x;
               }
               return true;
           }
           else
           {
               // A decimal string that starts with '0' must be exactly "0".
               return p[1] == '\0';
           }
       }
   
       // Expect a positive decimal digit:
  
     // Build the Sint64 as a negative number, regardless of the eventual sign      // At least one decimal digit is required
     x = -(*first++ - '0');      if (!isdigit(*p))
           return false;
   
       // Build the Sint64 as a negative number, regardless of the
       // eventual sign (negative numbers can be bigger than positive ones)
  
     while (first != last)      // Add on each digit, checking for overflow errors
       while (isdigit(*p))
     {     {
         if (x < -922337203685477580LL /* -(1<<63) / 10 */)          // Make sure we won't overflow when we multiply by 10
           if (x < PEGASUS_LLONG_MIN/10)
         {         {
             return false;             return false;
         }         }
         x = 10 * x;         x = 10 * x;
         Sint64 newDigit = (*first++ - '0');  
           // Make sure we won't overflow when we add the next digit
           Sint64 newDigit = (*p++ - '0');
         if (PEGASUS_LLONG_MIN - x > -newDigit)         if (PEGASUS_LLONG_MIN - x > -newDigit)
         {         {
             return false;             return false;
Line 713 
Line 799 
         x = x - newDigit;         x = x - newDigit;
     }     }
  
       // If we found a non-decimal digit, report an error
       if (*p)
           return false;
   
       // Return the integer to positive, if necessary, checking for an
       // overflow error
     if (!negative)     if (!negative)
     {     {
         if (x == PEGASUS_LLONG_MIN)         if (x == PEGASUS_LLONG_MIN)
Line 728 
Line 820 
 // //
 // stringToUnsignedInteger // stringToUnsignedInteger
 // //
 //      [ "+" ] ( positiveDecimalDigit *decimalDigit | "0" )  //      ( positiveDecimalDigit *decimalDigit | "0" )
   //    or
   //      ( "0x" | "0X" ) 1*hexDigit
 // //
 // ATTN-B: handle conversion from hexadecimal.  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::stringToUnsignedInteger( Boolean XmlReader::stringToUnsignedInteger(
Line 740 
Line 833 
     x = 0;     x = 0;
     const char* p = stringValue;     const char* p = stringValue;
  
     if (!*p)      if (!p || !*p)
         return false;  
   
     // Skip optional sign:  
   
     if (*p == '-')  
         return false;         return false;
  
     if (*p == '+')  
         p++;  
   
     // If the next thing is a zero, then it must be the last:  
   
     if (*p == '0')     if (*p == '0')
         return p[1] == '\0';      {
           if ( (p[1] == 'x') || (p[1] == 'X') )
     // Expect a positive decimal digit:          {
               // Convert a hexadecimal string
  
     const char* first = p;              // Skip over the "0x"
               p+=2;
  
     if (!isdigit(*p) || *p == '0')              // At least one hexadecimal digit is required
               if (!*p)
         return false;         return false;
  
     p++;              // Add on each digit, checking for overflow errors
               while (isxdigit(*p))
     // Expect zero or more digits:              {
                   // Make sure we won't overflow when we multiply by 16
                   if (x > PEGASUS_ULLONG_MAX/16)
                   {
                       return false;
                   }
                   x = x << 4;
  
     while (isdigit(*p))                  // We can't overflow when we add the next digit
         p++;                  Uint64 newDigit = Uint64(_hexCharToNumeric(*p++));
                   if (PEGASUS_ULLONG_MAX - x < newDigit)
                   {
                       return false;
                   }
                   x = x + newDigit;
               }
  
               // If we found a non-hexadecimal digit, report an error
     if (*p)     if (*p)
         return false;         return false;
  
     const char* last = p;              return true;
           }
           else
           {
               // A decimal string that starts with '0' must be exactly "0".
               return p[1] == '\0';
           }
       }
   
       // Expect a positive decimal digit:
  
     while (first != last)      // Add on each digit, checking for overflow errors
       while (isdigit(*p))
     {     {
         if (x > 1844674407370955161ULL /* (1<<64 - 1) / 10 */)          // Make sure we won't overflow when we multiply by 10
           if (x > PEGASUS_ULLONG_MAX/10)
         {         {
             return false;             return false;
         }         }
         x = 10 * x;         x = 10 * x;
         Uint64 newDigit = (*first++ - '0');  
         if (18446744073709551615ULL - x < newDigit)          // Make sure we won't overflow when we add the next digit
           Uint64 newDigit = (*p++ - '0');
           if (PEGASUS_ULLONG_MAX - x < newDigit)
         {         {
             return false;             return false;
         }         }
         x = x + newDigit;         x = x + newDigit;
     }     }
  
       // If we found a non-decimal digit, report an error
       if (*p)
           return false;
   
     return true;     return true;
 } }
  
Line 811 
Line 927 
 { {
     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):
  
     // If strlen == 0, set to default value for type  
   
     if (strlen(valueString)==0)  
     {  
         switch (type)  
         {  
             case CIMType::BOOLEAN: return CIMValue(false);  
             case CIMType::STRING: return CIMValue(valueString);  
             case CIMType::CHAR16: return CIMValue(Char16('\0'));  
             case CIMType::UINT8: return CIMValue(Uint8(0));  
             case CIMType::UINT16: return CIMValue(Uint16(0));  
             case CIMType::UINT32: return CIMValue(Uint32(0));  
             case CIMType::UINT64: return CIMValue(Uint64(0));  
             case CIMType::SINT8: return CIMValue(Sint8(0));  
             case CIMType::SINT16: return CIMValue(Sint16(0));  
             case CIMType::SINT32: return CIMValue(Sint32(0));  
             case CIMType::SINT64: return CIMValue(Sint64(0));  
             case CIMType::REAL32: return CIMValue(Real32(0));  
             case CIMType::REAL64: return CIMValue(Real64(0));  
         }  
     }  
   
     // Create value per type     // Create value per type
     switch (type)     switch (type)
     {     {
Line 975 
Line 1069 
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                  throw XmlSemanticError(lineNumber, "Bad real number value");
  
             // ATTN-RK-P3-20010319: This value gets truncated.  
             return CIMValue(Real32(x));             return CIMValue(Real32(x));
         }         }
  
Line 986 
Line 1079 
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                  throw XmlSemanticError(lineNumber, "Bad real number value");
  
             return CIMValue(x);             return CIMValue(x);
         }         }
Line 1115 
Line 1208 
     }     }
  
     // Test for VALUE.REFERENCE element     // Test for VALUE.REFERENCE element
     CIMReference reference;      CIMObjectPath reference;
     if (XmlReader::getValueReferenceElement(parser, reference))     if (XmlReader::getValueReferenceElement(parser, reference))
     {     {
         cimValue.set(reference);         cimValue.set(reference);
Line 1243 
Line 1336 
     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))
         return false;         return false;
  
     //ATTN: P1 KS KSTESTNULL - Need to relook at this one.  
     if (entry.type == XmlEntry::EMPTY_TAG)  
         return true;  
   
     if (entry.type != XmlEntry::EMPTY_TAG)     if (entry.type != XmlEntry::EMPTY_TAG)
     {     {
         // For each VALUE element:         // For each VALUE element:
Line 1311 
Line 1400 
     Boolean translatable = getCimBooleanAttribute(     Boolean translatable = getCimBooleanAttribute(
         lineNumber, entry, tagName, "TRANSLATABLE", false, false);         lineNumber, entry, tagName, "TRANSLATABLE", false, false);
  
     // ATTN: KS P1 5 Mar 2002 Should this not be CIMFlavor::DEFAULTS??      // Start with CIMFlavor::NONE.  Defaults are specified in the
     //Uint32 flavor = CIMFlavor::DEFAULTS;      // getCimBooleanAttribute() calls above.
     // ATTN-RK-P1-20020307: No, Karl.  If you initialize to the defaults,  
     // you have to unset the default flavors that don't apply.  The code  
     // below only adds qualifiers.  
     Uint32 flavor = CIMFlavor::NONE;     Uint32 flavor = CIMFlavor::NONE;
  
     if (overridable)     if (overridable)
         flavor |= CIMFlavor::OVERRIDABLE;         flavor |= CIMFlavor::OVERRIDABLE;
           else
                   flavor |= CIMFlavor::DISABLEOVERRIDE;
  
     if (toSubClass)     if (toSubClass)
         flavor |= CIMFlavor::TOSUBCLASS;         flavor |= CIMFlavor::TOSUBCLASS;
           else
                   flavor |= CIMFlavor::RESTRICTED;
  
     if (toInstance)     if (toInstance)
         flavor |= CIMFlavor::TOINSTANCE;         flavor |= CIMFlavor::TOINSTANCE;
Line 1403 
Line 1493 
 // //
 // getQualifierElement() // getQualifierElement()
 // //
 //     <!ELEMENT QUALIFIER (VALUE|VALUE.ARRAY)>  //     <!ELEMENT QUALIFIER (VALUE|VALUE.ARRAY)?>
 //     <!ATTLIST QUALIFIER //     <!ATTLIST QUALIFIER
 //         %CIMName; //         %CIMName;
 //         %CIMType; #REQUIRED //         %CIMType; #REQUIRED
Line 1441 
Line 1531 
  
     // Get VALUE or VALUE.ARRAY element:     // Get VALUE or VALUE.ARRAY element:
  
     // ATTN: KS P1 4 March 2002 - Requires either value or array element or  
     // generates exception.  Correct for spec but means no NULL values on qualifier  
     // values. Alternative is to set NULL value and continue  
   
     CIMValue value;     CIMValue value;
  
     if (!getValueElement(parser, type, value) &&     if (!getValueElement(parser, type, value) &&
         !getValueArrayElement(parser, type, value))         !getValueArrayElement(parser, type, value))
     {     {
         throw XmlSemanticError(parser.getLine(),          value.setNullValue(type, false);
             "Expected VALUE or VALUE.ARRAY element");  
     }     }
  
     // Expect </QUALIFIER>:     // Expect </QUALIFIER>:
Line 1529 
Line 1614 
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");
  
     // Create property: Sets type and !isarray     // Create property: Sets type and !isarray
     // ATTN: KS P1 change to use the correct constructor  
  
     CIMValue value;      CIMValue value(type, false);
     value.setNullValue(type, false);      property = CIMProperty(name, value, 0, String(), classOrigin, propagated);
     property = CIMProperty(  
         name, value, 0, String(), classOrigin, propagated);  
  
     if (!empty)     if (!empty)
     {     {
Line 1641 
Line 1723 
  
     // Create property:     // Create property:
  
     // ATTN: KS P1 4 March 2002 Change to use correct constructor.      CIMValue value(type, true, arraySize);
     // ATTN: KS P3 4 March 2002.  Why create extra value. Use same one.  
   
     CIMValue nullValue;  
     nullValue.setNullValue(type, true, arraySize);  
     property = CIMProperty(     property = CIMProperty(
         name, nullValue, arraySize, String(), classOrigin, propagated);          name, value, arraySize, String(), classOrigin, propagated);
  
     if (!empty)     if (!empty)
     {     {
Line 1657 
Line 1735 
  
         // Get value:         // Get value:
  
         // ATTN: KS P1 4 March 2002. Does not set array type into value.  
         // ATTN: Thus, if it returns false, the CIMValue is nothing.  
         CIMValue value;  
   
         if (getValueArrayElement(parser, type, value))         if (getValueArrayElement(parser, type, value))
         {         {
             if (arraySize && arraySize != value.getArraySize())             if (arraySize && arraySize != value.getArraySize())
Line 1950 
Line 2024 
  
     if (!getKeyValueElement(parser, type, value))     if (!getKeyValueElement(parser, type, value))
     {     {
         CIMReference reference;          CIMObjectPath reference;
  
         if (!getValueReferenceElement(parser, reference))         if (!getValueReferenceElement(parser, reference))
         {         {
Line 2004 
Line 2078 
     String name;     String name;
     KeyBinding::Type type;     KeyBinding::Type type;
     String value;     String value;
     CIMReference reference;      CIMObjectPath reference;
  
     if (getKeyValueElement(parser, type, value))     if (getKeyValueElement(parser, type, value))
     {     {
Line 2031 
Line 2105 
  
 Boolean XmlReader::getInstanceNameElement( Boolean XmlReader::getInstanceNameElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& instanceName)      CIMObjectPath& instanceName)
 { {
     String className;     String className;
     Array<KeyBinding> keyBindings;     Array<KeyBinding> keyBindings;
Line 2053 
Line 2127 
  
 Boolean XmlReader::getInstancePathElement( Boolean XmlReader::getInstancePathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& reference)      CIMObjectPath& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2094 
Line 2168 
  
 Boolean XmlReader::getLocalInstancePathElement( Boolean XmlReader::getLocalInstancePathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& reference)      CIMObjectPath& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2134 
Line 2208 
  
 Boolean XmlReader::getClassPathElement( Boolean XmlReader::getClassPathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& reference)      CIMObjectPath& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2174 
Line 2248 
  
 Boolean XmlReader::getLocalClassPathElement( Boolean XmlReader::getLocalClassPathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& reference)      CIMObjectPath& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2216 
Line 2290 
  
 Boolean XmlReader::getValueReferenceElement( Boolean XmlReader::getValueReferenceElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& reference)      CIMObjectPath& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2288 
Line 2362 
     CIMValue& value)     CIMValue& value)
 { {
     XmlEntry entry;     XmlEntry entry;
     Array<CIMReference> referenceArray;      Array<CIMObjectPath> referenceArray;
     CIMReference reference;      CIMObjectPath reference;
  
     value.clear();     value.clear();
  
Line 2360 
Line 2434 
  
     // Create property:     // Create property:
  
     CIMValue value;      CIMValue value = CIMValue(CIMType::REFERENCE, false, 0);
     value.set(CIMReference());  //    value.set(CIMObjectPath());
     property = CIMProperty(     property = CIMProperty(
         name, value, 0, referenceClass, classOrigin, propagated);         name, value, 0, referenceClass, classOrigin, propagated);
  
Line 2369 
Line 2443 
     {     {
         getQualifierElements(parser, property);         getQualifierElements(parser, property);
  
         CIMReference reference;          CIMObjectPath reference;
  
         if (getValueReferenceElement(parser, reference))         if (getValueReferenceElement(parser, reference))
             property.setValue(reference);             property.setValue(reference);
Line 2873 
Line 2947 
  
 Boolean XmlReader::getNamedInstanceElement( Boolean XmlReader::getNamedInstanceElement(
     XmlParser& parser,     XmlParser& parser,
     CIMNamedInstance& namedInstance)      CIMInstance& namedInstance)
 { {
     XmlEntry entry;     XmlEntry entry;
  
     if (!testStartTag(parser, entry, "VALUE.NAMEDINSTANCE"))     if (!testStartTag(parser, entry, "VALUE.NAMEDINSTANCE"))
         return false;         return false;
  
     CIMReference instanceName;      CIMObjectPath instanceName;
  
     // Get INSTANCENAME elements:     // Get INSTANCENAME elements:
  
Line 2890 
Line 2964 
             "expected INSTANCENAME element");             "expected INSTANCENAME element");
     }     }
  
     CIMInstance instance;  
   
     // Get INSTANCE elements:     // Get INSTANCE elements:
  
     if (!getInstanceElement(parser, instance))      if (!getInstanceElement(parser, namedInstance))
     {     {
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "expected INSTANCE element");             "expected INSTANCE element");
Line 2904 
Line 2976 
  
     expectEndTag(parser, "VALUE.NAMEDINSTANCE");     expectEndTag(parser, "VALUE.NAMEDINSTANCE");
  
     namedInstance.set(instanceName, instance);      namedInstance.setPath (instanceName);
  
     return true;     return true;
 } }
Line 3110 
Line 3182 
  
 Boolean XmlReader::getErrorElement( Boolean XmlReader::getErrorElement(
     XmlParser& parser,     XmlParser& parser,
     CIMStatusCode& code,      CIMException& cimException,
     const char*& description,  
     Boolean required)     Boolean required)
 { {
     XmlEntry entry;     XmlEntry entry;
Line 3133 
Line 3204 
         throw XmlValidationError(         throw XmlValidationError(
             parser.getLine(), "missing ERROR.CODE attribute");             parser.getLine(), "missing ERROR.CODE attribute");
  
     code = CIMStatusCode(tmpCode);  
   
     // Get ERROR.DESCRIPTION:     // Get ERROR.DESCRIPTION:
  
     description = "";      String tmpDescription;
     entry.getAttributeValue("DESCRIPTION", description);  
       entry.getAttributeValue("DESCRIPTION", tmpDescription);
  
     if (!empty)     if (!empty)
         expectEndTag(parser, "ERROR");         expectEndTag(parser, "ERROR");
  
       cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription);
     return true;     return true;
 } }
  
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // getObjectWithPath()  // getValueObjectElement()
   //
   // <!ELEMENT VALUE.OBJECT (CLASS|INSTANCE)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getValueObjectElement(
       XmlParser& parser,
       CIMObject& object)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "VALUE.OBJECT"))
           return false;
   
       CIMInstance cimInstance;
       CIMClass cimClass;
   
       if (XmlReader::getInstanceElement(parser, cimInstance))
       {
           object = CIMObject(cimInstance);
       }
       else if (!XmlReader::getClassElement(parser, cimClass))
       {
           object = CIMObject(cimClass);
       }
       else
       {
           throw XmlValidationError(parser.getLine(),
               "Expected INSTANCE or CLASS element");
       }
   
       expectEndTag(parser, "VALUE.OBJECT");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   // getValueObjectWithPathElement()
 // //
 // <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))> // <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getObjectWithPath(  Boolean XmlReader::getValueObjectWithPathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMObjectWithPath& objectWithPath)      CIMObject& objectWithPath)
 { {
     XmlEntry entry;     XmlEntry entry;
  
     if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH"))     if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH"))
         return false;         return false;
  
     CIMReference reference;      CIMObjectPath reference;
     Boolean isInstance = false;     Boolean isInstance = false;
  
     if (XmlReader::getInstancePathElement(parser, reference))     if (XmlReader::getInstancePathElement(parser, reference))
Line 3171 
Line 3280 
     else if (!XmlReader::getClassPathElement(parser, reference))     else if (!XmlReader::getClassPathElement(parser, reference))
     {     {
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Expected INSTANCE element");              "Expected INSTANCEPATH or CLASSPATH element");
     }     }
  
     if (isInstance)     if (isInstance)
Line 3181 
Line 3290 
         if (!XmlReader::getInstanceElement(parser, cimInstance))         if (!XmlReader::getInstanceElement(parser, cimInstance))
         {         {
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected INSTANCEPATH or CLASSPATH element");                  "Expected INSTANCE element");
         }         }
         objectWithPath.set(reference, CIMObject(cimInstance));          objectWithPath = CIMObject (cimInstance);
           objectWithPath.setPath (reference);
     }     }
     else     else
     {     {
Line 3194 
Line 3304 
             throw XmlValidationError(parser.getLine(),             throw XmlValidationError(parser.getLine(),
                 "Expected CLASS element");                 "Expected CLASS element");
         }         }
         objectWithPath.set(reference, CIMObject(cimClass));          objectWithPath = CIMObject (cimClass);
           objectWithPath.setPath (reference);
     }     }
  
     expectEndTag(parser, "VALUE.OBJECTWITHPATH");     expectEndTag(parser, "VALUE.OBJECTWITHPATH");
Line 3203 
Line 3314 
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
   // getValueObjectWithLocalPathElement()
   //
   // <!ELEMENT VALUE.OBJECTWITHLOCALPATH
   //     ((LOCALCLASSPATH,CLASS)|(LOCALINSTANCEPATH,INSTANCE))>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getValueObjectWithLocalPathElement(
       XmlParser& parser,
       CIMObject& objectWithPath)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "VALUE.OBJECTWITHLOCALPATH"))
           return false;
   
       CIMObjectPath reference;
       Boolean isInstance = false;
   
       if (XmlReader::getLocalInstancePathElement(parser, reference))
           isInstance = true;
       else if (!XmlReader::getLocalClassPathElement(parser, reference))
       {
           throw XmlValidationError(parser.getLine(),
               "Expected LOCALINSTANCEPATH or LOCALCLASSPATH element");
       }
   
       if (isInstance)
       {
           CIMInstance cimInstance;
   
           if (!XmlReader::getInstanceElement(parser, cimInstance))
           {
               throw XmlValidationError(parser.getLine(),
                   "Expected INSTANCE element");
           }
           objectWithPath = CIMObject (cimInstance);
           objectWithPath.setPath (reference);
       }
       else
       {
           CIMClass cimClass;
   
           if (!XmlReader::getClassElement(parser, cimClass))
           {
               throw XmlValidationError(parser.getLine(),
                   "Expected CLASS element");
           }
           objectWithPath = CIMObject (cimClass);
           objectWithPath.setPath (reference);
       }
   
       expectEndTag(parser, "VALUE.OBJECTWITHLOCALPATH");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   // getObjectArray()
   //
   // <object>
   //     (VALUE.OBJECT|VALUE.OBJECTWITHLOCALPATH|VALUE.OBJECTWITHPATH)
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::getObjectArray(
       XmlParser& parser,
       Array<CIMObject>& objectArray)
   {
       CIMObject object;
       CIMObject objectWithPath;
   
       objectArray.clear();
   
       if (getValueObjectElement(parser, object))
       {
           objectArray.append(object);
           while (getValueObjectElement(parser, object))
               objectArray.append(object);
       }
       else if (getValueObjectWithPathElement(parser, objectWithPath))
       {
           objectArray.append(objectWithPath);
           while (getValueObjectWithPathElement(parser, objectWithPath))
               objectArray.append(objectWithPath);
       }
       else if (getValueObjectWithLocalPathElement(parser, objectWithPath))
       {
           objectArray.append(objectWithPath);
           while (getValueObjectWithLocalPathElement(parser, objectWithPath))
               objectArray.append(objectWithPath);
       }
   }
   
   //------------------------------------------------------------------------------
 // //
 // <objectName>: (CLASSNAME|INSTANCENAME) // <objectName>: (CLASSNAME|INSTANCENAME)
 // //
Line 3210 
Line 3416 
  
 Boolean XmlReader::getObjectNameElement( Boolean XmlReader::getObjectNameElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& objectName)      CIMObjectPath& objectName)
 { {
     String className;     String className;
  
Line 3238 
Line 3444 
  
 Boolean XmlReader::getObjectPathElement( Boolean XmlReader::getObjectPathElement(
     XmlParser& parser,     XmlParser& parser,
     CIMReference& objectPath)      CIMObjectPath& objectPath)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 3401 
Line 3607 
         // Parse VALUE.REFERENCE and VALUE.REFARRAY type         // Parse VALUE.REFERENCE and VALUE.REFARRAY type
         if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )         if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )
         {         {
             CIMReference reference;              CIMObjectPath reference;
             if (XmlReader::getValueReferenceElement(parser, reference))             if (XmlReader::getValueReferenceElement(parser, reference))
             {             {
                 value.set(reference);                 value.set(reference);
Line 3469 
Line 3675 
     // Parse VALUE.REFERENCE type     // Parse VALUE.REFERENCE type
     if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )     if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )
     {     {
         CIMReference reference;          CIMObjectPath reference;
         if (XmlReader::getValueReferenceElement(parser, reference))         if (XmlReader::getValueReferenceElement(parser, reference))
         {         {
             returnValue.set(reference);             returnValue.set(reference);


Legend:
Removed from v.1.38  
changed lines
  Added in v.1.59

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2