(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.69 and 1.81.4.1

version 1.69, 2002/08/25 05:45:26 version 1.81.4.1, 2003/03/11 19:56:55
Line 45 
Line 45 
 #include "CIMInstance.h" #include "CIMInstance.h"
 #include "CIMObject.h" #include "CIMObject.h"
 #include "CIMParamValue.h" #include "CIMParamValue.h"
   #include "System.h"
  
 //#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(9223372036854775808))  #define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000))
 //#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(18446744073709551615)  
 #define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(0x7FFFFFFFFFFFFFFF))  
 #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF)
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 319 
Line 318 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 String XmlReader::getCimNameAttribute(  CIMName XmlReader::getCimNameAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName,     const char* elementName,
Line 335 
Line 334 
     }     }
  
     if (acceptNull && name.size() == 0)     if (acceptNull && name.size() == 0)
         return name;          return CIMName ();
  
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
   #ifdef PEGASUS_SNIA_INTEROP_TEST
       // This is not a Pegasus BUG.  It is a hack to protect against an error
       // from some servers.  In particular, the SNIA IBM server seems to be
       // sending a namespace component with "" as the string.  We cannot handle
       // this. This is probably because they are using the form /root/...
       // In testing, replace illegal CIMName with this value to avoid the
       // exception and let xml parsing continue.  THIS IS TEMP.
       name = "BADNAMESUBSTITUTEDBYPEGASUSCLIENT";
   #else
         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);
         throw XmlSemanticError(lineNumber, buffer);         throw XmlSemanticError(lineNumber, buffer);
   #endif
     }     }
       return CIMName (name);
     return name;  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 398 
Line 406 
     if (!entry.getAttributeValue("CLASSORIGIN", name))     if (!entry.getAttributeValue("CLASSORIGIN", name))
         return CIMName();         return CIMName();
  
       // KS 200209 This may be temp but we are adding test for form
       // CLASSNAME = "" for Wbemservices interoperability.  Returns same
       // as if attribute did not exist.
       if (name.size() == 0)
           return CIMName();
   
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
Line 429 
Line 443 
  
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
   #ifdef PEGASUS_SNIA_INTEROP_TEST
       name = "PEGASUS_SUBSTITUED_THIS_FOR_BAD_NAME";
       return name;
   #endif
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer,         sprintf(buffer,
             "Illegal value for %s.REFERENCECLASS attribute", elementName);             "Illegal value for %s.REFERENCECLASS attribute", elementName);
