(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.1.1.1 and 1.41

version 1.1.1.1, 2001/01/14 19:53:32 version 1.41, 2002/03/21 01:33:54
Line 1 
Line 1 
 //BEGIN_LICENSE  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 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  // Permission is hereby granted, free of charge, to any person obtaining a copy
 // copy of this software and associated documentation files (the "Software"),  // of this software and associated documentation files (the "Software"), to
 // to deal in the Software without restriction, including without limitation  // deal in the Software without restriction, including without limitation the
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 // and/or sell copies of the Software, and to permit persons to whom the  // sell copies of the Software, and to permit persons to whom the Software is
 // Software is furnished to do so, subject to the following conditions:  // furnished to do so, subject to the following conditions:
   //
   // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   //==============================================================================
   //
   // Author: Mike Brasher (mbrasher@bmc.com)
   //
   // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //                  (carolann_graves@hp.com)
   //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //%/////////////////////////////////////////////////////////////////////////////
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
 // DEALINGS IN THE SOFTWARE.  
 //  
 //END_LICENSE  
 //BEGIN_HISTORY  
 //  
 // Author:  
 //  
 // $Log$  
 // Revision 1.1.1.1  2001/01/14 19:53:32  mike  
 // Pegasus import  
 //  
 //  
 //END_HISTORY  
  
 #include <cassert> #include <cassert>
 #include <cctype> #include <cctype>
 #include <cstdio> #include <cstdio>
 #include <cstdlib> #include <cstdlib>
 #include "Name.h"  #include "CIMName.h"
 #include "XmlReader.h" #include "XmlReader.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "Qualifier.h"  #include "CIMQualifier.h"
 #include "QualifierDecl.h"  #include "CIMQualifierDecl.h"
 #include "ClassDecl.h"  #include "CIMClass.h"
 #include "InstanceDecl.h"  #include "CIMInstance.h"
   #include "CIMObject.h"
   #include "CIMNamedInstance.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 66 
Line 71 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   //  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 100 
Line 126 
         strcmp(entry.text, tagName) != 0)         strcmp(entry.text, tagName) != 0)
     {     {
         char message[MESSAGE_SIZE];         char message[MESSAGE_SIZE];
         sprintf(message, "Expected close of %s element", tagName);          sprintf(message, "Expected close of %s element, got %s instead",
                 tagName,entry.text);
         throw XmlValidationError(parser.getLine(), message);         throw XmlValidationError(parser.getLine(), message);
     }     }
 } }
Line 238 
Line 265 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // testCimStartTag()  // getCimStartTag()
 // //
 //     <!ELEMENT CIM (MESSAGE|DECLARATION)> //     <!ELEMENT CIM (MESSAGE|DECLARATION)>
 //     <!ATTRLIST CIM //     <!ATTRLIST CIM
Line 247 
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\"");  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // getIsArrayAttribute()  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::getIsArrayAttribute(  
     Uint32 lineNumber,  
     const XmlEntry& entry,  
     const char* tagName,  
     Boolean& value)  
 {  
     const char* tmp;  
   
     if (!entry.getAttributeValue("ISARRAY", tmp))  
         return false;  
   
     if (strcmp(tmp, "true") == 0)  
     {  
         value = true;  
         return true;  
     }  
     else if (strcmp(tmp, "false") == 0)  
     {  
         value = false;  
         return true;  
     }  
   
     char buffer[62];  
     sprintf(buffer, "Bad %s.%s attribute value", "ISARRAY", tagName);  
     throw XmlSemanticError(lineNumber, buffer);  
     return false;  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 330 
Line 314 
         throw XmlValidationError(lineNumber, buffer);         throw XmlValidationError(lineNumber, buffer);
     }     }
  
     if (acceptNull && name.getLength() == 0)      if (acceptNull && name.size() == 0)
         return name;         return name;
  
     if (!Name::legal(name))      if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer, "Illegal value for %s.NAME attribute", elementName);         sprintf(buffer, "Illegal value for %s.NAME attribute", elementName);
