version 1.1.1.1, 2001/01/14 19:53:32
|
version 1.24.2.4, 2001/10/31 04:37:50
|
|
|
//BEGIN_LICENSE |
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 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 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
// | // |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// 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. |
// | // |
//END_LICENSE |
//============================================================================== |
//BEGIN_HISTORY |
|
// | // |
// Author: |
// Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// $Log$ |
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
// Revision 1.1.1.1 2001/01/14 19:53:32 mike |
// (carolann_graves@hp.com) |
// Pegasus import |
|
// | // |
|
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
// | // |
//END_HISTORY |
//%///////////////////////////////////////////////////////////////////////////// |
| |
#include <cassert> | #include <cassert> |
#include <cctype> | #include <cctype> |
#include <cstdio> | #include <cstdio> |
#include <cstdlib> | #include <cstdlib> |
#include "Name.h" |
#include "CIMName.h" |
#include "XmlReader.h" | #include "XmlReader.h" |
#include "XmlWriter.h" | #include "XmlWriter.h" |
#include "Qualifier.h" |
#include "CIMQualifier.h" |
#include "QualifierDecl.h" |
#include "CIMQualifierDecl.h" |
#include "ClassDecl.h" |
#include "CIMClass.h" |
#include "InstanceDecl.h" |
#include "CIMInstance.h" |
|
#include "CIMObject.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; |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// 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() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
strcmp(entry.text, tagName) != 0) | strcmp(entry.text, tagName) != 0) |
{ | { |
char message[MESSAGE_SIZE]; | char message[MESSAGE_SIZE]; |
sprintf(message, "Expected close of %s element", tagName); |
sprintf(message, "Expected close of %s element, got %s instead", |
|
tagName,entry.text); |
throw XmlValidationError(parser.getLine(), message); | throw XmlValidationError(parser.getLine(), message); |
} | } |
} | } |
|
|
throw XmlValidationError(lineNumber, buffer); | throw XmlValidationError(lineNumber, buffer); |
} | } |
| |
if (acceptNull && name.getLength() == 0) |
if (acceptNull && name.size() == 0) |
return name; | return name; |
| |
if (!Name::legal(name)) |
if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "Illegal value for %s.NAME attribute", elementName); | sprintf(buffer, "Illegal value for %s.NAME attribute", elementName); |
|
|
throw XmlValidationError(lineNumber, buffer); | throw XmlValidationError(lineNumber, buffer); |
} | } |
| |
if (!Name::legal(name)) |
if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, | sprintf(buffer, |
|
|
if (!entry.getAttributeValue("CLASSORIGIN", name)) | if (!entry.getAttributeValue("CLASSORIGIN", name)) |
return String(); | return String(); |
| |
if (!Name::legal(name)) |
if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, | sprintf(buffer, |
|
|
if (!entry.getAttributeValue("REFERENCECLASS", name)) | if (!entry.getAttributeValue("REFERENCECLASS", name)) |
return String(); | return String(); |
| |
if (!Name::legal(name)) |
if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, | sprintf(buffer, |
|
|
if (!entry.getAttributeValue("SUPERCLASS", superClass)) | if (!entry.getAttributeValue("SUPERCLASS", superClass)) |
return String(); | return String(); |
| |
if (!Name::legal(superClass)) |
if (!CIMName::legal(superClass)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf( | sprintf( |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Type XmlReader::getCimTypeAttribute( |
CIMType XmlReader::getCimTypeAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* tagName) | const char* tagName) |
|
|
throw XmlValidationError(lineNumber, message); | throw XmlValidationError(lineNumber, message); |
} | } |
| |
Type type = Type::NONE; |
CIMType type = CIMType::NONE; |
| |
if (strcmp(typeName, "boolean") == 0) | if (strcmp(typeName, "boolean") == 0) |
type = Type::BOOLEAN; |
type = CIMType::BOOLEAN; |
else if (strcmp(typeName, "string") == 0) | else if (strcmp(typeName, "string") == 0) |
type = Type::STRING; |
type = CIMType::STRING; |
else if (strcmp(typeName, "char16") == 0) | else if (strcmp(typeName, "char16") == 0) |
type = Type::CHAR16; |
type = CIMType::CHAR16; |
else if (strcmp(typeName, "uint8") == 0) | else if (strcmp(typeName, "uint8") == 0) |
type = Type::UINT8; |
type = CIMType::UINT8; |
else if (strcmp(typeName, "sint8") == 0) | else if (strcmp(typeName, "sint8") == 0) |
type = Type::SINT8; |
type = CIMType::SINT8; |
else if (strcmp(typeName, "uint16") == 0) | else if (strcmp(typeName, "uint16") == 0) |
type = Type::UINT16; |
type = CIMType::UINT16; |
else if (strcmp(typeName, "sint16") == 0) | else if (strcmp(typeName, "sint16") == 0) |
type = Type::SINT16; |
type = CIMType::SINT16; |
else if (strcmp(typeName, "uint32") == 0) | else if (strcmp(typeName, "uint32") == 0) |
type = Type::UINT32; |
type = CIMType::UINT32; |
else if (strcmp(typeName, "sint32") == 0) | else if (strcmp(typeName, "sint32") == 0) |
type = Type::SINT32; |
type = CIMType::SINT32; |
else if (strcmp(typeName, "uint64") == 0) | else if (strcmp(typeName, "uint64") == 0) |
type = Type::UINT64; |
type = CIMType::UINT64; |
else if (strcmp(typeName, "sint64") == 0) | else if (strcmp(typeName, "sint64") == 0) |
type = Type::SINT64; |
type = CIMType::SINT64; |
else if (strcmp(typeName, "datetime") == 0) | else if (strcmp(typeName, "datetime") == 0) |
type = Type::DATETIME; |
type = CIMType::DATETIME; |
else if (strcmp(typeName, "real32") == 0) | else if (strcmp(typeName, "real32") == 0) |
type = Type::REAL32; |
type = CIMType::REAL32; |
else if (strcmp(typeName, "real64") == 0) | else if (strcmp(typeName, "real64") == 0) |
type = Type::REAL64; |
type = CIMType::REAL64; |
else if (strcmp(typeName, "reference") == 0) | else if (strcmp(typeName, "reference") == 0) |
type = Type::REFERENCE; |
type = CIMType::REFERENCE; |
| |
// ATTN: "reference" is not legal according to the DTD; however, it is | // ATTN: "reference" is not legal according to the DTD; however, it is |
// used by the XML version of the CIM schema. | // used by the XML version of the CIM schema. |
| |
if (type == Type::NONE) |
if (type == CIMType::NONE) |
{ | { |
char message[MESSAGE_SIZE]; | char message[MESSAGE_SIZE]; |
sprintf(message, "Illegal value for %s.TYPE attribute", tagName); | sprintf(message, "Illegal value for %s.TYPE attribute", tagName); |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Value XmlReader::stringToValue( |
CIMValue XmlReader::stringToValue( |
Uint32 lineNumber, | Uint32 lineNumber, |
const char* valueString, | const char* valueString, |
Type type) |
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): |
| |
|
if (strlen(valueString)==0) |
|
{ |
|
switch (type) |
|
{ |
|
case CIMType::BOOLEAN: return CIMValue(false); |
|
case CIMType::STRING: return CIMValue(valueString); |
|
case CIMType::CHAR16: return CIMValue(Char16('\0')); |
|
case CIMType::UINT8: return CIMValue(Uint8(0)); |
|
case CIMType::UINT16: return CIMValue(Uint16(0)); |
|
case CIMType::UINT32: return CIMValue(Uint32(0)); |
|
case CIMType::UINT64: return CIMValue(Uint64(0)); |
|
case CIMType::SINT8: return CIMValue(Sint8(0)); |
|
case CIMType::SINT16: return CIMValue(Sint16(0)); |
|
case CIMType::SINT32: return CIMValue(Sint32(0)); |
|
case CIMType::SINT64: return CIMValue(Sint64(0)); |
|
case CIMType::REAL32: return CIMValue(Real32(0)); |
|
case CIMType::REAL64: return CIMValue(Real64(0)); |
|
} |
|
} |
|
|
switch (type) | switch (type) |
{ | { |
case Type::BOOLEAN: |
case CIMType::BOOLEAN: |
{ | { |
if (strcmp(valueString, "TRUE") == 0) |
if (CompareNoCase(valueString, "TRUE") == 0) |
return Value(true); |
return CIMValue(true); |
else if (strcmp(valueString, "FALSE") == 0) |
else if (CompareNoCase(valueString, "FALSE") == 0) |
return Value(false); |
return CIMValue(false); |
else | else |
throw XmlSemanticError( | throw XmlSemanticError( |
lineNumber, "Bad boolean value"); | lineNumber, "Bad boolean value"); |
} | } |
| |
case Type::STRING: |
case CIMType::STRING: |
{ | { |
return Value(valueString); |
return CIMValue(valueString); |
} | } |
| |
case Type::CHAR16: |
case CIMType::CHAR16: |
{ | { |
if (strlen(valueString) != 1) | if (strlen(valueString) != 1) |
throw XmlSemanticError(lineNumber, "Bad char16 value"); | throw XmlSemanticError(lineNumber, "Bad char16 value"); |
| |
return Value(Char16(valueString[0])); |
return CIMValue(Char16(valueString[0])); |
} | } |
| |
case Type::UINT8: |
case CIMType::UINT8: |
case Type::UINT16: |
case CIMType::UINT16: |
case Type::UINT32: |
case CIMType::UINT32: |
case Type::UINT64: |
case CIMType::UINT64: |
{ | { |
Uint64 x; | Uint64 x; |
| |
|
|
| |
switch (type) | switch (type) |
{ | { |
case Type::UINT8: return Value(Uint8(x)); |
case CIMType::UINT8: return CIMValue(Uint8(x)); |
case Type::UINT16: return Value(Uint16(x)); |
case CIMType::UINT16: return CIMValue(Uint16(x)); |
case Type::UINT32: return Value(Uint32(x)); |
case CIMType::UINT32: return CIMValue(Uint32(x)); |
case Type::UINT64: return Value(Uint64(x)); |
case CIMType::UINT64: return CIMValue(Uint64(x)); |
default: break; | default: break; |
} | } |
} | } |
| |
case Type::SINT8: |
case CIMType::SINT8: |
case Type::SINT16: |
case CIMType::SINT16: |
case Type::SINT32: |
case CIMType::SINT32: |
case Type::SINT64: |
case CIMType::SINT64: |
{ | { |
Sint64 x; | Sint64 x; |
| |
|
|
| |
switch (type) | switch (type) |
{ | { |
case Type::SINT8: return Value(Sint8(x)); |
case CIMType::SINT8: return CIMValue(Sint8(x)); |
case Type::SINT16: return Value(Sint16(x)); |
case CIMType::SINT16: return CIMValue(Sint16(x)); |
case Type::SINT32: return Value(Sint32(x)); |
case CIMType::SINT32: return CIMValue(Sint32(x)); |
case Type::SINT64: return Value(Sint64(x)); |
case CIMType::SINT64: return CIMValue(Sint64(x)); |
default: break; | default: break; |
} | } |
} | } |
| |
case Type::DATETIME: |
case CIMType::DATETIME: |
{ | { |
DateTime tmp; |
CIMDateTime tmp; |
| |
try | try |
{ | { |
|
|
throw XmlSemanticError(lineNumber, "Bad datetime value"); | throw XmlSemanticError(lineNumber, "Bad datetime value"); |
} | } |
| |
return Value(tmp); |
return CIMValue(tmp); |
} | } |
| |
case Type::REAL32: |
case CIMType::REAL32: |
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) | if (!stringToReal(valueString, x)) |
throw XmlSemanticError(lineNumber, "Bad real value"); | throw XmlSemanticError(lineNumber, "Bad real value"); |
| |
return Value(Real32(x)); |
return CIMValue(Real32(x)); |
} | } |
| |
case Type::REAL64: |
case CIMType::REAL64: |
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) | if (!stringToReal(valueString, x)) |
throw XmlSemanticError(lineNumber, "Bad real value"); | throw XmlSemanticError(lineNumber, "Bad real value"); |
| |
return Value(x); |
return CIMValue(x); |
} | } |
| |
default: | default: |
|
|
| |
Boolean XmlReader::getValueElement( | Boolean XmlReader::getValueElement( |
XmlParser& parser, | XmlParser& parser, |
Type type, |
CIMType type, |
Value& value) |
CIMValue& value) |
{ | { |
// Get VALUE start tag: | // Get VALUE start tag: |
| |
XmlEntry entry; | XmlEntry entry; |
|
|
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
return false; | return false; |
| |
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; | Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
| |
// Get VALUE content: |
|
|
|
const char* valueString = ""; | const char* valueString = ""; |
| |
if (!empty) | if (!empty) |
|
|
} | } |
| |
value = stringToValue(parser.getLine(), valueString,type); | value = stringToValue(parser.getLine(), valueString,type); |
|
|
return true; | return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// getStringValueElement() |
|
// |
|
// <!ELEMENT VALUE (#PCDATA)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getStringValueElement( |
|
XmlParser& parser, |
|
String& str, |
|
Boolean required) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
|
{ |
|
if (required) |
|
throw XmlValidationError(parser.getLine(),"Expected VALUE element"); |
|
return false; |
|
} |
|
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
|
const char* valueString = ""; |
|
|
|
if (!empty) |
|
{ |
|
if (testContentOrCData(parser, entry)) |
|
valueString = entry.text; |
|
|
|
expectEndTag(parser, "VALUE"); |
|
} |
|
|
|
str = valueString; |
|
return true; |
|
} |
|
|
|
//---------------------------------------------------------------------------- |
|
// |
|
// getPropertyValue |
|
// Use: Decode property value from getPropertyResponse |
|
// Expect (ERROR|IRETURNVALUE).!ELEMENT VALUE (#PCDATA)> |
|
// |
|
// PropertyValue: |
|
// <!ELEMENT VALUE> |
|
// |
|
// <!ELEMENT VALUE.ARRAY (VALUE*)> |
|
// |
|
// <!ELEMENT VALUE.REFERENCE (CLASSPATH|LOCALCLASSPATH|CLASSNAME| |
|
// INSTANCEPATH|LOCALINSTANCEPATH|INSTANCENAME)> |
|
// |
|
//---------------------------------------------------------------------------- |
|
Boolean XmlReader::getPropertyValue( |
|
XmlParser& parser, |
|
CIMValue& cimValue) |
|
{ |
|
//Test for Element value type |
|
CIMType type = CIMType::STRING; |
|
|
|
if (XmlReader::getValueElement(parser, type, cimValue)) |
|
{ |
|
//cout << "DEBUG xmlReader::getPropertyValue " << __LINE__ |
|
// << " CimValue = " << cimValue.toString << endl; |
|
return true; |
|
} |
|
|
|
//Test for Element.array value |
|
if(XmlReader::getValueArrayElement(parser, type, cimValue)) |
|
return true; |
|
|
|
// 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; |
|
if(XmlReader::getValueReferenceElement(parser, reference)) |
|
return true; |
|
|
|
return false; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// stringArrayToValue() | // stringArrayToValue() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
template<class T> | template<class T> |
Value StringArrayToValueAux( |
CIMValue StringArrayToValueAux( |
Uint32 lineNumber, | Uint32 lineNumber, |
const Array<const char*>& stringArray, | const Array<const char*>& stringArray, |
Type type, |
CIMType type, |
T*) | T*) |
{ | { |
Array<T> array; | Array<T> array; |
| |
for (Uint32 i = 0, n = stringArray.getSize(); i < n; i++) |
for (Uint32 i = 0, n = stringArray.size(); i < n; i++) |
{ | { |
Value value = XmlReader::stringToValue( |
CIMValue value = XmlReader::stringToValue( |
lineNumber, stringArray[i], type); | lineNumber, stringArray[i], type); |
| |
T x; | T x; |
|
|
array.append(x); | array.append(x); |
} | } |
| |
return Value(array); |
return CIMValue(array); |
} | } |
| |
Value XmlReader::stringArrayToValue( |
CIMValue XmlReader::stringArrayToValue( |
Uint32 lineNumber, | Uint32 lineNumber, |
const Array<const char*>& array, | const Array<const char*>& array, |
Type type) |
CIMType type) |
{ | { |
switch (type) | switch (type) |
{ | { |
case Type::BOOLEAN: |
case CIMType::BOOLEAN: |
return StringArrayToValueAux(lineNumber, array, type, (Boolean*)0); | return StringArrayToValueAux(lineNumber, array, type, (Boolean*)0); |
| |
case Type::STRING: |
case CIMType::STRING: |
return StringArrayToValueAux(lineNumber, array, type, (String*)0); | return StringArrayToValueAux(lineNumber, array, type, (String*)0); |
| |
case Type::CHAR16: |
case CIMType::CHAR16: |
return StringArrayToValueAux(lineNumber, array, type, (Char16*)0); | return StringArrayToValueAux(lineNumber, array, type, (Char16*)0); |
| |
case Type::UINT8: |
case CIMType::UINT8: |
return StringArrayToValueAux(lineNumber, array, type, (Uint8*)0); | return StringArrayToValueAux(lineNumber, array, type, (Uint8*)0); |
| |
case Type::UINT16: |
case CIMType::UINT16: |
return StringArrayToValueAux(lineNumber, array, type, (Uint16*)0); | return StringArrayToValueAux(lineNumber, array, type, (Uint16*)0); |
| |
case Type::UINT32: |
case CIMType::UINT32: |
return StringArrayToValueAux(lineNumber, array, type, (Uint32*)0); | return StringArrayToValueAux(lineNumber, array, type, (Uint32*)0); |
| |
case Type::UINT64: |
case CIMType::UINT64: |
return StringArrayToValueAux(lineNumber, array, type, (Uint64*)0); | return StringArrayToValueAux(lineNumber, array, type, (Uint64*)0); |
| |
case Type::SINT8: |
case CIMType::SINT8: |
return StringArrayToValueAux(lineNumber, array, type, (Sint8*)0); | return StringArrayToValueAux(lineNumber, array, type, (Sint8*)0); |
| |
case Type::SINT16: |
case CIMType::SINT16: |
return StringArrayToValueAux(lineNumber, array, type, (Sint16*)0); | return StringArrayToValueAux(lineNumber, array, type, (Sint16*)0); |
| |
case Type::SINT32: |
case CIMType::SINT32: |
return StringArrayToValueAux(lineNumber, array, type, (Sint32*)0); | return StringArrayToValueAux(lineNumber, array, type, (Sint32*)0); |
| |
case Type::SINT64: |
case CIMType::SINT64: |
return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0); | return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0); |
| |
case Type::DATETIME: |
case CIMType::DATETIME: |
return StringArrayToValueAux(lineNumber, array, type, (DateTime*)0); |
return StringArrayToValueAux(lineNumber, array, type, (CIMDateTime*)0); |
| |
case Type::REAL32: |
case CIMType::REAL32: |
return StringArrayToValueAux(lineNumber, array, type, (Real32*)0); | return StringArrayToValueAux(lineNumber, array, type, (Real32*)0); |
| |
case Type::REAL64: |
case CIMType::REAL64: |
return StringArrayToValueAux(lineNumber, array, type, (Real64*)0); | return StringArrayToValueAux(lineNumber, array, type, (Real64*)0); |
| |
default: | default: |
|
|
} | } |
| |
// Unreachable: | // Unreachable: |
return Value(); |
return CIMValue(); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
Boolean XmlReader::getValueArrayElement( | Boolean XmlReader::getValueArrayElement( |
XmlParser& parser, | XmlParser& parser, |
Type type, |
CIMType type, |
Value& value) |
CIMValue& value) |
{ | { |
value.clear(); | value.clear(); |
| |
|
|
Uint32 flavor = 0; | Uint32 flavor = 0; |
| |
if (overridable) | if (overridable) |
flavor |= Flavor::OVERRIDABLE; |
flavor |= CIMFlavor::OVERRIDABLE; |
| |
if (toSubClass) | if (toSubClass) |
flavor |= Flavor::TOSUBCLASS; |
flavor |= CIMFlavor::TOSUBCLASS; |
| |
if (toInstance) | if (toInstance) |
flavor |= Flavor::TOINSTANCE; |
flavor |= CIMFlavor::TOINSTANCE; |
| |
if (translatable) | if (translatable) |
flavor |= Flavor::TRANSLATABLE; |
flavor |= CIMFlavor::TRANSLATABLE; |
| |
return flavor; | return flavor; |
} | } |
|
|
Uint32 scope = 0; | Uint32 scope = 0; |
| |
if (getCimBooleanAttribute(line, entry, "SCOPE", "CLASS", false, false)) | if (getCimBooleanAttribute(line, entry, "SCOPE", "CLASS", false, false)) |
scope |= Scope::CLASS; |
scope |= CIMScope::CLASS; |
| |
if (getCimBooleanAttribute( | if (getCimBooleanAttribute( |
line, entry, "SCOPE", "ASSOCIATION", false, false)) | line, entry, "SCOPE", "ASSOCIATION", false, false)) |
scope |= Scope::ASSOCIATION; |
scope |= CIMScope::ASSOCIATION; |
| |
if (getCimBooleanAttribute( | if (getCimBooleanAttribute( |
line, entry, "SCOPE", "REFERENCE", false, false)) | line, entry, "SCOPE", "REFERENCE", false, false)) |
scope |= Scope::REFERENCE; |
scope |= CIMScope::REFERENCE; |
| |
if (getCimBooleanAttribute(line, entry, "SCOPE", "PROPERTY", false, false)) | if (getCimBooleanAttribute(line, entry, "SCOPE", "PROPERTY", false, false)) |
scope |= Scope::PROPERTY; |
scope |= CIMScope::PROPERTY; |
| |
if (getCimBooleanAttribute(line, entry, "SCOPE", "METHOD", false, false)) | if (getCimBooleanAttribute(line, entry, "SCOPE", "METHOD", false, false)) |
scope |= Scope::METHOD; |
scope |= CIMScope::METHOD; |
| |
if (getCimBooleanAttribute(line, entry, "SCOPE", "PARAMETER", false, false)) | if (getCimBooleanAttribute(line, entry, "SCOPE", "PARAMETER", false, false)) |
scope |= Scope::PARAMETER; |
scope |= CIMScope::PARAMETER; |
| |
if (getCimBooleanAttribute(line, entry, "SCOPE", "INDICATION",false, false)) | if (getCimBooleanAttribute(line, entry, "SCOPE", "INDICATION",false, false)) |
scope |= Scope::INDICATION; |
scope |= CIMScope::INDICATION; |
| |
if (!isEmptyTag) | if (!isEmptyTag) |
expectEndTag(parser, "SCOPE"); | expectEndTag(parser, "SCOPE"); |
|
|
| |
Boolean XmlReader::getQualifierElement( | Boolean XmlReader::getQualifierElement( |
XmlParser& parser, | XmlParser& parser, |
Qualifier& qualifier) |
CIMQualifier& qualifier) |
{ | { |
// Get QUALIFIER element: | // Get QUALIFIER element: |
| |
|
|
| |
// Get QUALIFIER.TYPE attribute: | // Get QUALIFIER.TYPE attribute: |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "QUALIFIER"); |
| |
// Get QUALIFIER.PROPAGATED | // Get QUALIFIER.PROPAGATED |
| |
|
|
| |
// Get VALUE or VALUE.ARRAY element: | // Get VALUE or VALUE.ARRAY element: |
| |
Value value; |
CIMValue value; |
| |
if (!getValueElement(parser, type, value) && | if (!getValueElement(parser, type, value) && |
!getValueArrayElement(parser, type, value)) | !getValueArrayElement(parser, type, value)) |
|
|
| |
// Build qualifier: | // Build qualifier: |
| |
qualifier = Qualifier(name, value, flavor, propagated); |
qualifier = CIMQualifier(name, value, flavor, propagated); |
return true; | return true; |
} | } |
| |
|
|
template<class CONTAINER> | template<class CONTAINER> |
void getQualifierElements(XmlParser& parser, CONTAINER& container) | void getQualifierElements(XmlParser& parser, CONTAINER& container) |
{ | { |
Qualifier qualifier; |
CIMQualifier qualifier; |
| |
while (XmlReader::getQualifierElement(parser, qualifier)) | while (XmlReader::getQualifierElement(parser, qualifier)) |
{ | { |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getPropertyElement(XmlParser& parser, Property& property) |
Boolean XmlReader::getPropertyElement(XmlParser& parser, CIMProperty& property) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
// Create property: | // Create property: |
| |
Value value; |
CIMValue value; |
value.setNullValue(type, false); | value.setNullValue(type, false); |
property = Property( |
property = CIMProperty( |
name, value, 0, String(), classOrigin, propagated); | name, value, 0, String(), classOrigin, propagated); |
| |
if (!empty) | if (!empty) |
|
|
| |
Boolean XmlReader::getPropertyArrayElement( | Boolean XmlReader::getPropertyArrayElement( |
XmlParser& parser, | XmlParser& parser, |
Property& property) |
CIMProperty& property) |
{ | { |
// Get PROPERTY element: | // Get PROPERTY element: |
| |
|
|
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
| |
// Get PROPERTY.ARRAYSIZE attribute: | // Get PROPERTY.ARRAYSIZE attribute: |
| |
|
|
| |
// Create property: | // Create property: |
| |
Value nullValue; |
CIMValue nullValue; |
nullValue.setNullValue(type, true, arraySize); | nullValue.setNullValue(type, true, arraySize); |
property = Property( |
property = CIMProperty( |
name, nullValue, arraySize, String(), classOrigin, propagated); | name, nullValue, arraySize, String(), classOrigin, propagated); |
| |
if (!empty) | if (!empty) |
|
|
| |
// Get value: | // Get value: |
| |
Value value; |
CIMValue value; |
| |
if (getValueArrayElement(parser, type, value)) | if (getValueArrayElement(parser, type, value)) |
{ | { |
|
|
| |
while (getNameSpaceElement(parser, nameSpaceComponent)) | while (getNameSpaceElement(parser, nameSpaceComponent)) |
{ | { |
if (nameSpace.getLength()) |
if (nameSpace.size()) |
nameSpace += '/'; | nameSpace += '/'; |
| |
nameSpace += nameSpaceComponent; | nameSpace += nameSpaceComponent; |
} | } |
| |
if (!nameSpace.getLength()) |
if (!nameSpace.size()) |
{ | { |
throw XmlValidationError(parser.getLine(), | throw XmlValidationError(parser.getLine(), |
"Expected one or more NAMESPACE elements within " | "Expected one or more NAMESPACE elements within " |
|
|
if (!entry.getAttributeValue("VALUETYPE", tmp)) | if (!entry.getAttributeValue("VALUETYPE", tmp)) |
return KeyBinding::STRING; | return KeyBinding::STRING; |
| |
if (tmp == "string") |
if (String::equal(tmp, "string")) |
return KeyBinding::STRING; | return KeyBinding::STRING; |
else if (tmp == "boolean") |
else if (String::equal(tmp, "boolean")) |
return KeyBinding::BOOLEAN; | return KeyBinding::BOOLEAN; |
else if (tmp == "numeric") |
else if (String::equal(tmp, "numeric")) |
return KeyBinding::NUMERIC; | return KeyBinding::NUMERIC; |
| |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
| |
sprintf(buffer, | sprintf(buffer, |
"Illegal value for %s.VALUETYPE attribute; " | "Illegal value for %s.VALUETYPE attribute; " |
"Value must be one of \"string\", \"boolean\", or \"numeric\"", |
"CIMValue must be one of \"string\", \"boolean\", or \"numeric\"", |
elementName); | elementName); |
| |
throw XmlSemanticError(lineNumber, buffer); | throw XmlSemanticError(lineNumber, buffer); |
|
|
// <!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( |
|
|
// <!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( |
|
|
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; |
|
|
// %ClassName;> | // %ClassName;> |
// | // |
// ATTN-B: VALUE.REFERENCE sub-element not accepted yet. | // ATTN-B: VALUE.REFERENCE sub-element not accepted yet. |
// ATTN-B: KEYVALUE sub-element nothandled yet. |
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
return true; | return true; |
} | } |
| |
|
Boolean XmlReader::getInstanceNameElement( |
|
XmlParser& parser, |
|
CIMReference& instanceName) |
|
{ |
|
String className; |
|
Array<KeyBinding> keyBindings; |
|
|
|
if (!XmlReader::getInstanceNameElement(parser, className, keyBindings)) |
|
return false; |
|
|
|
instanceName.set(String(), String(), className, keyBindings); |
|
return true; |
|
} |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getInstancePathElement() | // getInstancePathElement() |
|
|
| |
Boolean XmlReader::getInstancePathElement( | Boolean XmlReader::getInstancePathElement( |
XmlParser& parser, | XmlParser& parser, |
Reference& reference) |
CIMReference& reference) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
Boolean XmlReader::getLocalInstancePathElement( | Boolean XmlReader::getLocalInstancePathElement( |
XmlParser& parser, | XmlParser& parser, |
Reference& reference) |
CIMReference& reference) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
Boolean XmlReader::getClassPathElement( | Boolean XmlReader::getClassPathElement( |
XmlParser& parser, | XmlParser& parser, |
Reference& reference) |
CIMReference& reference) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
Boolean XmlReader::getLocalClassPathElement( | Boolean XmlReader::getLocalClassPathElement( |
XmlParser& parser, | XmlParser& parser, |
Reference& reference) |
CIMReference& reference) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
Boolean XmlReader::getValueReferenceElement( | Boolean XmlReader::getValueReferenceElement( |
XmlParser& parser, | XmlParser& parser, |
Reference& reference) |
CIMReference& reference) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
Boolean XmlReader::getPropertyReferenceElement( | Boolean XmlReader::getPropertyReferenceElement( |
XmlParser& parser, | XmlParser& parser, |
Property& property) |
CIMProperty& property) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Create property: | // Create property: |
| |
Value value; |
CIMValue value; |
value.set(Reference()); |
value.set(CIMReference()); |
property = Property( |
property = CIMProperty( |
name, value, 0, referenceClass, classOrigin, propagated); | name, value, 0, referenceClass, classOrigin, propagated); |
| |
if (!empty) | if (!empty) |
{ | { |
getQualifierElements(parser, property); | getQualifierElements(parser, property); |
| |
Reference reference; |
CIMReference reference; |
| |
if (getValueReferenceElement(parser, reference)) | if (getValueReferenceElement(parser, reference)) |
property.setValue(reference); | property.setValue(reference); |
|
|
template<class CONTAINER> | template<class CONTAINER> |
void GetPropertyElements(XmlParser& parser, CONTAINER& container) | void GetPropertyElements(XmlParser& parser, CONTAINER& container) |
{ | { |
Property property; |
CIMProperty property; |
| |
while (XmlReader::getPropertyElement(parser, property) || | while (XmlReader::getPropertyElement(parser, property) || |
XmlReader::getPropertyArrayElement(parser, property) || | XmlReader::getPropertyArrayElement(parser, property) || |
|
|
| |
Boolean XmlReader::getParameterElement( | Boolean XmlReader::getParameterElement( |
XmlParser& parser, | XmlParser& parser, |
Parameter& parameter) |
CIMParameter& parameter) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Get PARAMETER.TYPE attribute: | // Get PARAMETER.TYPE attribute: |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER"); |
| |
// Create parameter: | // Create parameter: |
| |
parameter = Parameter(name, type); |
parameter = CIMParameter(name, type); |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
| |
Boolean XmlReader::getParameterArrayElement( | Boolean XmlReader::getParameterArrayElement( |
XmlParser& parser, | XmlParser& parser, |
Parameter& parameter) |
CIMParameter& parameter) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Get PARAMETER.ARRAY.TYPE attribute: | // Get PARAMETER.ARRAY.TYPE attribute: |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PARAMETER.ARRAY"); |
| |
// Get PARAMETER.ARRAYSIZE attribute: | // Get PARAMETER.ARRAYSIZE attribute: |
| |
|
|
| |
// Create parameter: | // Create parameter: |
| |
parameter = Parameter(name, type, true, arraySize); |
parameter = CIMParameter(name, type, true, arraySize); |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
| |
Boolean XmlReader::getParameterReferenceElement( | Boolean XmlReader::getParameterReferenceElement( |
XmlParser& parser, | XmlParser& parser, |
Parameter& parameter) |
CIMParameter& parameter) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Create parameter: | // Create parameter: |
| |
parameter = Parameter(name, Type::REFERENCE, false, 0, referenceClass); |
parameter = CIMParameter(name, CIMType::REFERENCE, false, 0, referenceClass); |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
template<class CONTAINER> | template<class CONTAINER> |
void GetParameterElements(XmlParser& parser, CONTAINER& container) | void GetParameterElements(XmlParser& parser, CONTAINER& container) |
{ | { |
Parameter parameter; |
CIMParameter parameter; |
| |
while (XmlReader::getParameterElement(parser, parameter) || | while (XmlReader::getParameterElement(parser, parameter) || |
XmlReader::getParameterArrayElement(parser, parameter) || | XmlReader::getParameterArrayElement(parser, parameter) || |
|
|
| |
Boolean XmlReader::getQualifierDeclElement( | Boolean XmlReader::getQualifierDeclElement( |
XmlParser& parser, | XmlParser& parser, |
QualifierDecl& qualifierDecl) |
CIMQualifierDecl& qualifierDecl) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
// Get TYPE attribute: | // Get TYPE attribute: |
| |
Type type = getCimTypeAttribute( |
CIMType type = getCimTypeAttribute( |
parser.getLine(), entry, "QUALIFIER.DECLARATION"); | parser.getLine(), entry, "QUALIFIER.DECLARATION"); |
| |
// Get ISARRAY attribute: | // Get ISARRAY attribute: |
|
|
| |
// No need to look for interior elements if empty tag: | // No need to look for interior elements if empty tag: |
| |
Uint32 scope = Scope::NONE; |
Uint32 scope = CIMScope::NONE; |
Value value; |
CIMValue value; |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
expectEndTag(parser, "QUALIFIER.DECLARATION"); | expectEndTag(parser, "QUALIFIER.DECLARATION"); |
} | } |
| |
if (value.getType() == Type::NONE) |
if (value.getType() == CIMType::NONE) |
{ | { |
if (isArray) | if (isArray) |
value.setNullValue(type, true, arraySize); | value.setNullValue(type, true, arraySize); |
|
|
value.setNullValue(type, false); | value.setNullValue(type, false); |
} | } |
| |
QualifierDecl tmp(name, value, scope, flavor, arraySize); |
CIMQualifierDecl tmp(name, value, scope, flavor, arraySize); |
qualifierDecl = QualifierDecl(name, value, scope, flavor, arraySize); |
qualifierDecl = CIMQualifierDecl(name, value, scope, flavor, arraySize); |
return true; | return true; |
} | } |
| |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getMethodElement(XmlParser& parser, Method& method) |
Boolean XmlReader::getMethodElement(XmlParser& parser, CIMMethod& method) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); | String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
Type type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
String classOrigin = | String classOrigin = |
getClassOriginAttribute(parser.getLine(), entry, "PROPERTY"); | getClassOriginAttribute(parser.getLine(), entry, "PROPERTY"); |
|
|
Boolean propagated = getCimBooleanAttribute( | Boolean propagated = getCimBooleanAttribute( |
parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); | parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); |
| |
method = Method(name, type, classOrigin, propagated); |
method = CIMMethod(name, type, classOrigin, propagated); |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getClassElement(XmlParser& parser, ClassDecl& classDecl) |
Boolean XmlReader::getClassElement(XmlParser& parser, CIMClass& cimClass) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
String superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS"); | String superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS"); |
| |
classDecl = ClassDecl(name, superClass); |
cimClass = CIMClass(name, superClass); |
| |
// Get QUALIFIER elements: | // Get QUALIFIER elements: |
| |
getQualifierElements(parser, classDecl); |
getQualifierElements(parser, cimClass); |
| |
// Get PROPERTY elements: | // Get PROPERTY elements: |
| |
GetPropertyElements(parser, classDecl); |
GetPropertyElements(parser, cimClass); |
| |
// Get METHOD elements: | // Get METHOD elements: |
| |
Method method; |
CIMMethod method; |
| |
while (getMethodElement(parser, method)) | while (getMethodElement(parser, method)) |
classDecl.addMethod(method); |
cimClass.addMethod(method); |
| |
// Get CLASS end tag: | // Get CLASS end tag: |
| |
|
|
| |
Boolean XmlReader::getInstanceElement( | Boolean XmlReader::getInstanceElement( |
XmlParser& parser, | XmlParser& parser, |
InstanceDecl& instanceDecl) |
CIMInstance& cimInstance) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
String className = getClassNameAttribute( | String className = getClassNameAttribute( |
parser.getLine(), entry, "INSTANCE"); | parser.getLine(), entry, "INSTANCE"); |
| |
instanceDecl = InstanceDecl(className); |
cimInstance = CIMInstance(className); |
| |
// Get QUALIFIER elements: | // Get QUALIFIER elements: |
| |
getQualifierElements(parser, instanceDecl); |
getQualifierElements(parser, cimInstance); |
| |
// Get PROPERTY elements: | // Get PROPERTY elements: |
| |
GetPropertyElements(parser, instanceDecl); |
GetPropertyElements(parser, cimInstance); |
| |
// Get INSTANCE end tag: | // Get INSTANCE end tag: |
| |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// getObject() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlReader::getObject(XmlParser& parser, CIMClass& x) |
|
{ |
|
if (!getClassElement(parser, x)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected CLASS element"); |
|
} |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getObject() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlReader::getObject(XmlParser& parser, CIMInstance& x) |
|
{ |
|
if (!getInstanceElement(parser, x)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected INSTANCE element"); |
|
} |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getObject() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlReader::getObject(XmlParser& parser, CIMQualifierDecl& x) |
|
{ |
|
if (!getQualifierDeclElement(parser, x)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected QUALIFIER.DECLARATION element"); |
|
} |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// getMessageStartTag() | // getMessageStartTag() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getMessageStartTag( | Boolean XmlReader::getMessageStartTag( |
XmlParser& parser, | XmlParser& parser, |
Uint32& id, |
String& id, |
const char*& protocolVersion) | const char*& protocolVersion) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
|
|
| |
if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion)) | if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion)) |
throw XmlValidationError(parser.getLine(), | throw XmlValidationError(parser.getLine(), |
"Bad or missing MESSAGE.ID attribute"); |
"Bad or missing MESSAGE.PROTOCOLVERSION attribute"); |
| |
return true; | return true; |
} | } |
|
|
| |
Boolean XmlReader::getErrorElement( | Boolean XmlReader::getErrorElement( |
XmlParser& parser, | XmlParser& parser, |
CimException::Code& code, |
CIMStatusCode& code, |
const char*& description, | const char*& description, |
Boolean required) | Boolean required) |
{ | { |
|
|
throw XmlValidationError( | throw XmlValidationError( |
parser.getLine(), "missing ERROR.CODE attribute"); | parser.getLine(), "missing ERROR.CODE attribute"); |
| |
code = CimException::Code(tmpCode); |
code = CIMStatusCode(tmpCode); |
| |
// Get ERROR.DESCRIPTION: | // Get ERROR.DESCRIPTION: |
| |
|
|
return true; | return true; |
} | } |
| |
|
|
|
//------------------------------------------------------------------------------ |
|
// getObjectWithPath() |
|
// |
|
// <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getObjectWithPath( |
|
XmlParser& parser, |
|
CIMObjectWithPath& objectWithPath) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "VALUE.OBJECTWITHPATH")) |
|
return false; |
|
|
|
CIMReference reference; |
|
Boolean isInstance = false; |
|
|
|
if (XmlReader::getInstancePathElement(parser, reference)) |
|
isInstance = true; |
|
else if (!XmlReader::getClassPathElement(parser, reference)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"Expected INSTANCE element"); |
|
} |
|
|
|
if (isInstance) |
|
{ |
|
CIMInstance cimInstance; |
|
|
|
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"Expected INSTANCEPATH or CLASSPATH element"); |
|
} |
|
objectWithPath.set(reference, CIMObject(cimInstance)); |
|
} |
|
else |
|
{ |
|
CIMClass cimClass; |
|
|
|
if (!XmlReader::getClassElement(parser, cimClass)) |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"Expected CLASS element"); |
|
} |
|
objectWithPath.set(reference, CIMObject(cimClass)); |
|
} |
|
|
|
expectEndTag(parser, "VALUE.OBJECTWITHPATH"); |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// <objectName>: (CLASSNAME|INSTANCENAME) |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getObjectNameElement( |
|
XmlParser& parser, |
|
CIMReference& objectName) |
|
{ |
|
String className; |
|
CIMReference instanceName; |
|
|
|
if (getClassNameElement(parser, className, false)) |
|
{ |
|
objectName.set(String(), String(), className); |
|
return true; |
|
} |
|
else if (getInstanceNameElement(parser, objectName)) |
|
return true; |
|
else |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected CLASSNAME or INSTANCENAME element"); |
|
} |
|
|
|
return false; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// <!ELEMENT OBJECTPATH (INSTANCEPATH|CLASSPATH)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getObjectPathElement( |
|
XmlParser& parser, |
|
CIMReference& objectPath) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "OBJECTPATH")) |
|
return false; |
|
|
|
if (getClassPathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else if (getInstancePathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else |
|
{ |
|
throw XmlValidationError(parser.getLine(), |
|
"expected INSTANCEPATH or CLASSPATH element"); |
|
} |
|
|
|
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 |