Line 695 
Line 713 
     return n;     return n;
 } }
  
   // See http://www.ietf.org/rfc/rfc2396.txt section 2
   String XmlReader::decodeURICharacters(String uriString)
   {
       String decodedString;
       Uint32 i;
   
       for (i=0; i<uriString.size(); i++)
       {
           if (uriString[i] == '%')
           {
               if (i+2 >= uriString.size())
               {
                   throw ParseError("Invalid URI encoding");
               }
   
               Uint8 digit1 = _hexCharToNumeric(char(uriString[++i]));
               Uint8 digit2 = _hexCharToNumeric(char(uriString[++i]));
               if ( (digit1 > 15) || (digit2 > 15) )
               {
                   throw ParseError("Invalid URI encoding");
               }
   
               // ATTN: Handle non-UTF-8 character sets
               Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);
               decodedString.append(Char16(decodedChar));
           }
           else
           {
               decodedString.append(uriString[i]);
           }
       }
   
       return decodedString;
   }
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringToSignedInteger // stringToSignedInteger
Line 941 
Line 994 
     {     {
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
         {         {
             if (CompareNoCase(valueString, "TRUE") == 0)              if (System::strcasecmp(valueString, "TRUE") == 0)
                 return CIMValue(true);                 return CIMValue(true);
             else if (CompareNoCase(valueString, "FALSE") == 0)              else if (System::strcasecmp(valueString, "FALSE") == 0)
                 return CIMValue(false);                 return CIMValue(false);
             else             else
                 throw XmlSemanticError(                 throw XmlSemanticError(
Line 972 
Line 1025 
  
             if (!stringToUnsignedInteger(valueString, x))             if (!stringToUnsignedInteger(valueString, x))
             {             {
               char message[128];
               sprintf(message, "Illegal unsigned integer value - %s", valueString);
                 throw XmlSemanticError(                 throw XmlSemanticError(
                     lineNumber, "Invalid unsigned integer value");                      lineNumber, message);
             }             }
  
             switch (type)             switch (type)
Line 1063 
Line 1118 
  
             try             try
             {             {
               // KS 20021002 - Exception if no datatime value. Test for
               // zero length and leave the NULL value in the variable
               // Bugzilla 137  Adds the following if line.
               // Expect this to become permanent but test only for now
   #ifdef PEGASUS_SNIA_INTEROP_TEST
               if (strlen(valueString) != 0)
   #endif
                 tmp.set(valueString);                 tmp.set(valueString);
             }             }
             catch (InvalidDateTimeFormatException&)             catch (InvalidDateTimeFormatException&)
Line 1133 
Line 1195 
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
   #ifdef PEGASUS_SNIA_INTEROP_TEST
       // KS 20021004 - tries to put value in even if empty.
       // Think this is general problem with empty value
       // Need to check meaning of (#PCDATA) - Does it allow empty.
       // Bugzilla tbd
       if (!empty)
   #endif
     value = stringToValue(parser.getLine(), valueString,type);     value = stringToValue(parser.getLine(), valueString,type);
  
     return true;     return true;
Line 1524 
Line 1592 
  
     // Get QUALIFIER.NAME attribute:     // Get QUALIFIER.NAME attribute:
  
     String name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER");
  
     // Get QUALIFIER.TYPE attribute:     // Get QUALIFIER.TYPE attribute:
  
Line 1608 
Line 1676 
  
     // Get PROPERTY.NAME attribute:     // Get PROPERTY.NAME attribute:
  
     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");
  
     // Get PROPERTY.CLASSORIGIN attribute:     // Get PROPERTY.CLASSORIGIN attribute:
  
Line 1711 
Line 1779 
  
     // Get PROPERTY.NAME attribute:     // Get PROPERTY.NAME attribute:
  
     String name =      CIMName name =
         getCimNameAttribute(parser.getLine(), entry, "PROPERTY.ARRAY");         getCimNameAttribute(parser.getLine(), entry, "PROPERTY.ARRAY");
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
Line 1781 
Line 1849 
  
     if (!testStartTag(parser, entry, "HOST"))     if (!testStartTag(parser, entry, "HOST"))
         return false;         return false;
   #ifdef PEGASUS_SNIA_INTEROP_TEST
       // Temp code to allow empty HOST field.
       // SNIA CIMOMs return empty field particularly on enumerateinstance.
       // Simply substitute a string for the empty.
           if (!parser.next(entry))
               throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine());
   
           if (entry.type == XmlEntry::CONTENT)
               host = entry.text;
           else
       {
               parser.putBack(entry);
           host = "HOSTNAMEINSERTEDBYPEGASUSCLIENT";
       }
   
   #else
  
     if (!parser.next(entry) || entry.type != XmlEntry::CONTENT)     if (!parser.next(entry) || entry.type != XmlEntry::CONTENT)
     {     {
Line 1789 
Line 1873 
     }     }
  
     host = entry.text;     host = entry.text;
   #endif
     expectEndTag(parser, "HOST");     expectEndTag(parser, "HOST");
     return true;     return true;
 } }
Line 1805 
Line 1889 
  
 Boolean XmlReader::getNameSpaceElement( Boolean XmlReader::getNameSpaceElement(
     XmlParser& parser,     XmlParser& parser,
     String& nameSpaceComponent)      CIMName& nameSpaceComponent)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 1840 
Line 1924 
     if (!testStartTag(parser, entry, "LOCALNAMESPACEPATH"))     if (!testStartTag(parser, entry, "LOCALNAMESPACEPATH"))
         return false;         return false;
  
     String nameSpaceComponent;      CIMName nameSpaceComponent;
  
     while (getNameSpaceElement(parser, nameSpaceComponent))     while (getNameSpaceElement(parser, nameSpaceComponent))
     {     {
         if (nameSpace.size())         if (nameSpace.size())
             nameSpace += '/';              nameSpace.append('/');
  
         nameSpace += nameSpaceComponent;          nameSpace.append(nameSpaceComponent.getString());
     }     }
  
     if (!nameSpace.size())     if (!nameSpace.size())
Line 1907 
Line 1991 
  
 Boolean XmlReader::getClassNameElement( Boolean XmlReader::getClassNameElement(
     XmlParser& parser,     XmlParser& parser,
     String& className,      CIMName& className,
     Boolean required)     Boolean required)
 { {
     XmlEntry entry;     XmlEntry entry;
Line 1922 
Line 2006 
         else         else
             return false;             return false;
     }     }
   
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     className = getCimNameAttribute(     className = getCimNameAttribute(
         parser.getLine(), entry, "CLASSNAME", true);          parser.getLine(), entry, "CLASSNAME", false);
  
     if (!empty)     if (!empty)
         expectEndTag(parser, "CLASSNAME");         expectEndTag(parser, "CLASSNAME");
Line 1942 
Line 2025 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 KeyBinding::Type XmlReader::getValueTypeAttribute(  CIMKeyBinding::Type XmlReader::getValueTypeAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName)     const char* elementName)
Line 1950 
Line 2033 
     String tmp;     String tmp;
  
     if (!entry.getAttributeValue("VALUETYPE", tmp))     if (!entry.getAttributeValue("VALUETYPE", tmp))
         return KeyBinding::STRING;          return CIMKeyBinding::STRING;
  
     if (String::equal(tmp, "string"))     if (String::equal(tmp, "string"))
         return KeyBinding::STRING;          return CIMKeyBinding::STRING;
     else if (String::equal(tmp, "boolean"))     else if (String::equal(tmp, "boolean"))
         return KeyBinding::BOOLEAN;          return CIMKeyBinding::BOOLEAN;
     else if (String::equal(tmp, "numeric"))     else if (String::equal(tmp, "numeric"))
         return KeyBinding::NUMERIC;          return CIMKeyBinding::NUMERIC;
  
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
  
Line 1967 
Line 2050 
         elementName);         elementName);
  
     throw XmlSemanticError(lineNumber, buffer);     throw XmlSemanticError(lineNumber, buffer);
     return KeyBinding::BOOLEAN;      return CIMKeyBinding::BOOLEAN;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 1982 
