(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.24.2.7 and 1.42

version 1.24.2.7, 2001/11/08 23:15:30 version 1.42, 2002/03/21 02:50:31
Line 25 
Line 25 
 // //
 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 //              (carolann_graves@hp.com) //              (carolann_graves@hp.com)
 //  
 //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 42 
Line 42 
 #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 264 
Line 265 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // testCimStartTag()  // getCimStartTag()
 // //
 //     <!ELEMENT CIM (MESSAGE|DECLARATION)> //     <!ELEMENT CIM (MESSAGE|DECLARATION)>
 //     <!ATTRLIST CIM //     <!ATTRLIST CIM
Line 273 
Line 274 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 void XmlReader::testCimStartTag(XmlParser& parser)  void XmlReader::getCimStartTag(
       XmlParser& parser,
       const char*& cimVersion,
       const char*& dtdVersion)
 { {
     XmlEntry entry;     XmlEntry entry;
     XmlReader::expectStartTag(parser, entry, "CIM");     XmlReader::expectStartTag(parser, entry, "CIM");
  
     const char* cimVersion;  
   
     if (!entry.getAttributeValue("CIMVERSION", cimVersion))     if (!entry.getAttributeValue("CIMVERSION", cimVersion))
         throw XmlValidationError(         throw XmlValidationError(
             parser.getLine(), "missing CIM.CIMVERSION attribute");             parser.getLine(), "missing CIM.CIMVERSION attribute");
  
     if (strcmp(cimVersion, "2.0") != 0)  
         throw XmlValidationError(parser.getLine(),  
             "CIM.CIMVERSION attribute must be \"2.0\"");  
   
     const char* dtdVersion;  
   
     if (!entry.getAttributeValue("DTDVERSION", dtdVersion))     if (!entry.getAttributeValue("DTDVERSION", dtdVersion))
         throw XmlValidationError(         throw XmlValidationError(
             parser.getLine(), "missing CIM.DTDVERSION attribute");             parser.getLine(), "missing CIM.DTDVERSION attribute");
   
     if (strcmp(dtdVersion, "2.0") != 0)  
         throw XmlValidationError(parser.getLine(),  
             "CIM.DTDVERSION attribute must be \"2.0\"");  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 459 
Line 451 
 // //
 // getCimTypeAttribute() // getCimTypeAttribute()
 // //
   // This method can be used to get a TYPE attribute or a PARAMTYPE attribute.
   // The only significant difference is that PARAMTYPE may specify a value of
   // "reference" type.  This method recognizes these attributes by name, and
   // does not allow a "TYPE" attribute to be of "reference" type.
   //
 //     <!ENTITY % CIMType "TYPE (boolean|string|char16|uint8|sint8|uint16 //     <!ENTITY % CIMType "TYPE (boolean|string|char16|uint8|sint8|uint16
 //         |sint16|uint32|sint32|uint64|sint64|datetime|real32|real64)"> //         |sint16|uint32|sint32|uint64|sint64|datetime|real32|real64)">
 // //
   //     <!ENTITY % ParamType "PARAMTYPE (boolean|string|char16|uint8|sint8
   //         |uint16|sint16|uint32|sint32|uint64|sint64|datetime|real32|real64
   //         |reference)">
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 CIMType XmlReader::getCimTypeAttribute( CIMType XmlReader::getCimTypeAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* tagName)      const char* tagName,
       const char* attributeName,
       Boolean required)
 { {
     const char* typeName;     const char* typeName;
  
     if (!entry.getAttributeValue("TYPE", typeName))      if (!entry.getAttributeValue(attributeName, typeName))
       {
           if (required)
     {     {
         char message[MESSAGE_SIZE];         char message[MESSAGE_SIZE];
         sprintf(message, "missing %s.TYPE attribute", tagName);              sprintf(message, "missing %s.%s attribute", tagName, attributeName);
         throw XmlValidationError(lineNumber, message);         throw XmlValidationError(lineNumber, message);
     }     }
           else
           {
               return CIMType::NONE;
           }
       }
  
     CIMType type = CIMType::NONE;     CIMType type = CIMType::NONE;
  
Line 508 
Line 518 
         type = CIMType::REAL32;         type = CIMType::REAL32;
     else if (strcmp(typeName, "real64") == 0)     else if (strcmp(typeName, "real64") == 0)
         type = CIMType::REAL64;         type = CIMType::REAL64;
       else if (strcmp(typeName, "reference") == 0)
           type = CIMType::REFERENCE;
  
     if (type == CIMType::NONE)      if ((type == CIMType::NONE) ||
           ((type == CIMType::REFERENCE) &&
            (strcmp(attributeName, "PARAMTYPE") != 0)))
     {     {
         char message[MESSAGE_SIZE];         char message[MESSAGE_SIZE];
         sprintf(message, "Illegal value for %s.TYPE attribute", tagName);          sprintf(message, "Illegal value for %s.%s attribute", tagName,
                   attributeName);
         throw XmlSemanticError(lineNumber, message);         throw XmlSemanticError(lineNumber, message);
     }     }
  
Line 630 
Line 645 
     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 646 
Line 676 
     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 656 
Line 686 
     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;
  
               // Find the first non-zero digit so we have something to negate
               while (*p == '0')
     p++;     p++;
  
     // Expect zero or more digits:              // If all the digits are zero, the result is zero
               if (!*p)
                   return true;
  
     while (isdigit(*p))              // Build the Sint64 as a negative number, regardless of the
         p++;              // eventual sign (negative numbers can be bigger than positive ones)
               x = -Sint64(_hexCharToNumeric(*p++));
  
     if (*p)              // 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;         return false;
                   }
                   x = x << 4;
  
     const char* last = p;                  // Make sure we don't overflow when we add the next digit
                   Sint64 newDigit = Sint64(_hexCharToNumeric(*p++));
                   if (PEGASUS_LLONG_MIN - x > -newDigit)
                   {
                       return false;
                   }
                   x = x - newDigit;
               }
  
     while (first != last)              // If we found a non-hexadecimal digit, report an error
         x = 10 * x + (*first++ - '0');              if (*p)
                   return false;
  
     if (negative)              // Return the integer to positive, if necessary, checking for an
               // overflow error
               if (!negative)
               {
                   if (x == PEGASUS_LLONG_MIN)
                   {
                       return false;
                   }
         x = -x;         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:
   
       // At least one decimal digit is required
       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)
       x = -(*p++ - '0');
   
       // Add on each digit, checking for overflow errors
       while (isdigit(*p))
       {
           // Make sure we won't overflow when we multiply by 10
           if (x < PEGASUS_LLONG_MIN/10)
           {
               return false;
           }
           x = 10 * x;
   
           // Make sure we won't overflow when we add the next digit
           Sint64 newDigit = (*p++ - '0');
           if (PEGASUS_LLONG_MIN - x > -newDigit)
           {
               return false;
           }
           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 (x == PEGASUS_LLONG_MIN)
           {
               return false;
           }
           x = -x;
       }
     return true;     return true;
 } }
  