Line 365 
Line 349 
         throw XmlValidationError(lineNumber, buffer);         throw XmlValidationError(lineNumber, buffer);
     }     }
  
     if (!Name::legal(name))      if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer,         sprintf(buffer,
Line 394 
Line 378 
     if (!entry.getAttributeValue("CLASSORIGIN", name))     if (!entry.getAttributeValue("CLASSORIGIN", name))
         return String();         return String();
  
     if (!Name::legal(name))      if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer,         sprintf(buffer,
Line 423 
Line 407 
     if (!entry.getAttributeValue("REFERENCECLASS", name))     if (!entry.getAttributeValue("REFERENCECLASS", name))
         return String();         return String();
  
     if (!Name::legal(name))      if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer,         sprintf(buffer,
Line 452 
Line 436 
     if (!entry.getAttributeValue("SUPERCLASS", superClass))     if (!entry.getAttributeValue("SUPERCLASS", superClass))
         return String();         return String();
  
     if (!Name::legal(superClass))      if (!CIMName::legal(superClass))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(         sprintf(
Line 467 
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)">
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Type 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;
           }
       }
  
     Type type = Type::NONE;      CIMType type = CIMType::NONE;
  
     if (strcmp(typeName, "boolean") == 0)     if (strcmp(typeName, "boolean") == 0)
         type = Type::BOOLEAN;          type = CIMType::BOOLEAN;
     else if (strcmp(typeName, "string") == 0)     else if (strcmp(typeName, "string") == 0)
         type = Type::STRING;          type = CIMType::STRING;
     else if (strcmp(typeName, "char16") == 0)     else if (strcmp(typeName, "char16") == 0)
         type = Type::CHAR16;          type = CIMType::CHAR16;
     else if (strcmp(typeName, "uint8") == 0)     else if (strcmp(typeName, "uint8") == 0)
         type = Type::UINT8;          type = CIMType::UINT8;
     else if (strcmp(typeName, "sint8") == 0)     else if (strcmp(typeName, "sint8") == 0)
         type = Type::SINT8;          type = CIMType::SINT8;
     else if (strcmp(typeName, "uint16") == 0)     else if (strcmp(typeName, "uint16") == 0)
         type = Type::UINT16;          type = CIMType::UINT16;
     else if (strcmp(typeName, "sint16") == 0)     else if (strcmp(typeName, "sint16") == 0)
         type = Type::SINT16;          type = CIMType::SINT16;
     else if (strcmp(typeName, "uint32") == 0)     else if (strcmp(typeName, "uint32") == 0)
         type = Type::UINT32;          type = CIMType::UINT32;
     else if (strcmp(typeName, "sint32") == 0)     else if (strcmp(typeName, "sint32") == 0)
         type = Type::SINT32;          type = CIMType::SINT32;
     else if (strcmp(typeName, "uint64") == 0)     else if (strcmp(typeName, "uint64") == 0)
         type = Type::UINT64;          type = CIMType::UINT64;
     else if (strcmp(typeName, "sint64") == 0)     else if (strcmp(typeName, "sint64") == 0)
         type = Type::SINT64;          type = CIMType::SINT64;
     else if (strcmp(typeName, "datetime") == 0)     else if (strcmp(typeName, "datetime") == 0)
         type = Type::DATETIME;          type = CIMType::DATETIME;
     else if (strcmp(typeName, "real32") == 0)     else if (strcmp(typeName, "real32") == 0)
         type = Type::REAL32;          type = CIMType::REAL32;
     else if (strcmp(typeName, "real64") == 0)     else if (strcmp(typeName, "real64") == 0)
         type = Type::REAL64;          type = CIMType::REAL64;
     else if (strcmp(typeName, "reference") == 0)     else if (strcmp(typeName, "reference") == 0)
         type = Type::REFERENCE;          type = CIMType::REFERENCE;
  
     // ATTN: "reference" is not legal according to the DTD; however, it is      if ((type == CIMType::NONE) ||
     // used by the XML version of the CIM schema.          ((type == CIMType::REFERENCE) &&
            (strcmp(attributeName, "PARAMTYPE") != 0)))
     if (type == Type::NONE)  
     {     {
         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 643 
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 659 
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 669 
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 706 
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 718 
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 763 
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.
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Value XmlReader::stringToValue(  CIMValue XmlReader::stringToValue(
     Uint32 lineNumber,     Uint32 lineNumber,
     const char* valueString,     const char* valueString,
     Type type)      CIMType type)
 { {
     // 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)
       {
           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));
           }
       }
   #endif
   
       // Create value per type
     switch (type)     switch (type)
     {     {
         case Type::BOOLEAN:          case CIMType::BOOLEAN:
         {         {
             if (strcmp(valueString, "TRUE") == 0)              if (CompareNoCase(valueString, "TRUE") == 0)
                 return Value(true);                  return CIMValue(true);
             else if (strcmp(valueString, "FALSE") == 0)              else if (CompareNoCase(valueString, "FALSE") == 0)
                 return Value(false);                  return CIMValue(false);
             else             else
                 throw XmlSemanticError(                 throw XmlSemanticError(
                     lineNumber, "Bad boolean value");                     lineNumber, "Bad boolean value");
         }         }
  
         case Type::STRING:          case CIMType::STRING:
         {         {
             return Value(valueString);              return CIMValue(valueString);
         }         }
  
         case Type::CHAR16:          case CIMType::CHAR16:
         {         {
             if (strlen(valueString) != 1)             if (strlen(valueString) != 1)
                 throw XmlSemanticError(lineNumber, "Bad char16 value");                 throw XmlSemanticError(lineNumber, "Bad char16 value");
  
             return Value(Char16(valueString[0]));              return CIMValue(Char16(valueString[0]));
         }         }
  
         case Type::UINT8:          case CIMType::UINT8:
         case Type::UINT16:          case CIMType::UINT16:
         case Type::UINT32:          case CIMType::UINT32:
         case Type::UINT64:          case CIMType::UINT64:
         {         {
             Uint64 x;             Uint64 x;
  
Line 816 
Line 978 
  
             switch (type)             switch (type)
             {             {
                 case Type::UINT8: return Value(Uint8(x));                  case CIMType::UINT8:
                 case Type::UINT16: return Value(Uint16(x));                  {
                 case Type::UINT32: return Value(Uint32(x));                      if (x >= (Uint64(1)<<8))
                 case Type::UINT64: return Value(Uint64(x));                      {
                           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));
                 default: break;                 default: break;
             }             }
         }         }
  
         case Type::SINT8:          case CIMType::SINT8:
         case Type::SINT16:          case CIMType::SINT16:
         case Type::SINT32:          case CIMType::SINT32:
         case Type::SINT64:          case CIMType::SINT64:
         {         {
             Sint64 x;             Sint64 x;
  
Line 839 
Line 1025 
  
             switch (type)             switch (type)
             {             {
                 case Type::SINT8: return Value(Sint8(x));                  case CIMType::SINT8:
                 case Type::SINT16: return Value(Sint16(x));                  {
                 case Type::SINT32: return Value(Sint32(x));                      if(  (x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7))) )
                 case Type::SINT64: return Value(Sint64(x));                      {
                           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));
                 default: break;                 default: break;
             }             }
         }         }
  
         case Type::DATETIME:          case CIMType::DATETIME:
         {         {
             DateTime tmp;              CIMDateTime tmp;
  
             try             try
             {             {
Line 860 
Line 1070 
                 throw XmlSemanticError(lineNumber, "Bad datetime value");                 throw XmlSemanticError(lineNumber, "Bad datetime value");
             }             }
  
             return Value(tmp);              return CIMValue(tmp);
         }         }
  
         case Type::REAL32:          case CIMType::REAL32:
         {         {
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                 throw XmlSemanticError(lineNumber, "Bad real value");
  
             return Value(Real32(x));              // ATTN-RK-P3-20010319: This value gets truncated.
               return CIMValue(Real32(x));
         }         }
  
         case Type::REAL64:          case CIMType::REAL64:
         {         {
             Real64 x;             Real64 x;
  
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                 throw XmlSemanticError(lineNumber, "Bad real value");
  
             return Value(x);              return CIMValue(x);
         }         }
  
         default:         default:
Line 897 
Line 1108 
 // //
 //     <!ELEMENT VALUE (#PCDATA)> //     <!ELEMENT VALUE (#PCDATA)>
 // //
   // Return: false if no value element.
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getValueElement( Boolean XmlReader::getValueElement(
     XmlParser& parser,     XmlParser& parser,
     Type type,      CIMType type,
     Value& 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"))
         return false;         return false;
  
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     // Get VALUE content:  
   
     const char* valueString = "";     const char* valueString = "";
  
     if (!empty)     if (!empty)
Line 926 
Line 1136 
     }     }
  
     value = stringToValue(parser.getLine(), valueString,type);     value = stringToValue(parser.getLine(), valueString,type);
   
     return true;     return true;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringArrayToValue()  // getStringValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 template<class T>  Boolean XmlReader::getStringValueElement(
 Value StringArrayToValueAux(      XmlParser& parser,
     Uint32 lineNumber,      String& str,
     const Array<const char*>& stringArray,      Boolean required)
     Type type,  
     T*)  
 { {
     Array<T> array;      XmlEntry entry;
  
     for (Uint32 i = 0, n = stringArray.getSize(); i < n; i++)      if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
     {     {
         Value value = XmlReader::stringToValue(          if (required)
             lineNumber, stringArray[i], type);              throw XmlValidationError(parser.getLine(),"Expected VALUE element");
           return false;
         T x;  
         value.get(x);  
         array.append(x);  
     }     }
  
     return Value(array);      Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
 }  
  
 Value XmlReader::stringArrayToValue(      const char* valueString = "";
     Uint32 lineNumber,  
     const Array<const char*>& array,      if (!empty)
     Type type)  
 {  
     switch (type)  
     {     {
         case Type::BOOLEAN:          if (testContentOrCData(parser, entry))
             return StringArrayToValueAux(lineNumber, array, type, (Boolean*)0);              valueString = entry.text;
  
         case Type::STRING:          expectEndTag(parser, "VALUE");
             return StringArrayToValueAux(lineNumber, array, type, (String*)0);      }
  
         case Type::CHAR16:      str = valueString;
             return StringArrayToValueAux(lineNumber, array, type, (Char16*)0);      return true;
   }
  
         case Type::UINT8:  //----------------------------------------------------------------------------
   //
   // getPropertyValue
   //     Use: Decode property value from SetProperty request and
   //     GetProperty response.
   //
   //     PropertyValue is one of:
   //
   //
   //      <!ELEMENT VALUE.ARRAY (VALUE*)>
   //
   //      <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME|
   //         <!ELEMENT VALUE.ARRAY (VALUE*)>
   //
   //         <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME|
   //                           INSTANCEPATH|LOCALINSTANCEPATH|INSTANCENAME)>
   //
   //         <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
   //
   //----------------------------------------------------------------------------
   Boolean XmlReader::getPropertyValue(
       XmlParser& parser,
       CIMValue& cimValue)
   {
       // Can not test for value type, so assume String
       const CIMType type = CIMType::STRING;
   
       // Test for VALUE element
       if (XmlReader::getValueElement(parser, type, cimValue))
       {
           return true;
       }
   
       // Test for VALUE.ARRAY element
       if (XmlReader::getValueArrayElement(parser, type, cimValue))
       {
          return true;
       }
   
       // Test for VALUE.REFERENCE element
       CIMReference reference;
       if (XmlReader::getValueReferenceElement(parser, reference))
       {
           cimValue.set(reference);
           return true;
       }
   
       // Test for VALUE.REFARRAY element
       if (XmlReader::getValueReferenceArrayElement(parser, cimValue))
       {
          return true;
       }
   
       return false;
   }
   
   //------------------------------------------------------------------------------
   //
   // stringArrayToValue()
   //
   //------------------------------------------------------------------------------
   
   template<class T>
   CIMValue StringArrayToValueAux(
       Uint32 lineNumber,
       const Array<const char*>& stringArray,
       CIMType type,
       T*)
   {
       Array<T> array;
   
       for (Uint32 i = 0, n = stringArray.size(); i < n; i++)
       {
           CIMValue value = XmlReader::stringToValue(
               lineNumber, stringArray[i], type);
   
           T x;
           value.get(x);
           array.append(x);
       }
   
       return CIMValue(array);
   }
   
   CIMValue XmlReader::stringArrayToValue(
       Uint32 lineNumber,
       const Array<const char*>& array,
       CIMType type)
   {
       switch (type)
       {
           case CIMType::BOOLEAN:
               return StringArrayToValueAux(lineNumber, array, type, (Boolean*)0);
   
           case CIMType::STRING:
               return StringArrayToValueAux(lineNumber, array, type, (String*)0);
   
           case CIMType::CHAR16:
               return StringArrayToValueAux(lineNumber, array, type, (Char16*)0);
   
           case CIMType::UINT8:
             return StringArrayToValueAux(lineNumber, array, type, (Uint8*)0);             return StringArrayToValueAux(lineNumber, array, type, (Uint8*)0);
  
         case Type::UINT16:          case CIMType::UINT16:
             return StringArrayToValueAux(lineNumber, array, type, (Uint16*)0);             return StringArrayToValueAux(lineNumber, array, type, (Uint16*)0);
  
         case Type::UINT32:          case CIMType::UINT32:
             return StringArrayToValueAux(lineNumber, array, type, (Uint32*)0);             return StringArrayToValueAux(lineNumber, array, type, (Uint32*)0);
  
         case Type::UINT64:          case CIMType::UINT64:
             return StringArrayToValueAux(lineNumber, array, type, (Uint64*)0);             return StringArrayToValueAux(lineNumber, array, type, (Uint64*)0);
  
         case Type::SINT8:          case CIMType::SINT8:
             return StringArrayToValueAux(lineNumber, array, type, (Sint8*)0);             return StringArrayToValueAux(lineNumber, array, type, (Sint8*)0);
  
         case Type::SINT16:          case CIMType::SINT16:
             return StringArrayToValueAux(lineNumber, array, type, (Sint16*)0);             return StringArrayToValueAux(lineNumber, array, type, (Sint16*)0);
  
         case Type::SINT32:          case CIMType::SINT32:
             return StringArrayToValueAux(lineNumber, array, type, (Sint32*)0);             return StringArrayToValueAux(lineNumber, array, type, (Sint32*)0);
  
         case Type::SINT64:          case CIMType::SINT64:
             return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0);             return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0);
  
         case Type::DATETIME:          case CIMType::DATETIME:
             return StringArrayToValueAux(lineNumber, array, type, (DateTime*)0);              return StringArrayToValueAux(lineNumber, array, type, (CIMDateTime*)0);
  
         case Type::REAL32:          case CIMType::REAL32:
             return StringArrayToValueAux(lineNumber, array, type, (Real32*)0);             return StringArrayToValueAux(lineNumber, array, type, (Real32*)0);
  
         case Type::REAL64:          case CIMType::REAL64:
             return StringArrayToValueAux(lineNumber, array, type, (Real64*)0);             return StringArrayToValueAux(lineNumber, array, type, (Real64*)0);
  
         default:         default:
Line 1011 
Line 1316 
     }     }
  
     // Unreachable:     // Unreachable:
     return Value();      return CIMValue();
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1020 
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(
     XmlParser& parser,     XmlParser& parser,
     Type type,      CIMType type,
     Value& 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 1060 
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 1102 
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 |= Flavor::OVERRIDABLE;          flavor |= CIMFlavor::OVERRIDABLE;
  
     if (toSubClass)     if (toSubClass)
         flavor |= Flavor::TOSUBCLASS;          flavor |= CIMFlavor::TOSUBCLASS;
  
     if (toInstance)     if (toInstance)
         flavor |= Flavor::TOINSTANCE;          flavor |= CIMFlavor::TOINSTANCE;
  
     if (translatable)     if (translatable)
         flavor |= Flavor::TRANSLATABLE;          flavor |= CIMFlavor::TRANSLATABLE;
  
     return flavor;     return flavor;
 } }