Line 2065 
  
 Boolean XmlReader::getKeyValueElement( Boolean XmlReader::getKeyValueElement(
     XmlParser& parser,     XmlParser& parser,
     KeyBinding::Type& type,      CIMKeyBinding::Type& type,
     String& value)     String& value)
 { {
     XmlEntry entry;     XmlEntry entry;
Line 2024 
Line 2107 
  
 Boolean XmlReader::getKeyBindingElement( Boolean XmlReader::getKeyBindingElement(
     XmlParser& parser,     XmlParser& parser,
     String& name,      CIMName& name,
     String& value,     String& value,
     KeyBinding::Type& type)      CIMKeyBinding::Type& type)
 { {
     XmlEntry entry;     XmlEntry entry;
  
Line 2045 
Line 2128 
                       "Expected KEYVALUE or VALUE.REFERENCE element");                       "Expected KEYVALUE or VALUE.REFERENCE element");
         }         }
  
         type = KeyBinding::REFERENCE;          type = CIMKeyBinding::REFERENCE;
         value = reference.toString();         value = reference.toString();
     }     }
  
Line 2069 
Line 2152 
 Boolean XmlReader::getInstanceNameElement( Boolean XmlReader::getInstanceNameElement(
     XmlParser& parser,     XmlParser& parser,
     String& className,     String& className,
     Array<KeyBinding>& keyBindings)      Array<CIMKeyBinding>& keyBindings)
 { {
     className.clear();     className.clear();
     keyBindings.clear();     keyBindings.clear();
Line 2088 
Line 2171 
         return true;         return true;
     }     }
  
     String name;      CIMName name;
     KeyBinding::Type type;      CIMKeyBinding::Type type;
     String value;     String value;
     CIMObjectPath reference;     CIMObjectPath reference;
  
     if (getKeyValueElement(parser, type, value))     if (getKeyValueElement(parser, type, value))
     {     {
         // Use empty key name because none was specified         // Use empty key name because none was specified
         keyBindings.append(KeyBinding(name, value, type));          keyBindings.append(CIMKeyBinding(name, value, type));
     }     }
     else if (getValueReferenceElement(parser, reference))     else if (getValueReferenceElement(parser, reference))
     {     {
         // Use empty key name because none was specified         // Use empty key name because none was specified
         type = KeyBinding::REFERENCE;          type = CIMKeyBinding::REFERENCE;
         value = reference.toString();         value = reference.toString();
         keyBindings.append(KeyBinding(name, value, type));          keyBindings.append(CIMKeyBinding(name, value, type));
     }     }
     else     else
     {     {
         while (getKeyBindingElement(parser, name, value, type))         while (getKeyBindingElement(parser, name, value, type))
             keyBindings.append(KeyBinding(name, value, type));              keyBindings.append(CIMKeyBinding(name, value, type));
     }     }
  
     expectEndTag(parser, "INSTANCENAME");     expectEndTag(parser, "INSTANCENAME");
