(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.129 and 1.129.12.2

version 1.129, 2008/01/30 18:56:21 version 1.129.12.2, 2009/02/09 11:36:51
Line 31 
Line 31 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/Constants.h>
 #include <errno.h> #include <errno.h>
 #include <cctype> #include <cctype>
 #include <cstdio> #include <cstdio>
Line 482 
Line 483 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return name;      return CIMNameUnchecked(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 492 
Line 493 
 // //
 //     <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED"> //     <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED">
 // //
   //     EmbeddedObjectAttributeType:
   //        NO_EMBEDDED_OBJECT     = 0,
   //        EMBEDDED_OBJECT_ATTR   = 1,
   //        EMBEDDED_INSTANCE_ATTR = 2
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 String XmlReader::getEmbeddedObjectAttribute(  XmlReader::EmbeddedObjectAttributeType XmlReader::getEmbeddedObjectAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName)      const char* tagName)
 { {
     String embeddedObject;      const char* embeddedObject;
  
     // Check for both upper case and mixed case "EmbeddedObject"     // Check for both upper case and mixed case "EmbeddedObject"
     // because of an error in an earlier pegasus version  where we     // because of an error in an earlier pegasus version  where we
Line 507 
Line 513 
     // whereas the DMTF spec calls for mixed case.     // whereas the DMTF spec calls for mixed case.
     if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) &&     if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) &&
         !entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject))         !entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject))
         return String();          return NO_EMBEDDED_OBJECT;
  
     // The embeddedObject attribute, if present, must have the string     // The embeddedObject attribute, if present, must have the string
     // value "object" or "instance".     // value "object" or "instance".
     if (!(String::equal(embeddedObject, "object") ||      if (strcmp(embeddedObject, "object") == 0)
           String::equal(embeddedObject, "instance")))      {
           return EMBEDDED_OBJECT_ATTR;
       }
   
       if (strcmp(embeddedObject, "instance") == 0)
     {     {
           return EMBEDDED_INSTANCE_ATTR;
       }
   
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer, "%s.EmbeddedObject", elementName);      sprintf(buffer, "%s.EmbeddedObject", tagName);
  
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",
             "Illegal value for $0 attribute",             "Illegal value for $0 attribute",
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }  
  
     return embeddedObject;      return NO_EMBEDDED_OBJECT;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 561 
Line 573 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return name;      return CIMNameUnchecked(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 594 
Line 606 
             buffer);             buffer);
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
       // The CIMName was already checked with legal() + String()
     return superClass;      return CIMNameUnchecked(superClass);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 862 
