version 1.34, 2002/03/06 05:12:05
|
version 1.35, 2002/03/07 00:42:12
|
|
|
// ATTN-C: note that integers are truncated without warning. What should be | // ATTN-C: note that integers are truncated without warning. What should be |
// done in this case? In C they are truncated without warning by design. | // done in this case? In C they are truncated without warning by design. |
// | // |
|
// Return: CIMValue. If the string input is zero length creates a CIMValue |
|
// with value defined by the type. Else the value is inserted. |
|
// |
|
// Note that this does not set the CIMValue Null if the string is empty. |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
CIMValue XmlReader::stringToValue( | CIMValue XmlReader::stringToValue( |
|
|
{ | { |
// 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 == 0, set to default value for type |
|
|
if (strlen(valueString)==0) | if (strlen(valueString)==0) |
{ | { |
// This needs to reflect the Null result. KSTESTNULL |
|
// ATTN: review the other code for this characteristic |
|
// In all cases, XML with an empty entry is NULL <VALUE></VALUE> |
|
return CIMValue(type, false); |
|
/* KS 27 Feb 2002 Droped this code in favor of inserting the Null version |
|
switch (type) | switch (type) |
{ | { |
case CIMType::BOOLEAN: return CIMValue(false); | case CIMType::BOOLEAN: return CIMValue(false); |
|
|
case CIMType::REAL32: return CIMValue(Real32(0)); | case CIMType::REAL32: return CIMValue(Real32(0)); |
case CIMType::REAL64: return CIMValue(Real64(0)); | case CIMType::REAL64: return CIMValue(Real64(0)); |
} | } |
*/ |
|
} | } |
| |
|
// Create value per type |
switch (type) | switch (type) |
{ | { |
case CIMType::BOOLEAN: | case CIMType::BOOLEAN: |
|
|
// | // |
// <!ELEMENT VALUE (#PCDATA)> | // <!ELEMENT VALUE (#PCDATA)> |
// | // |
|
// Return: false if no value element. |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getValueElement( | Boolean XmlReader::getValueElement( |
|
|
CIMType type, | CIMType type, |
CIMValue& value) | CIMValue& value) |
{ | { |
// Get VALUE start tag: |
// Get VALUE start tag: Return false if no VALUE start Tag |
| |
XmlEntry entry; | XmlEntry entry; |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
|
|
// | // |
// <!ELEMENT VALUE.ARRAY (VALUE*)> | // <!ELEMENT VALUE.ARRAY (VALUE*)> |
// | // |
|
// Return: Boolean. Returns false if there is no VALUE.ARRAY start element |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getValueArrayElement( | Boolean XmlReader::getValueArrayElement( |
|
|
CIMType type, | CIMType type, |
CIMValue& value) | CIMValue& value) |
{ | { |
|
// Clears any values from the Array. Assumes this is array CIMValue |
value.clear(); | value.clear(); |
| |
// Get VALUE.ARRAY open tag: | // Get VALUE.ARRAY open tag: |
|
|
XmlEntry entry; | XmlEntry entry; |
Array<const char*> stringArray; | Array<const char*> stringArray; |
| |
|
// If no VALUE.ARRAY start tag, return false |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) |
return false; | return false; |
| |
//ATTN: P1 KS KSTESTNULL - Need to relook at this one. | //ATTN: P1 KS KSTESTNULL - Need to relook at this one. |
//if (entry.type == XmlEntry::EMPTY_TAG) |
if (entry.type == XmlEntry::EMPTY_TAG) |
// return true; |
return true; |
| |
if (entry.type != XmlEntry::EMPTY_TAG) | if (entry.type != XmlEntry::EMPTY_TAG) |
{ | { |
|
|
Boolean translatable = getCimBooleanAttribute( | Boolean translatable = getCimBooleanAttribute( |
lineNumber, entry, tagName, "TRANSLATABLE", false, false); | lineNumber, entry, tagName, "TRANSLATABLE", false, false); |
| |
Uint32 flavor = 0; |
// ATTN: KS P1 5 Mar 2002 Should this not be CIMFlavor::DEFAULTS?? |
|
Uint32 flavor = CIMFlavor::DEFAULTS; |
| |
if (overridable) | if (overridable) |
flavor |= CIMFlavor::OVERRIDABLE; | flavor |= CIMFlavor::OVERRIDABLE; |
|
|
| |
// Get VALUE or VALUE.ARRAY element: | // Get VALUE or VALUE.ARRAY element: |
| |
|
// ATTN: KS P1 4 March 2002 - Requires either value or array element or |
|
// generates exception. Correct for spec but means no NULL values on qualifier |
|
// values. Alternative is to set NULL value and continue |
|
|
CIMValue value; | CIMValue value; |
| |
if (!getValueElement(parser, type, value) && | if (!getValueElement(parser, type, value) && |
|
|
| |
CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); | CIMType type = getCimTypeAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
// Create property: |
// Create property: Sets type and !isarray |
|
// ATTN: KS P1 change to use the correct constructor |
| |
CIMValue value; | CIMValue value; |
value.setNullValue(type, false); | value.setNullValue(type, false); |
|
|
| |
getQualifierElements(parser, property); | getQualifierElements(parser, property); |
| |
// Get value: |
// Get value: Insert value if getValueElement exists (returns True) |
| |
if (getValueElement(parser, type, value)) | if (getValueElement(parser, type, value)) |
property.setValue(value); | property.setValue(value); |
|
|
| |
// Create property: | // Create property: |
| |
|
// ATTN: KS P1 4 March 2002 Change to use correct constructor. |
|
// ATTN: KS P3 4 March 2002. Why create extra value. Use same one. |
|
|
CIMValue nullValue; | CIMValue nullValue; |
nullValue.setNullValue(type, true, arraySize); | nullValue.setNullValue(type, true, arraySize); |
property = CIMProperty( | property = CIMProperty( |
|
|
| |
// Get value: | // Get value: |
| |
|
// ATTN: KS P1 4 March 2002. Does not set array type into value. |
|
// ATTN: Thus, if it returns false, the CIMValue is nothing. |
CIMValue value; | CIMValue value; |
| |
if (getValueArrayElement(parser, type, value)) | if (getValueArrayElement(parser, type, value)) |