Line 2121 
Line 2204 
     CIMObjectPath& instanceName)     CIMObjectPath& instanceName)
 { {
     String className;     String className;
     Array<KeyBinding> keyBindings;      Array<CIMKeyBinding> keyBindings;
  
     if (!XmlReader::getInstanceNameElement(parser, className, keyBindings))     if (!XmlReader::getInstanceNameElement(parser, className, keyBindings))
         return false;         return false;
Line 2157 
Line 2240 
     }     }
  
     String className;     String className;
     Array<KeyBinding> keyBindings;      Array<CIMKeyBinding> keyBindings;
  
     if (!getInstanceNameElement(parser, className, keyBindings))     if (!getInstanceNameElement(parser, className, keyBindings))
     {     {
Line 2197 
Line 2280 
     }     }
  
     String className;     String className;
     Array<KeyBinding> keyBindings;      Array<CIMKeyBinding> keyBindings;
  
     if (!getInstanceNameElement(parser, className, keyBindings))     if (!getInstanceNameElement(parser, className, keyBindings))
     {     {
Line 2237 
Line 2320 
             "expected NAMESPACEPATH element");             "expected NAMESPACEPATH element");
     }     }
  
     String className;      CIMName className;
  
     if (!getClassNameElement(parser, className))     if (!getClassNameElement(parser, className))
     {     {
Line 2276 
Line 2359 
             "expected LOCALNAMESPACEPATH element");             "expected LOCALNAMESPACEPATH element");
     }     }
  
     String className;      CIMName className;
  
     if (!getClassNameElement(parser, className))     if (!getClassNameElement(parser, className))
     {     {
Line 2335 
Line 2418 
     else if (strcmp(entry.text, "CLASSNAME") == 0)     else if (strcmp(entry.text, "CLASSNAME") == 0)
     {     {
         parser.putBack(entry);         parser.putBack(entry);
         String className;          CIMName className;
         getClassNameElement(parser, className);         getClassNameElement(parser, className);
         reference.set(String(), CIMNamespaceName(), className);         reference.set(String(), CIMNamespaceName(), className);
     }     }
Line 2353 
Line 2436 
     {     {
         parser.putBack(entry);         parser.putBack(entry);
         String className;         String className;
         Array<KeyBinding> keyBindings;          Array<CIMKeyBinding> keyBindings;
         getInstanceNameElement(parser, className, keyBindings);         getInstanceNameElement(parser, className, keyBindings);
         reference.set(String(), CIMNamespaceName(), className, keyBindings);         reference.set(String(), CIMNamespaceName(), className, keyBindings);
     }     }
Line 2427 
Line 2510 
  
     // Get PROPERTY.NAME attribute:     // Get PROPERTY.NAME attribute:
  
     String name = getCimNameAttribute(      CIMName name = getCimNameAttribute(
         parser.getLine(), entry, "PROPERTY.REFERENCE");         parser.getLine(), entry, "PROPERTY.REFERENCE");
  
     // Get PROPERTY.REFERENCECLASS attribute:     // Get PROPERTY.REFERENCECLASS attribute:
Line 2517 
Line 2600 
  
     // Get PARAMETER.NAME attribute:     // Get PARAMETER.NAME attribute:
  
     String name = getCimNameAttribute(parser.getLine(), entry, "PARAMETER");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "PARAMETER");
  
     // Get PARAMETER.TYPE attribute:     // Get PARAMETER.TYPE attribute:
  
Line 2563 
Line 2646 
  
     // Get PARAMETER.ARRAY.NAME attribute:     // Get PARAMETER.ARRAY.NAME attribute:
  
     String name = getCimNameAttribute(      CIMName name = getCimNameAttribute(
         parser.getLine(), entry, "PARAMETER.ARRAY");         parser.getLine(), entry, "PARAMETER.ARRAY");
  
     // Get PARAMETER.ARRAY.TYPE attribute:     // Get PARAMETER.ARRAY.TYPE attribute:
Line 2614 
Line 2697 
  
     // Get PARAMETER.NAME attribute:     // Get PARAMETER.NAME attribute:
  
     String name = getCimNameAttribute(      CIMName name = getCimNameAttribute(
         parser.getLine(), entry, "PARAMETER.REFERENCE");         parser.getLine(), entry, "PARAMETER.REFERENCE");
  
     // Get PARAMETER.REFERENCECLASS attribute:     // Get PARAMETER.REFERENCECLASS attribute:
Line 2660 
Line 2743 
  
     // Get PARAMETER.NAME attribute:     // Get PARAMETER.NAME attribute:
  
     String name = getCimNameAttribute(      CIMName name = getCimNameAttribute(
         parser.getLine(), entry, "PARAMETER.REFARRAY");         parser.getLine(), entry, "PARAMETER.REFARRAY");
  
     // Get PARAMETER.REFERENCECLASS attribute:     // Get PARAMETER.REFERENCECLASS attribute:
Line 2742 
Line 2825 
  
     // Get NAME attribute:     // Get NAME attribute:
  
     String name = getCimNameAttribute(      CIMName name = getCimNameAttribute(
         parser.getLine(), entry, "QUALIFIER.DECLARATION");         parser.getLine(), entry, "QUALIFIER.DECLARATION");
  
     // Get TYPE attribute:     // Get TYPE attribute:
Line 2850 
Line 2933 
  
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");
  
     CIMType type;     CIMType type;
     getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY");     getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY");
