(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.66 and 1.70

version 1.66, 2002/08/20 17:39:37 version 1.70, 2002/08/25 06:43:56
Line 46 
Line 46 
 #include "CIMObject.h" #include "CIMObject.h"
 #include "CIMParamValue.h" #include "CIMParamValue.h"
  
   //#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(9223372036854775808))
   //#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(18446744073709551615)
   #define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL((Sint64) 0x8000000000000000))
   #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL((Uint64) 0xFFFFFFFFFFFFFFFF)
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 480 
Line 485 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 CIMType XmlReader::getCimTypeAttribute(  Boolean XmlReader::getCimTypeAttribute(
     Uint32 lineNumber,     Uint32 lineNumber,
     const XmlEntry& entry,     const XmlEntry& entry,
       CIMType& cimType,  // Output parameter
     const char* tagName,     const char* tagName,
     const char* attributeName,     const char* attributeName,
     Boolean required)     Boolean required)
Line 499 
Line 505 
         }         }
         else         else
         {         {
             return CIMTYPE_NONE;              return false;
         }         }
     }     }
  
     CIMType type = CIMTYPE_NONE;      CIMType type = CIMTYPE_BOOLEAN;
       Boolean unrecognizedType = false;
  
     if (strcmp(typeName, "boolean") == 0)     if (strcmp(typeName, "boolean") == 0)
         type = CIMTYPE_BOOLEAN;         type = CIMTYPE_BOOLEAN;
Line 535 
Line 542 
         type = CIMTYPE_REAL64;         type = CIMTYPE_REAL64;
     else if (strcmp(typeName, "reference") == 0)     else if (strcmp(typeName, "reference") == 0)
         type = CIMTYPE_REFERENCE;         type = CIMTYPE_REFERENCE;
       else unrecognizedType = true;
  
     if ((type == CIMTYPE_NONE) ||      if (unrecognizedType ||
         ((type == CIMTYPE_REFERENCE) &&         ((type == CIMTYPE_REFERENCE) &&
          (strcmp(attributeName, "PARAMTYPE") != 0)))          (strcmp(attributeName, "PARAMTYPE") != 0)))
     {     {
Line 546 
Line 554 
         throw XmlSemanticError(lineNumber, message);         throw XmlSemanticError(lineNumber, message);
     }     }
  
     return type;      cimType = type;
       return true;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 733 
