version 1.7, 2001/04/13 21:53:47
|
version 1.12, 2001/05/08 07:31:59
|
|
|
//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.7 2001/04/13 21:53:47 karl |
|
// add get and set property |
|
// | // |
// Revision 1.6 2001/04/08 01:13:22 mike |
//%///////////////////////////////////////////////////////////////////////////// |
// Changed "ConstCIM" to "CIMConst" |
|
// |
|
// Revision 1.4 2001/02/26 04:33:28 mike |
|
// Fixed many places where cim names were be compared with operator==(String,String). |
|
// Changed all of these to use CIMName::equal() |
|
// |
|
// Revision 1.3 2001/02/19 01:47:16 mike |
|
// Renamed names of the form CIMConst to CIMConst. |
|
// |
|
// 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; |
| |
|
|
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 (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
|
|
{ | { |
// ATTN-B: accepting only UTF-8 for now! (affects string and char16): | // ATTN-B: accepting only UTF-8 for now! (affects string and char16): |
| |
|
//SNIA |
|
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)); |
|
} |
|
} |
|
// end of SNIA |
|
|
switch (type) | switch (type) |
{ | { |
case CIMType::BOOLEAN: | case CIMType::BOOLEAN: |
{ | { |
if (strcmp(valueString, "TRUE") == 0) |
if (strcasecmp(valueString, "TRUE") == 0) |
return CIMValue(true); | return CIMValue(true); |
else if (strcmp(valueString, "FALSE") == 0) |
else if (strcasecmp(valueString, "FALSE") == 0) |
return CIMValue(false); | return CIMValue(false); |
else | else |
throw XmlSemanticError( | throw XmlSemanticError( |
|
|
// 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; | return true; |
} | } |
| |
|
|
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- |
// | // |
// getPropertyValue | // getPropertyValue |
|
// Use: Decode property value from getPropertyResponse |
// Expect (ERROR|IRETURNVALUE).!ELEMENT VALUE (#PCDATA)> | // Expect (ERROR|IRETURNVALUE).!ELEMENT VALUE (#PCDATA)> |
// | // |
// PropertyValue: | // PropertyValue: |
|
|
{ | { |
//Test for Element value type | //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)) |
|
{ |
|
//cout << "DEBUG xmlReader::getPropertyValue " << __LINE__ |
|
// << " CimValue = " << cimValue.toString << endl; |
return true; | return true; |
|
} |
| |
//Test for Element.array value | //Test for Element.array value |
if(XmlReader::getValueArrayElement(parser, type, cimValue)) | if(XmlReader::getValueArrayElement(parser, type, cimValue)) |
|
|
{ | { |
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) |
|
|
| |
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() |