version 1.74, 2008/12/02 09:00:43
|
version 1.76.6.1, 2011/08/08 08:42:55
|
|
|
#include "CIMName.h" | #include "CIMName.h" |
#include "CIMValue.h" | #include "CIMValue.h" |
#include "XmlReader.h" | #include "XmlReader.h" |
|
#include <Pegasus/Common/StringConversion.h> |
#include "ArrayInternal.h" | #include "ArrayInternal.h" |
#include "HostLocator.h" | #include "HostLocator.h" |
#include "System.h" | #include "System.h" |
|
|
{ | { |
Uint64 xValue; | Uint64 xValue; |
Uint64 yValue; | Uint64 yValue; |
if (XmlReader::stringToUnsignedInteger( |
if (StringConversion::stringToUnsignedInteger( |
x.getValue().getCString(), xValue) && | x.getValue().getCString(), xValue) && |
XmlReader::stringToUnsignedInteger( |
StringConversion::stringToUnsignedInteger( |
y.getValue().getCString(), yValue)) | y.getValue().getCString(), yValue)) |
{ | { |
return (xValue == yValue); | return (xValue == yValue); |
|
|
{ | { |
Sint64 xValue; | Sint64 xValue; |
Sint64 yValue; | Sint64 yValue; |
if (XmlReader::stringToSignedInteger( |
if (StringConversion::stringToSignedInteger( |
x.getValue().getCString(), xValue) && | x.getValue().getCString(), xValue) && |
XmlReader::stringToSignedInteger( |
StringConversion::stringToSignedInteger( |
y.getValue().getCString(), yValue)) | y.getValue().getCString(), yValue)) |
{ | { |
return (xValue == yValue); | return (xValue == yValue); |
|
|
{ | { |
if ((host != String::EMPTY) && !CIMObjectPathRep::isValidHostname(host)) | if ((host != String::EMPTY) && !CIMObjectPathRep::isValidHostname(host)) |
{ | { |
throw MalformedObjectNameException(host); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
host); |
|
|
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
_rep = _copyOnWriteCIMObjectPathRep(_rep); | _rep = _copyOnWriteCIMObjectPathRep(_rep); |
|
|
char* slash = strchr(p, '/'); | char* slash = strchr(p, '/'); |
if (!slash) | if (!slash) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.MISSING_SLASH_AFTER_HOST", |
|
"$0, reason:\"missing slash after hostname\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
String hostname = String(p, (Uint32)(slash - p)); | String hostname = String(p, (Uint32)(slash - p)); |
if (!CIMObjectPathRep::isValidHostname(hostname)) | if (!CIMObjectPathRep::isValidHostname(hostname)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
host = hostname; | host = hostname; |
| |
|
|
String namespaceName = String(p, (Uint32)(colon - p)); | String namespaceName = String(p, (Uint32)(colon - p)); |
if (!CIMNamespaceName::legal(namespaceName)) | if (!CIMNamespaceName::legal(namespaceName)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NAMESPACE", |
|
"$0, reason:\"invalid namespace name\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
nameSpace = namespaceName; | nameSpace = namespaceName; |
| |
|
|
char* equalsign = strchr(p, '='); | char* equalsign = strchr(p, '='); |
if (!equalsign) | if (!equalsign) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR", |
|
"$0, reason:\"invalid key-value pair, missing equal sign\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
*equalsign = 0; | *equalsign = 0; |
| |
if (!CIMName::legal(p)) | if (!CIMName::legal(p)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYNAME", |
|
"$0, reason:\"invalid key-value pair, invalid key name:$1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
CIMName keyName (p); | CIMName keyName (p); |
| |
|
|
| |
if ((*p != '\\') && (*p != '"')) | if ((*p != '\\') && (*p != '"')) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"malformed value\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
} | } |
| |
|
|
} | } |
| |
if (*p++ != '"') | if (*p++ != '"') |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR_MISSINGQUOTE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"missing quote in key value\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
// Convert the UTF-8 value to a UTF-16 String | // Convert the UTF-8 value to a UTF-16 String |
| |
|
|
| |
if (!(((strncmp(p, "TRUE", n) == 0) && n == 4) || | if (!(((strncmp(p, "TRUE", n) == 0) && n == 4) || |
((strncmp(p, "FALSE", n) == 0) && n == 5))) | ((strncmp(p, "FALSE", n) == 0) && n == 5))) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_BOOLVALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"value should be TRUE or FALSE\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
| |
valueString.assign(p, n); | valueString.assign(p, n); |
| |
|
|
if (*p == '-') | if (*p == '-') |
{ | { |
Sint64 x; | Sint64 x; |
if (!XmlReader::stringToSignedInteger(p, x)) |
if (!StringConversion::stringToSignedInteger(p, x)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NEGATIVNUMBER_VALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"invalid negative number value $1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
} | } |
else | else |
{ | { |
Uint64 x; | Uint64 x; |
if (!XmlReader::stringToUnsignedInteger(p, x)) |
if (!StringConversion::stringToUnsignedInteger(p, x)) |
throw MalformedObjectNameException(objectName); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_NEGATIVNUMBER_VALUE", |
|
"$0, reason:\"invalid key-value pair, " |
|
"invalid number value $1\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
|
} |
} | } |
| |
valueString.assign(p, n); | valueString.assign(p, n); |
|
|
{ | { |
if (*p++ != ',') | if (*p++ != ',') |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_KEYVALUEPAIR_MISSCOMMA", |
|
"$0, reason:\"invalid key-value pair, " |
|
"next key-value pair has to start with comma\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
} | } |
} | } |
|
|
| |
if (gotHost && !gotNamespace) | if (gotHost && !gotNamespace) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.MISSING_NAMESPACE", |
|
"$0, reason:\"host specified, missing namespace\"", |
|
objectName); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
// Extract the class name: | // Extract the class name: |
|
|
{ | { |
if (!CIMName::legal(p)) | if (!CIMName::legal(p)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_CLASSNAME", |
|
"$0, reason:\"class name $1 not a legal CIM name\"", |
|
objectName, |
|
p); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
| |
// ATTN: remove this later: a reference should only be able to hold | // ATTN: remove this later: a reference should only be able to hold |
|
|
String className = String(p, (Uint32)(dot - p)); | String className = String(p, (Uint32)(dot - p)); |
if (!CIMName::legal(className)) | if (!CIMName::legal(className)) |
{ | { |
throw MalformedObjectNameException(objectName); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_CLASSNAME", |
|
"$0, reason:\"class name $1 not a legal CIM name\"", |
|
objectName, |
|
className); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
_rep->_className = className; | _rep->_className = className; |
| |
|
|
(host != System::getHostName()) && | (host != System::getHostName()) && |
!CIMObjectPathRep::isValidHostname(host)) | !CIMObjectPathRep::isValidHostname(host)) |
{ | { |
throw MalformedObjectNameException(host); |
MessageLoaderParms mlParms( |
|
"Common.CIMObjectPath.INVALID_HOSTNAME", |
|
"$0, reason:\"invalid hostname\"", |
|
host); |
|
throw MalformedObjectNameException(mlParms); |
} | } |
_rep = _copyOnWriteCIMObjectPathRep(_rep); | _rep = _copyOnWriteCIMObjectPathRep(_rep); |
| |
|
|
Uint64 uValue; | Uint64 uValue; |
Sint64 sValue; | Sint64 sValue; |
// First try converting to unsigned integer | // First try converting to unsigned integer |
if (XmlReader::stringToUnsignedInteger( |
if (StringConversion::stringToUnsignedInteger( |
ref._rep->_keyBindings[i]._rep->_value.getCString(), | ref._rep->_keyBindings[i]._rep->_value.getCString(), |
uValue)) | uValue)) |
{ | { |
|
|
ref._rep->_keyBindings[i]._rep->_value = String(buffer); | ref._rep->_keyBindings[i]._rep->_value = String(buffer); |
} | } |
// Next try converting to signed integer | // Next try converting to signed integer |
else if (XmlReader::stringToSignedInteger( |
else if (StringConversion::stringToSignedInteger( |
ref._rep->_keyBindings[i]._rep->_value.getCString(), | ref._rep->_keyBindings[i]._rep->_value.getCString(), |
sValue)) | sValue)) |
{ | { |