(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.24 and 1.24.2.8

version 1.24, 2001/07/17 00:49:04 version 1.24.2.8, 2001/11/21 07:18:54
Line 1 
Line 1 
   //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 21 
Line 23 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //                  (carolann_graves@hp.com)
   //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 37 
Line 42 
 #include "CIMClass.h" #include "CIMClass.h"
 #include "CIMInstance.h" #include "CIMInstance.h"
 #include "CIMObject.h" #include "CIMObject.h"
   #include "CIMNamedInstance.h"
   #include "CIMParamValue.h"
  
   PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static const Uint32 MESSAGE_SIZE = 128; static const Uint32 MESSAGE_SIZE = 128;
Line 63 
Line 71 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
   //  testXmlDeclaration ()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::testXmlDeclaration (
       XmlParser& parser,
       XmlEntry& entry)
   {
       if (!parser.next (entry) ||
           entry.type != XmlEntry::XML_DECLARATION ||
           strcmp (entry.text, "xml") != 0)
       {
           parser.putBack (entry);
           return false;
       }
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
 // expectStartTag() // expectStartTag()
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 273 
Line 302 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getIsArrayAttribute()  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::getIsArrayAttribute(  
     Uint32 lineNumber,  
     const XmlEntry& entry,  
     const char* tagName,  
     Boolean& value)  
 {  
     const char* tmp;  
   
     if (!entry.getAttributeValue("ISARRAY", tmp))  
         return false;  
   
     if (strcmp(tmp, "true") == 0)  
     {  
         value = true;  
         return true;  
     }  
     else if (strcmp(tmp, "false") == 0)  
     {  
         value = false;  
         return true;  
     }  
   
     char buffer[62];  
     sprintf(buffer, "Bad %s.%s attribute value", "ISARRAY", tagName);  
     throw XmlSemanticError(lineNumber, buffer);  
     return false;  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // getCimNameAttribute() // getCimNameAttribute()
 // //
 //     <!ENTITY % CIMName "NAME CDATA #REQUIRED"> //     <!ENTITY % CIMName "NAME CDATA #REQUIRED">
Line 514 
Line 509 
         type = CIMType::REAL32;         type = CIMType::REAL32;
     else if (strcmp(typeName, "real64") == 0)     else if (strcmp(typeName, "real64") == 0)
         type = CIMType::REAL64;         type = CIMType::REAL64;
     else if (strcmp(typeName, "reference") == 0)  
         type = CIMType::REFERENCE;  
   
     // ATTN: "reference" is not legal according to the DTD; however, it is  
     // used by the XML version of the CIM schema.  
  
     if (type == CIMType::NONE)     if (type == CIMType::NONE)
     {     {
Line 1002 
Line 992 
     XmlParser& parser,     XmlParser& parser,
     CIMValue& cimValue)     CIMValue& cimValue)
 { {
     //Test for Element value type      //ATTN: Test for Element value type
     CIMType type = CIMType::STRING;     CIMType type = CIMType::STRING;
  
     if (XmlReader::getValueElement(parser, type, cimValue))     if (XmlReader::getValueElement(parser, type, cimValue))
Line 1017 
Line 1007 
        return true;        return true;
  
     // Test for Value.reference type     // Test for Value.reference type
     // ATTN:This returns a different type (CIMReference)  
     // ATTN: Possibly change to simply return result after  
     // we figure out the type differences.  
   
    CIMReference reference;    CIMReference reference;
    if(XmlReader::getValueReferenceElement(parser, reference))    if(XmlReader::getValueReferenceElement(parser, reference))
       {
           cimValue.set(reference);
       return true;       return true;
       }
  
    return false;    return false;
 } }
Line 1766 
Line 1755 
 //     <!ATTLIST KEYVALUE //     <!ATTLIST KEYVALUE
 //         VALUETYPE (string|boolean|numeric)  'string'> //         VALUETYPE (string|boolean|numeric)  'string'>
 // //
 // ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed!  
 //  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getKeyValueElement( Boolean XmlReader::getKeyValueElement(
Line 1810 
Line 1797 
 //     <!ATTLIST KEYBINDING //     <!ATTLIST KEYBINDING
 //         %CIMName;> //         %CIMName;>
 // //
 // ATTN-B: VALUE.REFERENCE ignored above; can't understand why it is needed!  
 //  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 Boolean XmlReader::getKeyBindingElement( Boolean XmlReader::getKeyBindingElement(
Line 1828 
Line 1813 
     name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING");     name = getCimNameAttribute(parser.getLine(), entry, "KEYBINDING");
  
     if (!getKeyValueElement(parser, type, value))     if (!getKeyValueElement(parser, type, value))
         throw XmlValidationError(parser.getLine(), "Expected KEYVALUE element");      {
           CIMReference reference;
   
           if (!getValueReferenceElement(parser, reference))
           {
               throw XmlValidationError(parser.getLine(),
                         "Expected KEYVALUE or VALUE.REFERENCE element");
           }
   
           type = KeyBinding::REFERENCE;
           value = reference.toString();
       }
  
     expectEndTag(parser, "KEYBINDING");     expectEndTag(parser, "KEYBINDING");
     return true;     return true;
Line 1842 
Line 1838 
 //     <!ATTLIST INSTANCENAME //     <!ATTLIST INSTANCENAME
 //         %ClassName;> //         %ClassName;>
 // //
 // ATTN-B: VALUE.REFERENCE sub-element not accepted yet.  // Note: An empty key name is used in the keyBinding when the INSTANCENAME is
   // specified using a KEYVALUE or a VALUE.REFERENCE.
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 1863 
Line 1860 
  
     className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME");     className = getClassNameAttribute(parser.getLine(), entry, "INSTANCENAME");
  
     if (!empty)      if (empty)
     {     {
           return true;
       }
   
         String name;         String name;
         KeyBinding::Type type;         KeyBinding::Type type;
         String value;         String value;
       CIMReference reference;
  
       if (getKeyValueElement(parser, type, value))
       {
           // Use empty key name because none was specified
           keyBindings.append(KeyBinding(name, value, type));
       }
       else if (getValueReferenceElement(parser, reference))
       {
           // Use empty key name because none was specified
           type = KeyBinding::REFERENCE;
           value = reference.toString();
           keyBindings.append(KeyBinding(name, value, type));
       }
       else
       {
         while (getKeyBindingElement(parser, name, value, type))         while (getKeyBindingElement(parser, name, value, type))
             keyBindings.append(KeyBinding(name, value, type));             keyBindings.append(KeyBinding(name, value, type));
       }
  
         if (!empty)  
             expectEndTag(parser, "INSTANCENAME");             expectEndTag(parser, "INSTANCENAME");
     }  
  
     return true;     return true;
 } }