Line 742 
             while (isxdigit(*p))             while (isxdigit(*p))
             {             {
                 // Make sure we won't overflow when we multiply by 16                 // Make sure we won't overflow when we multiply by 16
                 if (x < PEGASUS_LLONG_MIN/16)                  if (x < PEGASUS_SINT64_MIN/16)
                 {                 {
                     return false;                     return false;
                 }                 }
Line 741 
Line 750 
  
                 // Make sure we don't overflow when we add the next digit                 // Make sure we don't overflow when we add the next digit
                 Sint64 newDigit = Sint64(_hexCharToNumeric(*p++));                 Sint64 newDigit = Sint64(_hexCharToNumeric(*p++));
                 if (PEGASUS_LLONG_MIN - x > -newDigit)                  if (PEGASUS_SINT64_MIN - x > -newDigit)
                 {                 {
                     return false;                     return false;
                 }                 }
Line 756 
Line 765 
             // overflow error             // overflow error
             if (!negative)             if (!negative)
             {             {
                 if (x == PEGASUS_LLONG_MIN)                  if (x == PEGASUS_SINT64_MIN)
                 {                 {
                     return false;                     return false;
                 }                 }
Line 784 
Line 793 
     while (isdigit(*p))     while (isdigit(*p))
     {     {
         // Make sure we won't overflow when we multiply by 10         // Make sure we won't overflow when we multiply by 10
         if (x < PEGASUS_LLONG_MIN/10)          if (x < PEGASUS_SINT64_MIN/10)
         {         {
             return false;             return false;
         }         }
Line 792 
Line 801 
  
         // Make sure we won't overflow when we add the next digit         // Make sure we won't overflow when we add the next digit
         Sint64 newDigit = (*p++ - '0');         Sint64 newDigit = (*p++ - '0');
         if (PEGASUS_LLONG_MIN - x > -newDigit)          if (PEGASUS_SINT64_MIN - x > -newDigit)
         {         {
             return false;             return false;
         }         }
Line 807 
Line 816 
     // overflow error     // overflow error
     if (!negative)     if (!negative)
     {     {
         if (x == PEGASUS_LLONG_MIN)          if (x == PEGASUS_SINT64_MIN)
         {         {
             return false;             return false;
         }         }
Line 853 
Line 862 
             while (isxdigit(*p))             while (isxdigit(*p))
             {             {
                 // Make sure we won't overflow when we multiply by 16                 // Make sure we won't overflow when we multiply by 16
                 if (x > PEGASUS_ULLONG_MAX/16)                  if (x > PEGASUS_UINT64_MAX/16)
                 {                 {
                     return false;                     return false;
                 }                 }
Line 861 
Line 870 
  
                 // We can't overflow when we add the next digit                 // We can't overflow when we add the next digit
                 Uint64 newDigit = Uint64(_hexCharToNumeric(*p++));                 Uint64 newDigit = Uint64(_hexCharToNumeric(*p++));
                 if (PEGASUS_ULLONG_MAX - x < newDigit)                  if (PEGASUS_UINT64_MAX - x < newDigit)
                 {                 {
                     return false;                     return false;
                 }                 }
Line 887 
Line 896 
     while (isdigit(*p))     while (isdigit(*p))
     {     {
         // Make sure we won't overflow when we multiply by 10         // Make sure we won't overflow when we multiply by 10
         if (x > PEGASUS_ULLONG_MAX/10)          if (x > PEGASUS_UINT64_MAX/10)
         {         {
             return false;             return false;
         }         }
Line 895 
Line 904 
  
         // Make sure we won't overflow when we add the next digit         // Make sure we won't overflow when we add the next digit
         Uint64 newDigit = (*p++ - '0');         Uint64 newDigit = (*p++ - '0');
         if (PEGASUS_ULLONG_MAX - x < newDigit)          if (PEGASUS_UINT64_MAX - x < newDigit)
         {         {
             return false;             return false;
         }         }
Line 1519 
Line 1528 
  
     // Get QUALIFIER.TYPE attribute:     // Get QUALIFIER.TYPE attribute:
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "QUALIFIER");
  
     // Get QUALIFIER.PROPAGATED     // Get QUALIFIER.PROPAGATED
  
Line 1612 
Line 1622 
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY");
  
     // Create property: Sets type and !isarray     // Create property: Sets type and !isarray
  
Line 1705 
Line 1716 
  
     // Get PROPERTY.TYPE attribute:     // Get PROPERTY.TYPE attribute:
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY.ARRAY");
  
     // Get PROPERTY.ARRAYSIZE attribute:     // Get PROPERTY.ARRAYSIZE attribute:
  
Line 2509 
Line 2521 
  
     // Get PARAMETER.TYPE attribute:     // Get PARAMETER.TYPE attribute:
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "PARAMETER");
  
     // Create parameter:     // Create parameter:
  
Line 2555 
Line 2568 
  
     // Get PARAMETER.ARRAY.TYPE attribute:     // Get PARAMETER.ARRAY.TYPE attribute:
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "PARAMETER.ARRAY");
  
     // Get PARAMETER.ARRAYSIZE attribute:     // Get PARAMETER.ARRAYSIZE attribute:
  
Line 2733 
Line 2747 
  
     // Get TYPE attribute:     // Get TYPE attribute:
  
     CIMType type = getCimTypeAttribute(      CIMType type;
         parser.getLine(), entry, "QUALIFIER.DECLARATION");      getCimTypeAttribute(parser.getLine(), entry, type, "QUALIFIER.DECLARATION");
  
     // Get ISARRAY attribute:     // Get ISARRAY attribute:
  
Line 2757 
Line 2771 
  
     CIMScope scope = CIMScope ();     CIMScope scope = CIMScope ();
     CIMValue value;     CIMValue value;
       Boolean gotValue = false;
  
     if (!empty)     if (!empty)
     {     {
Line 2781 
Line 2796 
                     "VALUE.ARRAY size is not the same as "                     "VALUE.ARRAY size is not the same as "
                     "ARRAYSIZE attribute");                     "ARRAYSIZE attribute");
             }             }
   
               gotValue = true;
         }         }
         else if (getValueElement(parser, type, value))         else if (getValueElement(parser, type, value))
         {         {
Line 2789 
Line 2806 
                 throw XmlSemanticError(parser.getLine(),                 throw XmlSemanticError(parser.getLine(),
                     "ISARRAY attribute used but VALUE element encountered");                     "ISARRAY attribute used but VALUE element encountered");
             }             }
   
               gotValue = true;
         }         }
  
         // Now get the closing tag:         // Now get the closing tag:
Line 2796 
Line 2815 
         expectEndTag(parser, "QUALIFIER.DECLARATION");         expectEndTag(parser, "QUALIFIER.DECLARATION");
     }     }
  
     if (value.getType() == CIMTYPE_NONE)      if (!gotValue)
     {     {
         if (isArray)         if (isArray)
             value.setNullValue(type, true, arraySize);             value.setNullValue(type, true, arraySize);
Line 2833 
Line 2852 
  
     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");     String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY");
  
     CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY");      CIMType type;
       getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY");
  
     CIMName classOrigin =     CIMName classOrigin =
         getClassOriginAttribute(parser.getLine(), entry, "PROPERTY");         getClassOriginAttribute(parser.getLine(), entry, "PROPERTY");
Line 3601 
Line 3621 
  
     // Get PARAMVALUE.PARAMTYPE attribute:     // Get PARAMVALUE.PARAMTYPE attribute:
  
     type = getCimTypeAttribute(parser.getLine(), entry, "PARAMVALUE",      Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type,
                                "PARAMTYPE", false);                                            "PARAMVALUE", "PARAMTYPE", false);
  
     if (!empty)     if (!empty)
     {     {
         // Parse VALUE.REFERENCE and VALUE.REFARRAY type         // Parse VALUE.REFERENCE and VALUE.REFARRAY type
         if ( (type == CIMTYPE_REFERENCE) || (type == CIMTYPE_NONE) )          if ( (type == CIMTYPE_REFERENCE) || !gotType )
         {         {
             CIMObjectPath reference;             CIMObjectPath reference;
             if (XmlReader::getValueReferenceElement(parser, reference))             if (XmlReader::getValueReferenceElement(parser, reference))
             {             {
                 value.set(reference);                 value.set(reference);
                 type = CIMTYPE_REFERENCE;                 type = CIMTYPE_REFERENCE;
                   gotType = true;
             }             }
             else if (XmlReader::getValueReferenceArrayElement(parser, value))             else if (XmlReader::getValueReferenceArrayElement(parser, value))
             {             {
                 type = CIMTYPE_REFERENCE;                 type = CIMTYPE_REFERENCE;
                   gotType = true;
             }             }
             // If type==reference but no VALUE.REFERENCE found, use null value             // If type==reference but no VALUE.REFERENCE found, use null value
         }         }
Line 3625 
Line 3647 
         // Parse non-reference value         // Parse non-reference value
         if ( type != CIMTYPE_REFERENCE )         if ( type != CIMTYPE_REFERENCE )
         {         {
             // If we don't know what type the value is, read it as a String              CIMType effectiveType;
             CIMType effectiveType = type;              if (!gotType)
             if ( effectiveType == CIMTYPE_NONE)  
             {             {
                   // If we don't know what type the value is, read it as a String
                 effectiveType = CIMTYPE_STRING;                 effectiveType = CIMTYPE_STRING;
             }             }
               else
               {
                   effectiveType = type;
               }
  
             if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) &&             if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) &&
                  !XmlReader::getValueElement(parser, effectiveType, value) )                  !XmlReader::getValueElement(parser, effectiveType, value) )
Line 3642 
Line 3668 
         expectEndTag(parser, "PARAMVALUE");         expectEndTag(parser, "PARAMVALUE");
     }     }
  
     paramValue = CIMParamValue(name, value, Boolean(type!=CIMTYPE_NONE));      paramValue = CIMParamValue(name, value, gotType);
  
     return true;     return true;
 } }