Line 693 
Line 803 
 // //
 // 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 705 
Line 816 
     x = 0;     x = 0;
     const char* p = stringValue;     const char* p = stringValue;
  
     if (!*p)      if (!p || !*p)
         return false;         return false;
  
     // Skip optional sign:      if (*p == '0')
       {
           if ( (p[1] == 'x') || (p[1] == 'X') )
           {
               // Convert a hexadecimal string
  
     if (*p == '-')              // Skip over the "0x"
               p+=2;
   
               // At least one hexadecimal digit is required
               if (!*p)
         return false;         return false;
  
     if (*p == '+')              // Add on each digit, checking for overflow errors
         p++;              while (isxdigit(*p))
               {
                   // Make sure we won't overflow when we multiply by 16
                   if (x > PEGASUS_ULLONG_MAX/16)
                   {
                       return false;
                   }
                   x = x << 4;
  
     // If the next thing is a zero, then it must be the last:                  // We can't overflow when we add the next digit
                   Uint64 newDigit = Uint64(_hexCharToNumeric(*p++));
                   if (PEGASUS_ULLONG_MAX - x < newDigit)
                   {
                       return false;
                   }
                   x = x + newDigit;
               }
  
     if (*p == '0')              // If we found a non-hexadecimal digit, report an error
               if (*p)
                   return false;
   
               return true;
           }
           else
           {
               // A decimal string that starts with '0' must be exactly "0".
         return p[1] == '\0';         return p[1] == '\0';
           }
       }
  
     // Expect a positive decimal digit:     // Expect a positive decimal digit:
  
     const char* first = p;      // Add on each digit, checking for overflow errors
       while (isdigit(*p))
     if (!isdigit(*p) || *p == '0')      {
           // Make sure we won't overflow when we multiply by 10
           if (x > PEGASUS_ULLONG_MAX/10)
           {
         return false;         return false;
           }
           x = 10 * x;
  
     p++;          // Make sure we won't overflow when we add the next digit
           Uint64 newDigit = (*p++ - '0');
     // Expect zero or more digits:          if (PEGASUS_ULLONG_MAX - x < newDigit)
           {
     while (isdigit(*p))              return false;
         p++;          }
           x = x + newDigit;
       }
  
       // If we found a non-decimal digit, report an error
     if (*p)     if (*p)
         return false;         return false;
  
     const char* last = p;  
   
     while (first != last)  
         x = 10 * x + (*first++ - '0');  
   
     return true;     return true;
 } }
  