Line 2420 
Line 2434 
  
     // Get ISARRAY attribute:     // Get ISARRAY attribute:
  
     Boolean isArray = false;      Boolean isArray = getCimBooleanAttribute(
     getIsArrayAttribute(          parser.getLine(), entry, "QUALIFIER.DECLARATION", "ISARRAY",
         parser.getLine(), entry, "QUALIFIER.DECLARATION", isArray);          false, false);
  
     // Get ARRAYSIZE attribute:     // Get ARRAYSIZE attribute:
  
Line 2620 
Line 2634 
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
   // getNamedInstanceElement()
   //
   //     <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getNamedInstanceElement(
       XmlParser& parser,
       CIMNamedInstance& namedInstance)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "VALUE.NAMEDINSTANCE"))
           return false;
   
       CIMReference instanceName;
   
       // Get INSTANCENAME elements:
   
       if (!getInstanceNameElement(parser, instanceName))
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCENAME element");
       }
   
       CIMInstance instance;
   
       // Get INSTANCE elements:
   
       if (!getInstanceElement(parser, instance))
       {
           throw XmlValidationError(parser.getLine(),
               "expected INSTANCE element");
       }
   
       // Get VALUE.NAMEDINSTANCE end tag:
   
       expectEndTag(parser, "VALUE.NAMEDINSTANCE");
   
       namedInstance.set(instanceName, instance);
   
       return true;
   }
   
   //------------------------------------------------------------------------------
 // //
 // getObject() // getObject()
 // //
Line 2794 
Line 2853 
  
     expectContentOrCData(parser, entry);     expectContentOrCData(parser, entry);
  
     if (strcmp(entry.text, "TRUE") == 0)      if (CompareNoCase(entry.text, "TRUE") == 0)
         result = true;         result = true;
     else if (strcmp(entry.text, "FALSE") == 0)      else if (CompareNoCase(entry.text, "FALSE") == 0)
         result = false;         result = false;
     else     else
         throw XmlSemanticError(parser.getLine(),         throw XmlSemanticError(parser.getLine(),
Line 2923 
Line 2982 
     CIMReference& objectName)     CIMReference& objectName)
 { {
     String className;     String className;
     CIMReference instanceName;  
  
     if (getClassNameElement(parser, className, false))     if (getClassNameElement(parser, className, false))
     {     {
Line 2975 
Line 3033 
     PEGASUS_UNREACHABLE ( return false; )     PEGASUS_UNREACHABLE ( return false; )
 } }
  
   //------------------------------------------------------------------------------
   //
   // getEMethodCallStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getEMethodCallStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "EXPMETHODCALL"))
           return false;
   
       // Get EXPMETHODCALL.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing EXPMETHODCALL.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getEMethodResponseStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getEMethodResponseStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "EXPMETHODRESPONSE"))
           return false;
   
       // Get EXPMETHODRESPONSE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing EXPMETHODRESPONSE.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getMethodCallStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getMethodCallStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "METHODCALL"))
           return false;
   
       // Get METHODCALL.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing METHODCALL.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getMethodResponseStartTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getMethodResponseStartTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "METHODRESPONSE"))
           return false;
   
       // Get METHODRESPONSE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing METHODRESPONSE.NAME attribute");
   
       return true;
   }
   
   //------------------------------------------------------------------------------
   //
   // getParamValueTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParamValueTag(
       XmlParser& parser,
       const char*& name)
   {
       XmlEntry entry;
   
       if (!testStartTag(parser, entry, "PARAMVALUE"))
           return false;
   
       // Get IPARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
           throw XmlValidationError(parser.getLine(),
               "Missing PARAMVALUE.NAME attribute");
   
       return true;
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.24  
changed lines
  Added in v.1.24.2.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2