(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.131 and 1.144.4.3

version 1.131, 2008/08/12 19:36:13 version 1.144.4.3, 2012/02/21 17:22:10
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // 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.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
Line 40 
Line 38 
 # include <errno.h> # include <errno.h>
 #endif #endif
 #include "CIMName.h" #include "CIMName.h"
   #include "CIMNameCast.h"
 #include "XmlReader.h" #include "XmlReader.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
 #include "CIMQualifier.h" #include "CIMQualifier.h"
Line 54 
Line 53 
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
 #include <Pegasus/Common/StringConversion.h> #include <Pegasus/Common/StringConversion.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
 #include "CIMNameUnchecked.h"  
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
Line 206 
Line 204 
     {     {
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.EXPECTED_CDATA",             "Common.XmlReader.EXPECTED_CDATA",
             "Expected content of CDATA");              "Expected content or CDATA");
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
Line 267 
Line 265 
     XmlEntry& entry,     XmlEntry& entry,
     const char* tagName)     const char* tagName)
 { {
     if (!parser.next(entry) ||      if (!parser.next(entry))
        (entry.type != XmlEntry::START_TAG &&      {
           return false;
       }
       if ((entry.type != XmlEntry::START_TAG &&
         entry.type != XmlEntry::EMPTY_TAG) ||         entry.type != XmlEntry::EMPTY_TAG) ||
         strcmp(entry.text, tagName) != 0)         strcmp(entry.text, tagName) != 0)
     {     {
Line 371 
Line 372 
     const char* elementName,     const char* elementName,
     Boolean acceptNull)     Boolean acceptNull)
 { {
     String name;      const char* name;
  
     if (!entry.getAttributeValue("NAME", name))     if (!entry.getAttributeValue("NAME", name))
     {     {
Line 385 
Line 386 
         throw XmlValidationError(lineNumber, mlParms);         throw XmlValidationError(lineNumber, mlParms);
     }     }
  
     if (acceptNull && name.size() == 0)      if (acceptNull && *name == '\0')
         return CIMName ();         return CIMName ();
  
       Uint32 size = CIMNameLegalASCII(name);
   
       if (size)
       {
           String tmp(name, size);
           return CIMName(CIMNameCast(tmp));
       }
   
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
 #ifdef PEGASUS_SNIA_INTEROP_TEST #ifdef PEGASUS_SNIA_INTEROP_TEST
Line 408 
Line 417 
  
 #endif #endif
     }     }
     return CIMNameUnchecked(name);  
       return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 472 
Line 482 
     if (!entry.getAttributeValue("CLASSORIGIN", name))     if (!entry.getAttributeValue("CLASSORIGIN", name))
         return CIMName();         return CIMName();
  
       /* Interoperability hack to make the C++ client of OpenPegasus able
          to deal with the wbemservices CIMOM delivered with Sun Solaris.
          The issue is that the wbemservices delivers Xml responses with
          CLASSORIGIN=""
          Originally this had been reported with Bug#537.
       */
       if (name.size()==0)
       {
           return CIMName();
       }
   
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
Line 484 
Line 505 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(name);      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 574 
Line 595 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(name);      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 607 
Line 628 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(superClass);      return CIMNameCast(superClass);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 772 
Line 793 
 { {
     Uint32 i;     Uint32 i;
  
     Array<Uint8> utf8Chars;      Buffer utf8Chars;
  
     for (i=0; i<uriString.size(); i++)     for (i=0; i<uriString.size(); i++)
     {     {
Line 799 
Line 820 
             }             }
  
             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);
             utf8Chars.append((Uint8)decodedChar);              utf8Chars.append((char)decodedChar);
         }         }
         else         else
         {         {
             utf8Chars.append((Uint8)uriString[i]);              utf8Chars.append((char)uriString[i]);
         }         }
     }     }
  