Line 1157 
Line 1474 
     Uint32 scope = 0;     Uint32 scope = 0;
  
     if (getCimBooleanAttribute(line, entry, "SCOPE", "CLASS", false, false))     if (getCimBooleanAttribute(line, entry, "SCOPE", "CLASS", false, false))
         scope |= Scope::CLASS;          scope |= CIMScope::CLASS;
  
     if (getCimBooleanAttribute(     if (getCimBooleanAttribute(
         line, entry, "SCOPE", "ASSOCIATION", false, false))         line, entry, "SCOPE", "ASSOCIATION", false, false))
         scope |= Scope::ASSOCIATION;          scope |= CIMScope::ASSOCIATION;
  
     if (getCimBooleanAttribute(     if (getCimBooleanAttribute(
         line, entry, "SCOPE", "REFERENCE", false, false))         line, entry, "SCOPE", "REFERENCE", false, false))
         scope |= Scope::REFERENCE;          scope |= CIMScope::REFERENCE;
  
     if (getCimBooleanAttribute(line, entry, "SCOPE", "PROPERTY", false, false))     if (getCimBooleanAttribute(line, entry, "SCOPE", "PROPERTY", false, false))
         scope |= Scope::PROPERTY;          scope |= CIMScope::PROPERTY;
  
     if (getCimBooleanAttribute(line, entry, "SCOPE", "METHOD", false, false))     if (getCimBooleanAttribute(line, entry, "SCOPE", "METHOD", false, false))
         scope |= Scope::METHOD;          scope |= CIMScope::METHOD;
  
     if (getCimBooleanAttribute(line, entry, "SCOPE", "PARAMETER", false, false))     if (getCimBooleanAttribute(line, entry, "SCOPE", "PARAMETER", false, false))
         scope |= Scope::PARAMETER;          scope |= CIMScope::PARAMETER;
  
     if (getCimBooleanAttribute(line, entry, "SCOPE", "INDICATION",false, false))     if (getCimBooleanAttribute(line, entry, "SCOPE", "INDICATION",false, false))
         scope |= Scope::INDICATION;          scope |= CIMScope::INDICATION;
  
     if (!isEmptyTag)     if (!isEmptyTag)
         expectEndTag(parser, "SCOPE");         expectEndTag(parser, "SCOPE");