Line 3671 
Line 3697 
     // Get RETURNVALUE.PARAMTYPE attribute:     // Get RETURNVALUE.PARAMTYPE attribute:
     // NOTE: Array type return values are not allowed (2/20/02)     // NOTE: Array type return values are not allowed (2/20/02)
  
     type = getCimTypeAttribute(parser.getLine(), entry, "RETURNVALUE",      Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type,
                                "PARAMTYPE", false);                                            "RETURNVALUE", "PARAMTYPE", false);
  
     // Parse VALUE.REFERENCE type     // Parse VALUE.REFERENCE type
     if ( (type == CIMTYPE_REFERENCE) || (type == CIMTYPE_NONE) )      if ( (type == CIMTYPE_REFERENCE) || !gotType )
     {     {
         CIMObjectPath reference;         CIMObjectPath reference;
         if (XmlReader::getValueReferenceElement(parser, reference))         if (XmlReader::getValueReferenceElement(parser, reference))
         {         {
             returnValue.set(reference);             returnValue.set(reference);
             type = CIMTYPE_REFERENCE;             type = CIMTYPE_REFERENCE;
               gotType = true;
         }         }
         else if (type == CIMTYPE_REFERENCE)         else if (type == CIMTYPE_REFERENCE)
         {         {
Line 3693 
Line 3720 
     // Parse non-reference return value     // Parse non-reference return value
     if ( type != CIMTYPE_REFERENCE )     if ( type != CIMTYPE_REFERENCE )
     {     {
         // If we don't know what type the value is, read it as a String          if (!gotType)
         if ( type == CIMTYPE_NONE)  
         {         {
               // If we don't know what type the value is, read it as a String
             type = CIMTYPE_STRING;             type = CIMTYPE_STRING;
         }         }
  


Legend:
Removed from v.1.66  
changed lines
  Added in v.1.70

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2