Line 811 
Line 832 
     if (uriString.size() > 0)     if (uriString.size() > 0)
     {     {
         // Convert UTF-8 to UTF-16 and return the String         // Convert UTF-8 to UTF-16 and return the String
         utf8Chars.append('\0');          return String(utf8Chars.getData(), utf8Chars.size());
         return String((char *)utf8Chars.getData());  
     }     }
     else     else
     {     {
Line 822 
Line 842 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringToSignedInteger  
 //  
 //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      [ "+" | "-" ] ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToSignedInteger(  
     const char* stringValue,  
     Sint64& x)  
 {  
     return (StringConversion::stringToSint64(  
                 stringValue, StringConversion::decimalStringToUint64, x) ||  
             StringConversion::stringToSint64(  
                 stringValue, StringConversion::hexStringToUint64, x));  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToUnsignedInteger  
 //  
 //      ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToUnsignedInteger(  
     const char* stringValue,  
     Uint64& x)  
 {  
     return (StringConversion::decimalStringToUint64(stringValue, x) ||  
             StringConversion::hexStringToUint64(stringValue, x));  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToValue() // stringToValue()
 // //
 // Return: CIMValue. If the string input is zero length creates a CIMValue // Return: CIMValue. If the string input is zero length creates a CIMValue
Line 874 
Line 856 
     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 896 
Line 890 
  
         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 921 
Line 915 
         {         {
             Uint64 x;             Uint64 x;
  
             if (!stringToUnsignedInteger(valueString, x))              if (!StringConversion::stringToUnsignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_UI_VALUE",                     "Common.XmlReader.INVALID_UI_VALUE",
Line 976 
Line 970 
         {         {
             Sint64 x;             Sint64 x;
  
             if (!stringToSignedInteger(valueString, x))              if (!StringConversion::stringToSignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_SI_VALUE",                     "Common.XmlReader.INVALID_SI_VALUE",
Line 1035 
Line 1029 
                 // 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 1083 
Line 1077 
 //  just a Pegasus internal representation of an embedded object. However, //  just a Pegasus internal representation of an embedded object. However,
 //  this case is used when decoding string representations of embedded objects. //  this case is used when decoding string representations of embedded objects.
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         {         {
             CIMObject x;             CIMObject x;
  
Line 1102 
Line 1094 
                 // 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 1114 
Line 1106 
  
                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_INSTANCE)                     if (type == CIMTYPE_INSTANCE)
                         return CIMValue(cimInstance);                         return CIMValue(cimInstance);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     x = CIMObject(cimInstance);                     x = CIMObject(cimInstance);
                 }                 }
                 else if (XmlReader::getClassElement(tmp_parser, cimClass))                 else if (XmlReader::getClassElement(tmp_parser, cimClass))
Line 1126 
Line 1116 
                 }                 }
                 else                 else
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_OBJECT)                     if (type == CIMTYPE_OBJECT)
                     {                     {
                         // change "element" to "embedded object"                         // change "element" to "embedded object"
Line 1144 
Line 1133 
                             "Expected INSTANCE element");                             "Expected INSTANCE element");
                         throw XmlValidationError(lineNumber, mlParms);                         throw XmlValidationError(lineNumber, mlParms);
                     }                     }
 #else  
                     // change "element" to "embedded object"  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT",  
                         "Expected INSTANCE or CLASS element");  
                     throw XmlValidationError(lineNumber, mlParms);  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                 }                 }
                 // Ok, now we can delete the storage for the temporary                 // Ok, now we can delete the storage for the temporary
                 // XmlParser.                 // XmlParser.
Line 1227 
Line 1209 
     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 1244 
Line 1227 
     // 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 1279 
Line 1266 
     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 (testContentOrCData(parser, entry))
           {
               valueString = entry.text;
               valueStringLen = entry.textLen;
           }
   
           expectEndTag(parser, "VALUE");
       }
   
       str = String(valueString, valueStringLen);
       return true;
   }
   
   // EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // getUint32ValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getUint32ValueElement(
       XmlParser& parser,
       Uint32Arg& val,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
           {
               MessageLoaderParms mlParms(
                   "Common.XmlReader.EXPECTED_VALUE_ELEMENT",
                   "Expected VALUE element");
               throw XmlValidationError(parser.getLine(), mlParms);
           }
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
   
       if (!empty)
       {
           if (testContentOrCData(parser, entry))
               valueString = entry.text;
   
           expectEndTag(parser, "VALUE");
       }
       else
       {
           // create the arg object with the NULL value in it.
           val = Uint32Arg();
           return true;
       }
   
       //convert to Uint32. Note error if overflow.
   
       Uint64 x;
       if (!StringConversion::stringToUnsignedInteger(valueString, x))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.INVALID_UI_VALUE",
               "Invalid unsigned integer value");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
   
       if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT32))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.U32_VALUE_OUT_OF_RANGE",
               "Uint32 value out of range");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       // create the arg object with the value in it.
       val = Uint32Arg(x);
   
       return true;
   }
   //------------------------------------------------------------------------------
   //
   // getUint64ValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getUint64ValueElement(
       XmlParser& parser,
       Uint64Arg& val,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
           {
               MessageLoaderParms mlParms(
                   "Common.XmlReader.EXPECTED_VALUE_ELEMENT",
                   "Expected VALUE element");
               throw XmlValidationError(parser.getLine(), mlParms);
           }
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
  
     if (!empty)     if (!empty)
     {     {
Line 1287 
Line 1390 
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
       else
       {
           // create the arg object with the NULL value in it.
           val = Uint64Arg();
           return true;
       }
   
       Uint64 x;
       // EXP_PULL clean this up
       if (!StringConversion::stringToUnsignedInteger(valueString, x))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.INVALID_UI_VALUE",
               "Invalid unsigned integer value");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       //EXP_PULL_QUESTION- Is there even a check for 64 bit too large
   
       if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT64))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.U64_VALUE_OUT_OF_RANGE",
               "Uint64 value out of range");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       // create the arg object with the value in it.
       val = Uint64Arg(x);
  
     str = String(valueString);  
     return true;     return true;
 } }
   //EXP_PULL_END
  
 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
 // //
