version 1.3, 2001/02/19 01:47:16
|
version 1.11, 2001/04/29 18:57:33
|
|
|
//BEGIN_LICENSE |
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM | // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM |
// | // |
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
// DEALINGS IN THE SOFTWARE. | // DEALINGS IN THE SOFTWARE. |
// | // |
//END_LICENSE |
//============================================================================== |
//BEGIN_HISTORY |
|
// | // |
// Author: |
// Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// $Log$ |
// Modified By: |
// Revision 1.3 2001/02/19 01:47:16 mike |
|
// Renamed names of the form CIMConst to ConstCIM. |
|
// | // |
// Revision 1.2 2001/02/16 02:06:07 mike |
//%///////////////////////////////////////////////////////////////////////////// |
// Renamed many classes and headers. |
|
// |
|
// Revision 1.1.1.1 2001/01/14 19:53:32 mike |
|
// Pegasus import |
|
// |
|
// |
|
//END_HISTORY |
|
| |
#include <cassert> | #include <cassert> |
#include <cctype> | #include <cctype> |
|
|
#include "CIMInstance.h" | #include "CIMInstance.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
//debug |
|
#include <iostream> |
|
using namespace std; |
| |
static const Uint32 MESSAGE_SIZE = 128; | static const Uint32 MESSAGE_SIZE = 128; |
| |
|
|
throw XmlValidationError(lineNumber, buffer); | throw XmlValidationError(lineNumber, buffer); |
} | } |
| |
if (acceptNull && name.getLength() == 0) |
if (acceptNull && name.size() == 0) |
return name; | return name; |
| |
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
|
|
// 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; |
| |
|
|
// Get VALUE content: | // Get VALUE content: |
| |
const char* valueString = ""; | const char* valueString = ""; |
|
// cout << "DEBUG XMLReader:getValueElement " << __LINE__ ; |
| |
if (!empty) | if (!empty) |
{ | { |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
valueString = entry.text; | valueString = entry.text; |
|
//cout << "DEBUG XMLReader:getValueElement " << __LINE__ |
|
// << " valueString " << valueString ; |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
| |
value = stringToValue(parser.getLine(), valueString,type); | value = stringToValue(parser.getLine(), valueString,type); |
|
//cout << "DEBUG XMLReader:getValueElement " << __LINE__ |
|
// << " value " << value; |
|
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; | 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() |
|
|
{ | { |
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++) |
{ | { |
CIMValue value = XmlReader::stringToValue( | CIMValue value = XmlReader::stringToValue( |
lineNumber, stringArray[i], type); | lineNumber, stringArray[i], type); |
|
|
| |
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 " |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
KeyBinding::CIMType XmlReader::getValueTypeAttribute( |
KeyBinding::Type XmlReader::getValueTypeAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName) | const char* elementName) |
|
|
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]; |
|
|
| |
Boolean XmlReader::getKeyValueElement( | Boolean XmlReader::getKeyValueElement( |
XmlParser& parser, | XmlParser& parser, |
KeyBinding::CIMType& type, |
KeyBinding::Type& type, |
String& value) | String& value) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
|
|
XmlParser& parser, | XmlParser& parser, |
String& name, | String& name, |
String& value, | String& value, |
KeyBinding::CIMType& type) |
KeyBinding::Type& type) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
if (!empty) | if (!empty) |
{ | { |
String name; | String name; |
KeyBinding::CIMType type; |
KeyBinding::Type type; |
String value; | String value; |
| |
while (getKeyBindingElement(parser, name, value, type)) | while (getKeyBindingElement(parser, name, value, type)) |
|
|
return true; | return true; |
} | } |
| |
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getErrorElement() | // getErrorElement() |
|
|
| |
Boolean XmlReader::getErrorElement( | Boolean XmlReader::getErrorElement( |
XmlParser& parser, | XmlParser& parser, |
CimException::Code& code, |
CIMException::Code& 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 = CIMException::Code(tmpCode); |
| |
// Get ERROR.DESCRIPTION: | // Get ERROR.DESCRIPTION: |
| |