Line 2893 
Line 2976 
     if (!testStartTag(parser, entry, "CLASS"))     if (!testStartTag(parser, entry, "CLASS"))
         return false;         return false;
  
     String name = getCimNameAttribute(parser.getLine(), entry, "CLASS");      CIMName name = getCimNameAttribute(parser.getLine(), entry, "CLASS");
  
     CIMName superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS");     CIMName superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS");
  
Line 3178 
Line 3261 
  
     expectContentOrCData(parser, entry);     expectContentOrCData(parser, entry);
  
     if (CompareNoCase(entry.text, "TRUE") == 0)      if (System::strcasecmp(entry.text, "TRUE") == 0)
         result = true;         result = true;
     else if (CompareNoCase(entry.text, "FALSE") == 0)      else if (System::strcasecmp(entry.text, "FALSE") == 0)
         result = false;         result = false;
     else     else
         throw XmlSemanticError(parser.getLine(),         throw XmlSemanticError(parser.getLine(),
Line 3440 
Line 3523 
     XmlParser& parser,     XmlParser& parser,
     CIMObjectPath& objectName)     CIMObjectPath& objectName)
 { {
     String className;      CIMName className;
  
     if (getClassNameElement(parser, className, false))     if (getClassNameElement(parser, className, false))
     {     {
Line 3542 
Line 3625 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   // getEParamValueTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getEParamValueTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "EXPPARAMVALUE"))
           return false;
   
       // Get EXPPARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing EXPPARAMVALUE.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
 // getMethodCallStartTag() // getMethodCallStartTag()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------


Legend:
Removed from v.1.69  
changed lines
  Added in v.1.81.4.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2