Line 750 
Line 896 
 // //
 // stringToValue() // stringToValue()
 // //
 // ATTN-C: note that integers are truncated without warning. What should be  // Return: CIMValue. If the string input is zero length creates a CIMValue
 // done in this case? In C they are truncated without warning by design.  //         with value defined by the type.  Else the value is inserted.
   //
   //         Note that this does not set the CIMValue Null if the string is empty.
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 762 
Line 910 
 { {
     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):     // ATTN-B: accepting only UTF-8 for now! (affects string and char16):
  
   // The Specification for the Representation of CIM in XML does not indicate
   // that a default value should be used when a VALUE element is empty.
   //#if 0
       // If strlen == 0, set to default value for type
   
     if (strlen(valueString)==0)     if (strlen(valueString)==0)
     {     {
         switch (type)         switch (type)
Line 781 
Line 934 
             case CIMType::REAL64: return CIMValue(Real64(0));             case CIMType::REAL64: return CIMValue(Real64(0));
         }         }
     }     }
   //#endif
  
       // Create value per type
     switch (type)     switch (type)
     {     {
         case CIMType::BOOLEAN:         case CIMType::BOOLEAN:
Line 823 
Line 978 
  
             switch (type)             switch (type)
             {             {
                 case CIMType::UINT8: return CIMValue(Uint8(x));                  case CIMType::UINT8:
                 case CIMType::UINT16: return CIMValue(Uint16(x));                  {
                 case CIMType::UINT32: return CIMValue(Uint32(x));                      if (x >= (Uint64(1)<<8))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint8 value out of range");
                       }
                       return CIMValue(Uint8(x));
                   }
                   case CIMType::UINT16:
                   {
                       if (x >= (Uint64(1)<<16))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint16 value out of range");
                       }
                       return CIMValue(Uint16(x));
                   }
                   case CIMType::UINT32:
                   {
                       if (x >= (Uint64(1)<<32))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint32 value out of range");
                       }
                       return CIMValue(Uint32(x));
                   }
                 case CIMType::UINT64: return CIMValue(Uint64(x));                 case CIMType::UINT64: return CIMValue(Uint64(x));
                 default: break;                 default: break;
             }             }