Line 1357 
Line 1487 
 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 1366 
Line 1496 
     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 1381 
Line 1514 
     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 1433 
Line 1581 
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMObject*)0);                 lineNumber, array, type, (CIMObject*)0);
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMInstance*)0);                 lineNumber, array, type, (CIMInstance*)0);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
   
         default:         default:
             break;             break;
     }     }
Line 1468 
Line 1613 
     // 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 1480 
Line 1625 
  
         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 1791 
Line 1941 
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
Line 1799 
Line 1948 
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // If the EmbeddedObject attribute is present with value "object"     // If the EmbeddedObject attribute is present with value "object"
     // 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  
     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
Line 1844 
Line 1991 
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else  
     if ((embeddedObject == EMBEDDED_OBJECT_ATTR)|| embeddedObjectQualifierValue)  
     {  
         // The EmbeddedObject attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, false);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, 0, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 i = 0; i < property.getQualifierCount(); ++i)  
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(i));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EmbeddedObject attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property value, if not empty.     // Continue on to get property value, if not empty.
     if (!empty)     if (!empty)
     {     {
Line 1914 
Line 2026 
  
     Uint64 arraySize;     Uint64 arraySize;
  
     if (!stringToUnsignedInteger(tmp, arraySize) || (arraySize == 0) ||      if (!StringConversion::stringToUnsignedInteger(tmp, arraySize) ||
           (arraySize == 0) ||
         !StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32))         !StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32))
     {     {
         char message[128];         char message[128];
Line 2012 
Line 2125 
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
Line 2020 
Line 2132 
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // If the EmbeddedObject attribute is present with value "object"     // If the EmbeddedObject attribute is present with value "object"
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then     // then
     //     Convert the EmbeddedObject-encoded string into a CIMObject     //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
Line 2066 
Line 2176 
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else  
     if ((embeddedObject == EMBEDDED_OBJECT_ATTR)||embeddedObjectQualifierValue)  
     {  
         // The EmbeddedObject attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, true, arraySize);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, arraySize, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 i = 0; i < property.getQualifierCount(); ++i)  
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(i));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EmbeddedObject attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property array value, if not empty.     // Continue on to get property array value, if not empty.
     // Else not an embedded object, if not empty, get the property array value.     // Else not an embedded object, if not empty, get the property array value.
     if (!empty)     if (!empty)
Line 3432 
Line 3507 
     return true;     return true;
 } }
  
   
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   // getInstanceWithPathElement()
   //
   //     <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getInstanceWithPathElement(
       XmlParser& parser,
       CIMInstance& namedInstance)
   {
       XmlEntry entry;
       if (!testStartTag(parser, entry, "VALUE.INSTANCEWITHPATH"))
           return false;
   
       CIMObjectPath instanceName;
   
       // Get INSTANCENAME elements:
   //EXP_PULL_ISSUE Should we have new getInstancePathElement???
       if (!getInstancePathElement(parser, instanceName))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.EXPECTED_INSTANCEPATH_ELEMENT",
               "expected INSTANCEPATH element");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   
       // Get INSTANCE elements:
   
       if (!getInstanceElement(parser, namedInstance))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.EXPECTED_INSTANCE_ELEMENT",
               "expected INSTANCE element");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
       // Get VALUE.NAMEDINSTANCE end tag:
   
       expectEndTag(parser, "VALUE.INSTANCEWITHPATH");
   
       namedInstance.setPath (instanceName);
   
       return true;
   }
   
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getObject() // getObject()
Line 3616 
Line 3740 
     return true;     return true;
 } }
  
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // getIParamValueTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParamValueTag(
       XmlParser& parser,
       const char*& name,
       Boolean& isEmptyTag)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE"))
       {
   
           return false;
       }
   
       isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG);
   
       // Get PARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.MISSING_PARAMVALUE_ATTRIBUTE",
               "Missing PARAMVALUE.NAME attribute");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
       return true;
   }
   //------------------------------------------------------------------------------
   //
   // getIReturnValueTag()
   //
   //------------------------------------------------------------------------------
   ////EXP_PULL Think we can get rid of this TBD
   Boolean XmlReader::getIReturnValueTag(
       XmlParser& parser,
       const char*& name,
       Boolean& isEmptyTag)
   {
       XmlEntry entry;
       if (!testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE"))
           return false;
       //entry.print();
       isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG);
   
       if (!entry.getAttributeValue("NAME", name))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.MISSING_IRETURNVALUE_ATTRIBUTE",
               "Missing IRETURNVALUE.NAME attribute");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   // EXP_PULL_TBD Add new msg above to msg bundle.
       return true;
   }
   
   //EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // rejectNullIParamValue() // rejectNullIParamValue()