Line 874 
     const char* valueString,     const char* valueString,
     CIMType type)     CIMType type)
 { {
       return stringToValue(lineNumber, valueString, strlen(valueString), type);
   }
   
   CIMValue XmlReader::stringToValue(
       Uint32 lineNumber,
       const char* valueString,
       Uint32 valueStringLen,
       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):
  
       // Char string must have been null terminated.
       PEGASUS_ASSERT (!valueString[valueStringLen]);
   
     // Create value per type     // Create value per type
     switch (type)     switch (type)
     {     {
Line 884 
Line 908 
  
         case CIMTYPE_STRING:         case CIMTYPE_STRING:
         {         {
             return CIMValue(String(valueString));              return CIMValue(String(valueString, valueStringLen));
         }         }
  
         case CIMTYPE_CHAR16:         case CIMTYPE_CHAR16:
         {         {
             // Converts UTF-8 to UTF-16             // Converts UTF-8 to UTF-16
             String tmp(valueString);              String tmp(valueString, valueStringLen);
             if (tmp.size() != 1)             if (tmp.size() != 1)
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
Line 1023 
Line 1047 
                 // Bugzilla 137  Adds the following if line.                 // Bugzilla 137  Adds the following if line.
                 // Expect this to become permanent but test only for now                 // Expect this to become permanent but test only for now
 #ifdef PEGASUS_SNIA_INTEROP_TEST #ifdef PEGASUS_SNIA_INTEROP_TEST
                 if (strlen(valueString) != 0)                  if (valueStringLen != 0)
 #endif #endif
                     tmp.set(valueString);                     tmp.set(valueString);
             }             }
Line 1090 
Line 1114 
                 // just the value of the Embedded Object in String                 // just the value of the Embedded Object in String
                 // representation.                 // representation.
                 AutoArrayPtr<char> tmp_buffer(                 AutoArrayPtr<char> tmp_buffer(
                     new char[strlen(valueString) + 1]);                      new char[valueStringLen + 1]);
                 strcpy(tmp_buffer.get(), valueString);                  memcpy(tmp_buffer.get(), valueString, valueStringLen + 1);
                 XmlParser tmp_parser(tmp_buffer.get());                 XmlParser tmp_parser(tmp_buffer.get());
  
                 // The next bit of logic constructs a CIMObject from the                 // The next bit of logic constructs a CIMObject from the
Line 1215 
Line 1239 
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     const char* valueString = "";     const char* valueString = "";
       Uint32 valueStringLen = 0;
     if (!empty)     if (!empty)
     {     {
         if (testContentOrCData(parser, entry))         if (testContentOrCData(parser, entry))
         {         {
             valueString = entry.text;             valueString = entry.text;
               valueStringLen = entry.textLen;
         }         }
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
Line 1232 
Line 1257 
     // Bugzilla tbd     // Bugzilla tbd
     if (!empty)     if (!empty)
 #endif #endif
         value = stringToValue(parser.getLine(), valueString,type);          value = stringToValue(
               parser.getLine(),
               valueString,
               valueStringLen,
               type);
  
     return true;     return true;
 } }
Line 1267 
Line 1296 
     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;     Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
  
     const char* valueString = "";     const char* valueString = "";
       Uint32 valueStringLen = 0;
  
     if (!empty)     if (!empty)
     {     {
         if (testContentOrCData(parser, entry))         if (testContentOrCData(parser, entry))
           {
             valueString = entry.text;             valueString = entry.text;
               valueStringLen = entry.textLen;
           }
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
  
     str = String(valueString);      str = String(valueString, valueStringLen);
     return true;     return true;
 } }
  
Line 1345 
Line 1378 
 template<class T> template<class T>
 CIMValue StringArrayToValueAux( CIMValue StringArrayToValueAux(
     Uint32 lineNumber,     Uint32 lineNumber,
     const Array<const char*>& stringArray,      const Array<CharString>& stringArray,
     CIMType type,     CIMType type,
     T*)     T*)
 { {
Line 1354 
Line 1387 
     for (Uint32 i = 0, n = stringArray.size(); i < n; i++)     for (Uint32 i = 0, n = stringArray.size(); i < n; i++)
     {     {
         CIMValue value = XmlReader::stringToValue(         CIMValue value = XmlReader::stringToValue(
             lineNumber, stringArray[i], type);              lineNumber,
               stringArray[i].value,
               stringArray[i].length,
               type);
  
         T x;         T x;
         value.get(x);         value.get(x);
Line 1369 
Line 1405 
     const Array<const char*>& array,     const Array<const char*>& array,
     CIMType type)     CIMType type)
 { {
       Array<CharString> strArray;
   
       for (Uint32 i = 0, n = array.size() ; i < n ; ++i)
       {
           strArray.append(CharString(array[i], strlen(array[i])));
       }
   
       return _stringArrayToValue(lineNumber, strArray, type);
   }
   
   CIMValue XmlReader::_stringArrayToValue(
       Uint32 lineNumber,
       const Array<CharString> &array,
       CIMType type)
   {
     switch (type)     switch (type)
     {     {
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
Line 1456 
Line 1507 
     // Get VALUE.ARRAY open tag:     // Get VALUE.ARRAY open tag:
  
     XmlEntry entry;     XmlEntry entry;
     Array<const char*> stringArray;      Array<CharString> stringArray;
  
     // If no VALUE.ARRAY start tag, return false     // If no VALUE.ARRAY start tag, return false
     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))     if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY"))
Line 1468 
Line 1519 
  
         while (testStartTagOrEmptyTag(parser, entry, "VALUE"))         while (testStartTagOrEmptyTag(parser, entry, "VALUE"))
         {         {
               // ATTN: NULL values in array will have VALUE.NULL subelement
               // See DSP0201 Version 2.3.0, Section 5.2.3.2
             if (entry.type == XmlEntry::EMPTY_TAG)             if (entry.type == XmlEntry::EMPTY_TAG)
             {             {
                 stringArray.append("");                  stringArray.append(CharString("", 0));
                 continue;                 continue;
             }             }
  
             if (testContentOrCData(parser, entry))             if (testContentOrCData(parser, entry))
                 stringArray.append(entry.text);              {
                   stringArray.append(CharString(entry.text, entry.textLen));
               }
             else             else
                 stringArray.append("");              {
                   stringArray.append(CharString("", 0));
               }
             expectEndTag(parser, "VALUE");             expectEndTag(parser, "VALUE");
         }         }
  
         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 1752 
Line 1808 
  
     // Get PROPERTY.EmbeddedObject attribute:     // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject =
         parser.getLine(), entry, "PROPERTY");          getEmbeddedObjectAttribute(parser.getLine(), entry, "PROPERTY");
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
Line 1774 
Line 1830 
     }     }
  
     Boolean embeddedObjectQualifierValue = false;     Boolean embeddedObjectQualifierValue = false;
     Uint32 ix = property.findQualifier(CIMName("EmbeddedObject"));      Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(CIMName("EmbeddedInstance"));      ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
Line 1792 
Line 1848 
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then convert the EmbeddedObject-encoded string into a CIMObject     // then convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||      Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") ||      Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
Line 1833 
Line 1889 
         }         }
     }     }
 #else #else
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)      if ((embeddedObject == EMBEDDED_OBJECT_ATTR)|| embeddedObjectQualifierValue)
     {     {
         // The EmbeddedObject attribute is only valid on Properties of type         // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
Line 1979 
Line 2035 
  
     // Get PROPERTY.EmbeddedObject attribute:     // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PROPERTY.ARRAY");         parser.getLine(), entry, "PROPERTY.ARRAY");
  
     // Create property:     // Create property:
Line 1995 
Line 2051 
     }     }
  
     Boolean embeddedObjectQualifierValue = false;     Boolean embeddedObjectQualifierValue = false;
     Uint32 ix = property.findQualifier(CIMName("EmbeddedObject"));      Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(CIMName("EmbeddedInstance"));      ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
     {     {
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
Line 2014 
Line 2070 
     // then     // then
     //     Convert the EmbeddedObject-encoded string into a CIMObject     //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||      Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") ||      Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
Line 2055 
Line 2111 
         }         }
     }     }
 #else #else
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)      if ((embeddedObject == EMBEDDED_OBJECT_ATTR)||embeddedObjectQualifierValue)
     {     {
         // The EmbeddedObject attribute is only valid on Properties of type         // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
Line 2321 
Line 2377 
     const XmlEntry& entry,     const XmlEntry& entry,
     const char* elementName)     const char* elementName)
 { {
     String tmp;      const char* tmp;
  
     if (!entry.getAttributeValue("VALUETYPE", tmp))     if (!entry.getAttributeValue("VALUETYPE", tmp))
         return CIMKeyBinding::STRING;         return CIMKeyBinding::STRING;
  
     if (String::equal(tmp, "string"))      if (strcmp(tmp, "string") == 0)
         return CIMKeyBinding::STRING;         return CIMKeyBinding::STRING;
     else if (String::equal(tmp, "boolean"))      else if (strcmp(tmp, "boolean") == 0)
         return CIMKeyBinding::BOOLEAN;         return CIMKeyBinding::BOOLEAN;
     else if (String::equal(tmp, "numeric"))      else if (strcmp(tmp, "numeric") == 0)
         return CIMKeyBinding::NUMERIC;         return CIMKeyBinding::NUMERIC;
  
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
Line 4191 
Line 4247 
  
     // Get PROPERTY.EmbeddedObject     // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PARAMVALUE");         parser.getLine(), entry, "PARAMVALUE");
  
     // Get PARAMVALUE.PARAMTYPE attribute:     // Get PARAMVALUE.PARAMTYPE attribute:
Line 4244 
Line 4300 
             // then             // then
             //     Convert the EmbeddedObject-encoded string into a CIMObject             //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
             Boolean isEmbeddedObject = String::equal(embeddedObject, "object");              if (embeddedObject != NO_EMBEDDED_OBJECT)
             Boolean isEmbeddedInstance =  
                 String::equal(embeddedObject, "instance");  
             if (isEmbeddedObject || isEmbeddedInstance)  
             {             {
                 // The EmbeddedObject attribute is only valid on Parameters                 // The EmbeddedObject attribute is only valid on Parameters
                 // of type string                 // of type string
                 // The type must have been specified.                 // The type must have been specified.
                 if (gotType && (type == CIMTYPE_STRING))                 if (gotType && (type == CIMTYPE_STRING))
                 {                 {
                   if (isEmbeddedObject)                    if (embeddedObject == EMBEDDED_OBJECT_ATTR)
                       // Used below by getValueElement() or                       // Used below by getValueElement() or
                       // getValueArrayElement()                       // getValueArrayElement()
                       effectiveType = CIMTYPE_OBJECT;                       effectiveType = CIMTYPE_OBJECT;
Line 4271 
Line 4324 
                 }                 }
             }             }
 #else #else
             if (String::equal(embeddedObject, "object"))              if (embeddedObject == EMBEDDED_OBJECT_ATTR)
             {             {
                 // The EmbeddedObject attribute is only valid on Parameters                 // The EmbeddedObject attribute is only valid on Parameters
                 // of type string                 // of type string
Line 4332 
Line 4385 
  
     // Get PROPERTY.EmbeddedObject     // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(      EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "RETURNVALUE");         parser.getLine(), entry, "RETURNVALUE");
  
     // Get RETURNVALUE.PARAMTYPE attribute:     // Get RETURNVALUE.PARAMTYPE attribute:
Line 4369 
Line 4422 
             type = CIMTYPE_STRING;             type = CIMTYPE_STRING;
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
         Boolean isEmbeddedObject = String::equal(embeddedObject, "object");          if (embeddedObject != NO_EMBEDDED_OBJECT)
         Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance");  
         if (isEmbeddedObject || isEmbeddedInstance)  
         {         {
             if (gotType && (type == CIMTYPE_STRING))             if (gotType && (type == CIMTYPE_STRING))
             {             {
                 if (isEmbeddedObject)                  if (embeddedObject == EMBEDDED_OBJECT_ATTR)
                     // Used below by getValueElement() or getValueArrayElement()                     // Used below by getValueElement() or getValueArrayElement()
                     type = CIMTYPE_OBJECT;                     type = CIMTYPE_OBJECT;
                 else                 else
Line 4391 
Line 4442 
             }             }
         }         }
 #else #else
         if (String::equal(embeddedObject, "object"))          if (embeddedObject == EMBEDDED_OBJECT_ATTR)
         {         {
             if (gotType && (type == CIMTYPE_STRING))             if (gotType && (type == CIMTYPE_STRING))
             {             {


Legend:
Removed from v.1.129  
changed lines
  Added in v.1.129.12.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2