Line 846 
Line 1025 
  
             switch (type)             switch (type)
             {             {
                 case CIMType::SINT8: return CIMValue(Sint8(x));                  case CIMType::SINT8:
                 case CIMType::SINT16: return CIMValue(Sint16(x));                  {
                 case CIMType::SINT32: return CIMValue(Sint32(x));                      if(  (x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint8 value out of range");
                       }
                       return CIMValue(Sint8(x));
                   }
                   case CIMType::SINT16:
                   {
                       if(  (x >= (Sint64(1)<<15)) || (x < (-(Sint64(1)<<15))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint16 value out of range");
                       }
                       return CIMValue(Sint16(x));
                   }
                   case CIMType::SINT32:
                   {
                       if(  (x >= (Sint64(1)<<31)) || (x < (-(Sint64(1)<<31))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint32 value out of range");
                       }
                       return CIMValue(Sint32(x));
                   }
                 case CIMType::SINT64: return CIMValue(Sint64(x));                 case CIMType::SINT64: return CIMValue(Sint64(x));
                 default: break;                 default: break;
             }             }
Line 877 
Line 1080 
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                 throw XmlSemanticError(lineNumber, "Bad real value");
  
               // ATTN-RK-P3-20010319: This value gets truncated.
             return CIMValue(Real32(x));             return CIMValue(Real32(x));
         }         }
  
Line 904 
Line 1108 
 // //
 //     <!ELEMENT VALUE (#PCDATA)> //     <!ELEMENT VALUE (#PCDATA)>
 // //
   // Return: false if no value element.
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getValueElement( Boolean XmlReader::getValueElement(
Line 911 
Line 1117 
     CIMType type,     CIMType type,
     CIMValue& value)     CIMValue& value)
 { {
     // Get VALUE start tag:      // Get VALUE start tag: Return false if no VALUE start Tag
  
     XmlEntry entry;     XmlEntry entry;
     if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))     if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
Line 975 
Line 1181 
 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
 // //
 // getPropertyValue // getPropertyValue
 //     Use: Decode property value from getPropertyResponse  //     Use: Decode property value from SetProperty request and
 //     Expect (ERROR|IRETURNVALUE).!ELEMENT VALUE (#PCDATA)>  //     GetProperty response.
   //
   //     PropertyValue is one of:
 // //
 //      PropertyValue:  
 //      <!ELEMENT VALUE>  
 // //
 //      <!ELEMENT VALUE.ARRAY (VALUE*)> //      <!ELEMENT VALUE.ARRAY (VALUE*)>
 // //
 //      <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME| //      <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME|
   //         <!ELEMENT VALUE.ARRAY (VALUE*)>
   //
   //         <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME|
 //                           INSTANCEPATH|LOCALINSTANCEPATH|INSTANCENAME)> //                           INSTANCEPATH|LOCALINSTANCEPATH|INSTANCENAME)>
 // //
   //         <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
   //
 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
 Boolean XmlReader::getPropertyValue( Boolean XmlReader::getPropertyValue(
     XmlParser& parser,     XmlParser& parser,
     CIMValue& cimValue)     CIMValue& cimValue)
 { {
     //ATTN: Test for Element value type      // Can not test for value type, so assume String
     CIMType type = CIMType::STRING;      const CIMType type = CIMType::STRING;
  
       // Test for VALUE element
     if (XmlReader::getValueElement(parser, type, cimValue))     if (XmlReader::getValueElement(parser, type, cimValue))
     {     {
         //cout << "DEBUG xmlReader::getPropertyValue " << __LINE__  
         //    << " CimValue = " << cimValue.toString << endl;  
         return true;         return true;
     }     }
  
     //Test for Element.array value      // Test for VALUE.ARRAY element
     if(XmlReader::getValueArrayElement(parser, type, cimValue))     if(XmlReader::getValueArrayElement(parser, type, cimValue))
       {
        return true;        return true;
       }
  
     // Test for Value.reference type      // Test for VALUE.REFERENCE element
     CIMReference reference;     CIMReference reference;
     if(XmlReader::getValueReferenceElement(parser, reference))     if(XmlReader::getValueReferenceElement(parser, reference))
     {     {
Line 1013 
Line 1225 
         return true;         return true;
     }     }
  
       // Test for VALUE.REFARRAY element
       if (XmlReader::getValueReferenceArrayElement(parser, cimValue))
       {
          return true;
       }
   
    return false;    return false;
 } }
  
Line 1107 
Line 1325 
 // //
 //     <!ELEMENT VALUE.ARRAY (VALUE*)> //     <!ELEMENT VALUE.ARRAY (VALUE*)>
 // //
   //  Return: Boolean. Returns false if there is no VALUE.ARRAY start element
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getValueArrayElement( Boolean XmlReader::getValueArrayElement(
Line 1114 
Line 1334 
     CIMType type,     CIMType type,
     CIMValue& value)     CIMValue& value)
 { {
       // Clears any values from the Array. Assumes this is array CIMValue
     value.clear();     value.clear();
  
     // Get VALUE.ARRAY open tag:     // Get VALUE.ARRAY open tag:
  
     XmlEntry entry;     XmlEntry entry;
       Array<const char*> stringArray;
  
       // If no VALUE.ARRAY start tag, return false
     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)     if (entry.type == XmlEntry::EMPTY_TAG)
         return true;         return true;
  
       if (entry.type != XmlEntry::EMPTY_TAG)
       {
     // For each VALUE element:     // For each VALUE element:
  
     Array<const char*> stringArray;  
   
     while (testStartTagOrEmptyTag(parser, entry, "VALUE"))     while (testStartTagOrEmptyTag(parser, entry, "VALUE"))
     {     {
         if (entry.type == XmlEntry::EMPTY_TAG)         if (entry.type == XmlEntry::EMPTY_TAG)
Line 1147 
Line 1371 
     }     }
  
     expectEndTag(parser, "VALUE.ARRAY");     expectEndTag(parser, "VALUE.ARRAY");
       }
  
     value = stringArrayToValue(parser.getLine(), stringArray, type);     value = stringArrayToValue(parser.getLine(), stringArray, type);
     return true;     return true;
Line 1189 
Line 1414 
     Boolean translatable = getCimBooleanAttribute(     Boolean translatable = getCimBooleanAttribute(
         lineNumber, entry, tagName, "TRANSLATABLE", false, false);         lineNumber, entry, tagName, "TRANSLATABLE", false, false);
  
     Uint32 flavor = 0;      // ATTN: KS P1 5 Mar 2002 Should this not be CIMFlavor::DEFAULTS??
       //Uint32 flavor = CIMFlavor::DEFAULTS;
       // 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;
  
     if (overridable)     if (overridable)
         flavor |= CIMFlavor::OVERRIDABLE;         flavor |= CIMFlavor::OVERRIDABLE;
Line 1314 
Line 1544 
  
     // 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) &&
Line 1397 
Line 1631 
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");
  
     // Create property:      // Create property: Sets type and !isarray
       // ATTN: KS P1 change to use the correct constructor
  
     CIMValue value;     CIMValue value;
     value.setNullValue(type, false);     value.setNullValue(type, false);
Line 1410 
Line 1645 
  
         getQualifierElements(parser, property);         getQualifierElements(parser, property);
  
         // Get value:          // Get value:  Insert value if getValueElement exists (returns True)
  
         if (getValueElement(parser, type, value))         if (getValueElement(parser, type, value))
             property.setValue(value);             property.setValue(value);
Line 1509 
Line 1744 
  
     // Create property:     // Create property:
  
       // ATTN: KS P1 4 March 2002 Change to use correct constructor.
       // ATTN: KS P3 4 March 2002.  Why create extra value. Use same one.
   
     CIMValue nullValue;     CIMValue nullValue;
     nullValue.setNullValue(type, true, arraySize);     nullValue.setNullValue(type, true, arraySize);
     property = CIMProperty(     property = CIMProperty(
Line 1522 
Line 1760 
  
         // 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;         CIMValue value;
  
         if (getValueArrayElement(parser, type, value))         if (getValueArrayElement(parser, type, value))
Line 2140 
Line 2380 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   // getValueReferenceArrayElement()
   //
   //     <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getValueReferenceArrayElement(
       XmlParser& parser,
       CIMValue& value)
   {
       XmlEntry entry;
       Array<CIMReference> referenceArray;
       CIMReference reference;
   
       value.clear();
   
       // Get VALUE.REFARRAY open tag:
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE.REFARRAY"))
           return false;
   
       if (entry.type != XmlEntry::EMPTY_TAG)
       {
           // For each VALUE.REFERENCE element:
   
           while (getValueReferenceElement(parser, reference))
           {
               referenceArray.append(reference);
           }
   
           expectEndTag(parser, "VALUE.REFARRAY");
       }
   
       value.set(referenceArray);
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
 // getPropertyReferenceElement() // getPropertyReferenceElement()
 // //
 //     <!ELEMENT PROPERTY.REFERENCE (QUALIFIER*,(VALUE.REFERENCE)?)> //     <!ELEMENT PROPERTY.REFERENCE (QUALIFIER*,(VALUE.REFERENCE)?)>
Line 2372 
Line 2651 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   // getParameterReferenceArrayElement()
   //
   //     <!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)>
   //     <!ATTLIST PARAMETER.REFARRAY
   //         %CIMName;
   //         %ReferenceClass;
   //         %ArraySize;>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParameterReferenceArrayElement(
       XmlParser& parser,
       CIMParameter& parameter)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "PARAMETER.REFARRAY"))
           return false;
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       // Get PARAMETER.NAME attribute:
   
       String name = getCimNameAttribute(
           parser.getLine(), entry, "PARAMETER.REFARRAY");
   
       // Get PARAMETER.REFERENCECLASS attribute:
   
       String referenceClass = getReferenceClassAttribute(
           parser.getLine(), entry, "PARAMETER.REFARRAY");
   
       // Get PARAMETER.ARRAYSIZE attribute:
   
       Uint32 arraySize = 0;
       getArraySizeAttribute(parser.getLine(), entry, "PARAMETER.REFARRAY",
                             arraySize);
   
       // Create parameter:
   
       parameter = CIMParameter(name, CIMType::REFERENCE, true, arraySize,
                                referenceClass);
   
       if (!empty)
       {
           getQualifierElements(parser, parameter);
           expectEndTag(parser, "PARAMETER.REFARRAY");
       }
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
 // GetParameterElements() // GetParameterElements()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2383 
Line 2715 
  
     while (XmlReader::getParameterElement(parser, parameter) ||     while (XmlReader::getParameterElement(parser, parameter) ||
         XmlReader::getParameterArrayElement(parser, parameter) ||         XmlReader::getParameterArrayElement(parser, parameter) ||
         XmlReader::getParameterReferenceElement(parser, parameter))          XmlReader::getParameterReferenceElement(parser, parameter) ||
           XmlReader::getParameterReferenceArrayElement(parser, parameter))
     {     {
         try         try
         {         {
Line 2539 
Line 2872 
  
     if (!empty)     if (!empty)
     {     {
           // ATTN-RK-P2-20020219: Decoding algorithm must not depend on the
           // ordering of qualifiers and parameters.
         getQualifierElements(parser, method);         getQualifierElements(parser, method);
  
         GetParameterElements(parser, method);         GetParameterElements(parser, method);
Line 2633 
Line 2968 
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
   // getNamedInstanceElement()
   //
   //     <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getNamedInstanceElement(
       XmlParser& parser,
       CIMNamedInstance& namedInstance)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "VALUE.NAMEDINSTANCE"))
           return false;
   
       CIMReference instanceName;
   
       // Get INSTANCENAME elements:
   
       if (!getInstanceNameElement(parser, instanceName))
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCENAME element");
       }
   
       CIMInstance instance;
   
       // Get INSTANCE elements:
   
       if (!getInstanceElement(parser, instance))
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCE element");
       }
   
       // Get VALUE.NAMEDINSTANCE end tag:
   
       expectEndTag(parser, "VALUE.NAMEDINSTANCE");
   
       namedInstance.set(instanceName, instance);
   
       return true;
   }
   
   //------------------------------------------------------------------------------
 // //
 // getObject() // getObject()
 // //
Line 2686 
Line 3066 
 Boolean XmlReader::getMessageStartTag( Boolean XmlReader::getMessageStartTag(
     XmlParser& parser,     XmlParser& parser,
     String& id,     String& id,
     const char*& protocolVersion)      String& protocolVersion)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2936 
Line 3316 
     CIMReference& objectName)     CIMReference& objectName)
 { {
     String className;     String className;
     CIMReference instanceName;  
  
     if (getClassNameElement(parser, className, false))     if (getClassNameElement(parser, className, false))
     {     {
Line 3086 
Line 3465 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getParamValueTag()  // getParamValueElement()
   //
   // <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?>
   // <!ATTLIST PARAMVALUE
   //      %CIMName;
   //      %ParamType;>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getParamValueTag(  Boolean XmlReader::getParamValueElement(
     XmlParser& parser,     XmlParser& parser,
     const char*& name)      CIMParamValue& paramValue)
 { {
     XmlEntry entry;     XmlEntry entry;
       const char* name;
       CIMType type;
       CIMValue value;
  
     if (!testStartTag(parser, entry, "PARAMVALUE"))      if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE"))
         return false;         return false;
  
     // Get IPARAMVALUE.NAME attribute:      Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       // Get PARAMVALUE.NAME attribute:
  
     if (!entry.getAttributeValue("NAME", name))     if (!entry.getAttributeValue("NAME", name))
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Missing PARAMVALUE.NAME attribute");             "Missing PARAMVALUE.NAME attribute");
  
       // Get PARAMVALUE.PARAMTYPE attribute:
   
       type = getCimTypeAttribute(parser.getLine(), entry, "PARAMVALUE",
                                  "PARAMTYPE", false);
   
       if (!empty)
       {
           // Parse VALUE.REFERENCE and VALUE.REFARRAY type
           if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )
           {
               CIMReference reference;
               if (XmlReader::getValueReferenceElement(parser, reference))
               {
                   value.set(reference);
                   type = CIMType::REFERENCE;
               }
               else if (XmlReader::getValueReferenceArrayElement(parser, value))
               {
                   type = CIMType::REFERENCE;
               }
               // If type==reference but no VALUE.REFERENCE found, use null value
           }
   
           // Parse non-reference value
           if ( type != CIMType::REFERENCE )
           {
               // If we don't know what type the value is, read it as a String
               CIMType effectiveType = type;
               if ( effectiveType == CIMType::NONE)
               {
                   effectiveType = CIMType::STRING;
               }
   
               if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) &&
                    !XmlReader::getValueElement(parser, effectiveType, value) )
               {
                   value.clear();    // Isn't necessary; should already be cleared
               }
           }
   
           expectEndTag(parser, "PARAMVALUE");
       }
   
       paramValue = CIMParamValue(name, value, Boolean(type!=CIMType::NONE));
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getReturnValueElement()
   //
   // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)>
   // <!ATTLIST RETURNVALUE
   //      %ParamType;>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getReturnValueElement(
       XmlParser& parser,
       CIMValue& returnValue)
   {
       XmlEntry entry;
       CIMType type;
       CIMValue value;
   
       if (!testStartTag(parser, entry, "RETURNVALUE"))
           return false;
   
       // Get RETURNVALUE.PARAMTYPE attribute:
       // NOTE: Array type return values are not allowed (2/20/02)
   
       type = getCimTypeAttribute(parser.getLine(), entry, "RETURNVALUE",
                                  "PARAMTYPE", false);
   
       // Parse VALUE.REFERENCE type
       if ( (type == CIMType::REFERENCE) || (type == CIMType::NONE) )
       {
           CIMReference reference;
           if (XmlReader::getValueReferenceElement(parser, reference))
           {
               returnValue.set(reference);
               type = CIMType::REFERENCE;
           }
           else if (type == CIMType::REFERENCE)
           {
               throw XmlValidationError(parser.getLine(),
                   "expected VALUE.REFERENCE element");
           }
       }
   
       // Parse non-reference return value
       if ( type != CIMType::REFERENCE )
       {
           // If we don't know what type the value is, read it as a String
           if ( type == CIMType::NONE)
           {
               type = CIMType::STRING;
           }
   
           if ( !XmlReader::getValueElement(parser, type, returnValue) )
           {
               throw XmlValidationError(parser.getLine(),
                   "expected VALUE element");
           }
       }
   
       expectEndTag(parser, "RETURNVALUE");
   
     return true;     return true;
 } }
  


Legend:
Removed from v.1.24.2.7  
changed lines
  Added in v.1.42

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2