Line 1200 
Line 1517 
  
 Boolean XmlReader::getQualifierElement( Boolean XmlReader::getQualifierElement(
     XmlParser& parser,     XmlParser& parser,
     Qualifier& qualifier)      CIMQualifier& qualifier)
 { {
     // Get QUALIFIER element:     // Get QUALIFIER element:
  
Line 1214 
Line 1531 
  
     // Get QUALIFIER.TYPE attribute:     // Get QUALIFIER.TYPE attribute:
  
     Type type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER");      CIMType type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER");
  
     // Get QUALIFIER.PROPAGATED     // Get QUALIFIER.PROPAGATED
  
Line 1227 
Line 1544 
  
     // Get VALUE or VALUE.ARRAY element:     // Get VALUE or VALUE.ARRAY element:
  
     Value value;      // 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;
  
     if (!getValueElement(parser, type, value) &&     if (!getValueElement(parser, type, value) &&
         !getValueArrayElement(parser, type, value))         !getValueArrayElement(parser, type, value))
Line 1242 
Line 1563 
  
     // Build qualifier:     // Build qualifier:
  
     qualifier = Qualifier(name, value, flavor, propagated);      qualifier = CIMQualifier(name, value, flavor, propagated);
     return true;     return true;
 } }
  
Line 1255 
Line 1576 
 template<class CONTAINER> template<class CONTAINER>
 void getQualifierElements(XmlParser& parser, CONTAINER& container) void getQualifierElements(XmlParser& parser, CONTAINER& container)
 { {
     Qualifier qualifier;      CIMQualifier qualifier;
  
     while (XmlReader::getQualifierElement(parser, qualifier))     while (XmlReader::getQualifierElement(parser, qualifier))
     {     {
Line 1283 
Line 1604 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getPropertyElement(XmlParser& parser, Property& property)  Boolean XmlReader::getPropertyElement(XmlParser& parser, CIMProperty& property)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1308 
Line 1629 
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
     Type 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
  
     Value value;      CIMValue value;
     value.setNullValue(type, false);     value.setNullValue(type, false);
     property = Property(      property = CIMProperty(
         name, value, 0, String(), classOrigin, propagated);         name, value, 0, String(), classOrigin, propagated);
  
     if (!empty)     if (!empty)
Line 1323 
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 1385 
Line 1707 
  
 Boolean XmlReader::getPropertyArrayElement( Boolean XmlReader::getPropertyArrayElement(
     XmlParser& parser,     XmlParser& parser,
     Property& property)      CIMProperty& property)
 { {
     // Get PROPERTY element:     // Get PROPERTY element:
  
Line 1403 
Line 1725 
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
     Type type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY");      CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY");
  
     // Get PROPERTY.ARRAYSIZE attribute:     // Get PROPERTY.ARRAYSIZE attribute:
  
Line 1422 
Line 1744 
  
     // Create property:     // Create property:
  
     Value nullValue;      // 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;
     nullValue.setNullValue(type, true, arraySize);     nullValue.setNullValue(type, true, arraySize);
     property = Property(      property = CIMProperty(
         name, nullValue, arraySize, String(), classOrigin, propagated);         name, nullValue, arraySize, String(), classOrigin, propagated);
  
     if (!empty)     if (!empty)
Line 1435 
Line 1760 
  
         // Get value:         // Get value:
  
         Value 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))
         {         {
Line 1533 
Line 1860 
  
     while (getNameSpaceElement(parser, nameSpaceComponent))     while (getNameSpaceElement(parser, nameSpaceComponent))
     {     {
         if (nameSpace.getLength())          if (nameSpace.size())
             nameSpace += '/';             nameSpace += '/';
  
         nameSpace += nameSpaceComponent;         nameSpace += nameSpaceComponent;
     }     }
  
     if (!nameSpace.getLength())      if (!nameSpace.size())
     {     {
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Expected one or more NAMESPACE elements within "             "Expected one or more NAMESPACE elements within "
Line 1641 
Line 1968 
     if (!entry.getAttributeValue("VALUETYPE", tmp))     if (!entry.getAttributeValue("VALUETYPE", tmp))
         return KeyBinding::STRING;         return KeyBinding::STRING;
  
     if (tmp == "string")      if (String::equal(tmp, "string"))
         return KeyBinding::STRING;         return KeyBinding::STRING;
     else if (tmp == "boolean")      else if (String::equal(tmp, "boolean"))
         return KeyBinding::BOOLEAN;         return KeyBinding::BOOLEAN;
     else if (tmp == "numeric")      else if (String::equal(tmp, "numeric"))
         return KeyBinding::NUMERIC;         return KeyBinding::NUMERIC;
  
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
  
     sprintf(buffer,     sprintf(buffer,
         "Illegal value for %s.VALUETYPE attribute; "         "Illegal value for %s.VALUETYPE attribute; "
         "Value must be one of \"string\", \"boolean\", or \"numeric\"",          "CIMValue must be one of \"string\", \"boolean\", or \"numeric\"",
         elementName);         elementName);
  
     throw XmlSemanticError(lineNumber, buffer);     throw XmlSemanticError(lineNumber, buffer);
Line 1667 
Line 1994 
 //     <!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 1711 
Line 2036 
 //     <!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 1729 
Line 2052 
     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 1743 
Line 2077 
 //     <!ATTLIST INSTANCENAME //     <!ATTLIST INSTANCENAME
 //         %ClassName;> //         %ClassName;>
 // //
 // ATTN-B: VALUE.REFERENCE sub-element not accepted yet.  // Note: An empty key name is used in the keyBinding when the INSTANCENAME is
 // ATTN-B: KEYVALUE sub-element nothandled yet.  // specified using a KEYVALUE or a VALUE.REFERENCE.
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 1765 
Line 2099 
  
     className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME");     className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME");
  
     if (!empty)      if (empty)
     {     {
           return true;
       }
   
         String name;         String name;
         KeyBinding::Type type;         KeyBinding::Type type;
         String value;         String value;
       CIMReference reference;
  
       if (getKeyValueElement(parser, type, value))
       {
           // Use empty key name because none was specified
           keyBindings.append(KeyBinding(name, value, type));
       }
       else if (getValueReferenceElement(parser, reference))
       {
           // Use empty key name because none was specified
           type = KeyBinding::REFERENCE;
           value = reference.toString();
           keyBindings.append(KeyBinding(name, value, type));
       }
       else
       {
         while (getKeyBindingElement(parser, name, value, type))         while (getKeyBindingElement(parser, name, value, type))
             keyBindings.append(KeyBinding(name, value, type));             keyBindings.append(KeyBinding(name, value, type));
       }
  
         if (!empty)  
             expectEndTag(parser, "INSTANCENAME");             expectEndTag(parser, "INSTANCENAME");
   
       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;     return true;
 } }
  
Line 1791 
Line 2156 
  
 Boolean XmlReader::getInstancePathElement( Boolean XmlReader::getInstancePathElement(
     XmlParser& parser,     XmlParser& parser,
     Reference& reference)      CIMReference& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1832 
Line 2197 
  
 Boolean XmlReader::getLocalInstancePathElement( Boolean XmlReader::getLocalInstancePathElement(
     XmlParser& parser,     XmlParser& parser,
     Reference& reference)      CIMReference& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1872 
Line 2237 
  
 Boolean XmlReader::getClassPathElement( Boolean XmlReader::getClassPathElement(
     XmlParser& parser,     XmlParser& parser,
     Reference& reference)      CIMReference& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1912 
Line 2277 
  
 Boolean XmlReader::getLocalClassPathElement( Boolean XmlReader::getLocalClassPathElement(
     XmlParser& parser,     XmlParser& parser,
     Reference& reference)      CIMReference& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1954 
Line 2319 
  
 Boolean XmlReader::getValueReferenceElement( Boolean XmlReader::getValueReferenceElement(
     XmlParser& parser,     XmlParser& parser,
     Reference& reference)      CIMReference& reference)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2015 
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 2028 
Line 2432 
  
 Boolean XmlReader::getPropertyReferenceElement( Boolean XmlReader::getPropertyReferenceElement(
     XmlParser& parser,     XmlParser& parser,
     Property& property)      CIMProperty& property)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2059 
Line 2463 
  
     // Create property:     // Create property:
  
     Value value;      CIMValue value;
     value.set(Reference());      value.set(CIMReference());
     property = Property(      property = CIMProperty(
         name, value, 0, referenceClass, classOrigin, propagated);         name, value, 0, referenceClass, classOrigin, propagated);
  
     if (!empty)     if (!empty)
     {     {
         getQualifierElements(parser, property);         getQualifierElements(parser, property);
  
         Reference reference;          CIMReference reference;
  
         if (getValueReferenceElement(parser, reference))         if (getValueReferenceElement(parser, reference))
             property.setValue(reference);             property.setValue(reference);
Line 2088 
Line 2492 
 template<class CONTAINER> template<class CONTAINER>
 void GetPropertyElements(XmlParser& parser, CONTAINER& container) void GetPropertyElements(XmlParser& parser, CONTAINER& container)
 { {
     Property property;      CIMProperty property;
  
     while (XmlReader::getPropertyElement(parser, property) ||     while (XmlReader::getPropertyElement(parser, property) ||
         XmlReader::getPropertyArrayElement(parser, property) ||         XmlReader::getPropertyArrayElement(parser, property) ||
Line 2118 
Line 2522 
  
 Boolean XmlReader::getParameterElement( Boolean XmlReader::getParameterElement(
     XmlParser& parser,     XmlParser& parser,
     Parameter& parameter)      CIMParameter& parameter)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2133 
Line 2537 
  
     // Get PARAMETER.TYPE attribute:     // Get PARAMETER.TYPE attribute:
  
     Type type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER");      CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER");
  
     // Create parameter:     // Create parameter:
  
     parameter = Parameter(name, type);      parameter = CIMParameter(name, type);
  
     if (!empty)     if (!empty)
     {     {
Line 2163 
Line 2567 
  
 Boolean XmlReader::getParameterArrayElement( Boolean XmlReader::getParameterArrayElement(
     XmlParser& parser,     XmlParser& parser,
     Parameter& parameter)      CIMParameter& parameter)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2179 
Line 2583 
  
     // Get PARAMETER.ARRAY.TYPE attribute:     // Get PARAMETER.ARRAY.TYPE attribute:
  
     Type type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY");      CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY");
  
     // Get PARAMETER.ARRAYSIZE attribute:     // Get PARAMETER.ARRAYSIZE attribute:
  
Line 2188 
Line 2592 
  
     // Create parameter:     // Create parameter:
  
     parameter = Parameter(name, type, true, arraySize);      parameter = CIMParameter(name, type, true, arraySize);
  
     if (!empty)     if (!empty)
     {     {
Line 2213 
Line 2617 
  
 Boolean XmlReader::getParameterReferenceElement( Boolean XmlReader::getParameterReferenceElement(
     XmlParser& parser,     XmlParser& parser,
     Parameter& parameter)      CIMParameter& parameter)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2234 
Line 2638 
  
     // Create parameter:     // Create parameter:
  
     parameter = Parameter(name, Type::REFERENCE, false, 0, referenceClass);      parameter = CIMParameter(name, CIMType::REFERENCE, false, 0, referenceClass);
  
     if (!empty)     if (!empty)
     {     {
Line 2247 
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 2254 
Line 2711 
 template<class CONTAINER> template<class CONTAINER>
 void GetParameterElements(XmlParser& parser, CONTAINER& container) void GetParameterElements(XmlParser& parser, CONTAINER& container)
 { {
     Parameter parameter;      CIMParameter parameter;
  
     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 2287 
Line 2745 
  
 Boolean XmlReader::getQualifierDeclElement( Boolean XmlReader::getQualifierDeclElement(
     XmlParser& parser,     XmlParser& parser,
     QualifierDecl& qualifierDecl)      CIMQualifierDecl& qualifierDecl)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2303 
Line 2761 
  
     // Get TYPE attribute:     // Get TYPE attribute:
  
     Type type = getCimTypeAttribute(      CIMType type = getCimTypeAttribute(
         parser.getLine(), entry, "QUALIFIER.DECLARATION");         parser.getLine(), entry, "QUALIFIER.DECLARATION");
  
     // Get ISARRAY attribute:     // Get ISARRAY attribute:
  
     Boolean isArray = false;      Boolean isArray = getCimBooleanAttribute(
     getIsArrayAttribute(          parser.getLine(), entry, "QUALIFIER.DECLARATION", "ISARRAY",
         parser.getLine(), entry, "QUALIFIER.DECLARATION", isArray);          false, false);
  
     // Get ARRAYSIZE attribute:     // Get ARRAYSIZE attribute:
  
Line 2324 
Line 2782 
  
     // No need to look for interior elements if empty tag:     // No need to look for interior elements if empty tag:
  
     Uint32 scope = Scope::NONE;      Uint32 scope = CIMScope::NONE;
     Value value;      CIMValue value;
  
     if (!empty)     if (!empty)
     {     {
Line 2365 
Line 2823 
         expectEndTag(parser, "QUALIFIER.DECLARATION");         expectEndTag(parser, "QUALIFIER.DECLARATION");
     }     }
  
     if (value.getType() == Type::NONE)      if (value.getType() == CIMType::NONE)
     {     {
         if (isArray)         if (isArray)
             value.setNullValue(type, true, arraySize);             value.setNullValue(type, true, arraySize);
Line 2373 
Line 2831 
             value.setNullValue(type, false);             value.setNullValue(type, false);
     }     }
  
     QualifierDecl tmp(name, value, scope, flavor, arraySize);      CIMQualifierDecl tmp(name, value, scope, flavor, arraySize);
     qualifierDecl = QualifierDecl(name, value, scope, flavor, arraySize);      qualifierDecl = CIMQualifierDecl(name, value, scope, flavor, arraySize);
     return true;     return true;
 } }
  
Line 2391 
Line 2849 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getMethodElement(XmlParser& parser, Method& method)  Boolean XmlReader::getMethodElement(XmlParser& parser, CIMMethod& method)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2402 
Line 2860 
  
     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");
  
     Type type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");      CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");
  
     String classOrigin =     String classOrigin =
         getClassOriginAttribute(parser.getLine(), entry, "PROPERTY");         getClassOriginAttribute(parser.getLine(), entry, "PROPERTY");
Line 2410 
Line 2868 
     Boolean propagated = getCimBooleanAttribute(     Boolean propagated = getCimBooleanAttribute(
         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);
  
     method = Method(name, type, classOrigin, propagated);      method = CIMMethod(name, type, classOrigin, propagated);
  
     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 2433 
Line 2893 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getClassElement(XmlParser& parser, ClassDecl& classDecl)  Boolean XmlReader::getClassElement(XmlParser& parser, CIMClass& cimClass)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2444 
Line 2904 
  
     String superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS");     String superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS");
  
     classDecl = ClassDecl(name, superClass);      cimClass = CIMClass(name, superClass);
  
     // Get QUALIFIER elements:     // Get QUALIFIER elements:
  
     getQualifierElements(parser, classDecl);      getQualifierElements(parser, cimClass);
  
     // Get PROPERTY elements:     // Get PROPERTY elements:
  
     GetPropertyElements(parser, classDecl);      GetPropertyElements(parser, cimClass);
  
     // Get METHOD elements:     // Get METHOD elements:
  
     Method method;      CIMMethod method;
  
     while (getMethodElement(parser, method))     while (getMethodElement(parser, method))
         classDecl.addMethod(method);          cimClass.addMethod(method);
  
     // Get CLASS end tag:     // Get CLASS end tag:
  
Line 2480 
Line 2940 
  
 Boolean XmlReader::getInstanceElement( Boolean XmlReader::getInstanceElement(
     XmlParser& parser,     XmlParser& parser,
     InstanceDecl& instanceDecl)      CIMInstance& cimInstance)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2490 
Line 2950 
     String className = getClassNameAttribute(     String className = getClassNameAttribute(
         parser.getLine(), entry, "INSTANCE");         parser.getLine(), entry, "INSTANCE");
  
     instanceDecl = InstanceDecl(className);      cimInstance = CIMInstance(className);
  
     // Get QUALIFIER elements:     // Get QUALIFIER elements:
  
     getQualifierElements(parser, instanceDecl);      getQualifierElements(parser, cimInstance);
  
     // Get PROPERTY elements:     // Get PROPERTY elements:
  
     GetPropertyElements(parser, instanceDecl);      GetPropertyElements(parser, cimInstance);
  
     // Get INSTANCE end tag:     // Get INSTANCE end tag:
  
Line 2508 
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()
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::getObject(XmlParser& parser, CIMClass& x)
   {
       if (!getClassElement(parser, x))
       {
           throw XmlValidationError(parser.getLine(),
               "expected CLASS element");
       }
   }
   
   //------------------------------------------------------------------------------
   //
   // getObject()
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::getObject(XmlParser& parser, CIMInstance& x)
   {
       if (!getInstanceElement(parser, x))
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCE element");
       }
   }
   
   //------------------------------------------------------------------------------
   //
   // getObject()
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::getObject(XmlParser& parser, CIMQualifierDecl& x)
   {
       if (!getQualifierDeclElement(parser, x))
       {
           throw XmlValidationError(parser.getLine(),
               "expected QUALIFIER.DECLARATION element");
       }
   }
   
   //------------------------------------------------------------------------------
 // //
 // getMessageStartTag() // getMessageStartTag()
 // //
Line 2515 
Line 3065 
  
 Boolean XmlReader::getMessageStartTag( Boolean XmlReader::getMessageStartTag(
     XmlParser& parser,     XmlParser& parser,
     Uint32& id,      String& id,
     const char*& protocolVersion)      String& protocolVersion)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2533 
Line 3083 
  
     if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion))     if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion))
         throw XmlValidationError(parser.getLine(),         throw XmlValidationError(parser.getLine(),
             "Bad or missing MESSAGE.ID attribute");              "Bad or missing MESSAGE.PROTOCOLVERSION attribute");
  
     return true;     return true;
 } }
Line 2637 
Line 3187 
  
     expectContentOrCData(parser, entry);     expectContentOrCData(parser, entry);
  
     if (strcmp(entry.text, "TRUE") == 0)      if (CompareNoCase(entry.text, "TRUE") == 0)
         result = true;         result = true;
     else if (strcmp(entry.text, "FALSE") == 0)      else if (CompareNoCase(entry.text, "FALSE") == 0)
         result = false;         result = false;
     else     else
         throw XmlSemanticError(parser.getLine(),         throw XmlSemanticError(parser.getLine(),
Line 2663 
Line 3213 
  
 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 2686 
Line 3236 
         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 2699 
Line 3249 
     return true;     return true;
 } }
  
   
   //------------------------------------------------------------------------------
   // getObjectWithPath()
   //
   // <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getObjectWithPath(
       XmlParser& parser,
       CIMObjectWithPath& objectWithPath)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH"))
           return false;
   
       CIMReference reference;
       Boolean isInstance = false;
   
       if (XmlReader::getInstancePathElement(parser, reference))
           isInstance = true;
       else if (!XmlReader::getClassPathElement(parser, reference))
       {
           throw XmlValidationError(parser.getLine(),
               "Expected INSTANCE element");
       }
   
       if (isInstance)
       {
           CIMInstance cimInstance;
   
           if (!XmlReader::getInstanceElement(parser, cimInstance))
           {
               throw XmlValidationError(parser.getLine(),
                   "Expected INSTANCEPATH or CLASSPATH element");
           }
           objectWithPath.set(reference, CIMObject(cimInstance));
       }
       else
       {
           CIMClass cimClass;
   
           if (!XmlReader::getClassElement(parser, cimClass))
           {
               throw XmlValidationError(parser.getLine(),
                   "Expected CLASS element");
           }
           objectWithPath.set(reference, CIMObject(cimClass));
       }
   
       expectEndTag(parser, "VALUE.OBJECTWITHPATH");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // <objectName>: (CLASSNAME|INSTANCENAME)
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getObjectNameElement(
       XmlParser& parser,
       CIMReference& objectName)
   {
       String className;
   
       if (getClassNameElement(parser, className, false))
       {
           objectName.set(String(), String(), className);
           return true;
       }
       else if (getInstanceNameElement(parser, objectName))
           return true;
       else
       {
           throw XmlValidationError(parser.getLine(),
               "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
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCEPATH or CLASSPATH element");
       }
   
       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;
   }
   
   //------------------------------------------------------------------------------
   //
   // getParamValueElement()
   //
   // <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?>
   // <!ATTLIST PARAMVALUE
   //      %CIMName;
   //      %ParamType;>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParamValueElement(
       XmlParser& parser,
       CIMParamValue& paramValue)
   {
       XmlEntry entry;
       const char* name;
       CIMType type;
       CIMValue value;
   
       if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE"))
           return false;
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       // Get PARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "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;
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.41

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2