Line 3636 
Line 3822 
     }     }
 } }
  
   // EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // rejectNullIReturnParamValue()
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::rejectNullIReturnValue(
       XmlParser& parser,
       Boolean isEmptyTag,
       const char* paramName)
   {
       if (isEmptyTag)
       {
           MessageLoaderParms mlParms("Common.XmlReader.INVALID_NULL_IRETURNVALUE",
               "A null value is not valid for IRETURNVALUE \"$0\".",
               paramName);
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   }
   
   void XmlReader::rejectNullParamValue(
       XmlParser& parser,
       Boolean isEmptyTag,
       const char* paramName)
   {
       if (isEmptyTag)
       {
           MessageLoaderParms mlParms("Common.XmlReader.INVALID_NULL_PARAMVALUE",
               "A null value is not valid for PARAMVALUE \"$0\".",
               paramName);
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   }
   // EXP_PULL_TODO_TBD add above message to bundle
   // EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getBooleanValueElement() // getBooleanValueElement()
Line 4255 
Line 4477 
             // If the EmbeddedObject attribute is present with value "object"             // If the EmbeddedObject attribute is present with value "object"
             // then             // then
             //     Convert the EmbeddedObject-encoded string into a CIMObject             //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             if (embeddedObject != NO_EMBEDDED_OBJECT)             if (embeddedObject != NO_EMBEDDED_OBJECT)
             {             {
                 // The EmbeddedObject attribute is only valid on Parameters                 // The EmbeddedObject attribute is only valid on Parameters
Line 4279 
Line 4500 
                     throw XmlValidationError(parser.getLine(), mlParms);                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
             }             }
 #else  
             if (embeddedObject == EMBEDDED_OBJECT_ATTR)  
             {  
                 // The EmbeddedObject attribute is only valid on Parameters  
                 // of type string  
                 // The type must have been specified.  
                 if (gotType && (type == CIMTYPE_STRING))  
                 {  
                     // Used below by getValueElement() or getValueArrayElement()  
                     effectiveType = CIMTYPE_OBJECT;  
                 }  
                 else  
                 {  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                         "The EmbeddedObject attribute is only valid on "  
                             "string types.");  
                     throw XmlValidationError(parser.getLine(), mlParms);  
                 }  
             }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
  
             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)
                 && !XmlReader::getValueElement(parser, effectiveType, value))                 && !XmlReader::getValueElement(parser, effectiveType, value))
Line 4377 
Line 4577 
             // If we don't know what type the value is, read it as a String             // If we don't know what type the value is, read it as a String
             type = CIMTYPE_STRING;             type = CIMTYPE_STRING;
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         if (embeddedObject != NO_EMBEDDED_OBJECT)         if (embeddedObject != NO_EMBEDDED_OBJECT)
         {         {
             if (gotType && (type == CIMTYPE_STRING))             if (gotType && (type == CIMTYPE_STRING))
Line 4397 
Line 4596 
                 throw XmlValidationError(parser.getLine(), mlParms);                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
         }         }
 #else  
         if (embeddedObject == EMBEDDED_OBJECT_ATTR)  
         {  
             if (gotType && (type == CIMTYPE_STRING))  
             {  
                 type = CIMTYPE_OBJECT;  // Used below by getValueElement()  
             }  
             else  
             {  
                 MessageLoaderParms mlParms(  
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                     "The EmbeddedObject attribute is only valid on string "  
                         "types.");  
                 throw XmlValidationError(parser.getLine(), mlParms);  
             }  
         }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         if ( !XmlReader::getValueElement(parser, type, returnValue) )         if ( !XmlReader::getValueElement(parser, type, returnValue) )
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(


Legend:
Removed from v.1.131  
changed lines
  Added in v.1.144.4.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2