version 1.6, 2002/06/01 00:56:26
|
version 1.7, 2002/07/30 16:14:53
|
|
|
} | } |
| |
KeyBindingRep( | KeyBindingRep( |
const String& name, |
const CIMName& name, |
const String& value, | const String& value, |
KeyBinding::Type type) | KeyBinding::Type type) |
: _name(name), _value(value), _type(type) | : _name(name), _value(value), _type(type) |
|
|
return *this; | return *this; |
} | } |
| |
String _name; |
CIMName _name; |
String _value; | String _value; |
KeyBinding::Type _type; | KeyBinding::Type _type; |
}; | }; |
|
|
_rep = new KeyBindingRep(*x._rep); | _rep = new KeyBindingRep(*x._rep); |
} | } |
| |
KeyBinding::KeyBinding(const String& name, const String& value, Type type) |
KeyBinding::KeyBinding(const CIMName& name, const String& value, Type type) |
{ | { |
_rep = new KeyBindingRep(name, value, type); | _rep = new KeyBindingRep(name, value, type); |
} | } |
|
|
return *this; | return *this; |
} | } |
| |
const String& KeyBinding::getName() const |
const CIMName& KeyBinding::getName() const |
{ | { |
return _rep->_name; | return _rep->_name; |
} | } |
| |
void KeyBinding::setName(const String& name) |
void KeyBinding::setName(const CIMName& name) |
{ | { |
_rep->_name = name; | _rep->_name = name; |
} | } |
|
|
Boolean operator==(const KeyBinding& x, const KeyBinding& y) | Boolean operator==(const KeyBinding& x, const KeyBinding& y) |
{ | { |
return | return |
CIMName::equal(x.getName(), y.getName()) && |
x.getName().equal(y.getName()) && |
String::equal(x.getValue(), y.getValue()) && | String::equal(x.getValue(), y.getValue()) && |
x.getType() == y.getType(); | x.getType() == y.getType(); |
} | } |
|
|
| |
CIMObjectPathRep( | CIMObjectPathRep( |
const String& host, | const String& host, |
const String& nameSpace, |
const CIMNamespaceName& nameSpace, |
const String& className, |
const CIMName& className, |
const Array<KeyBinding>& keyBindings) | const Array<KeyBinding>& keyBindings) |
: _host(host), _nameSpace(nameSpace), | : _host(host), _nameSpace(nameSpace), |
_className(className), _keyBindings(keyBindings) | _className(className), _keyBindings(keyBindings) |
|
|
// | // |
String _host; | String _host; |
| |
String _nameSpace; |
CIMNamespaceName _nameSpace; |
String _className; |
CIMName _className; |
Array<KeyBinding> _keyBindings; | Array<KeyBinding> _keyBindings; |
}; | }; |
| |
|
|
| |
CIMObjectPath::CIMObjectPath( | CIMObjectPath::CIMObjectPath( |
const String& host, | const String& host, |
const String& nameSpace, |
const CIMNamespaceName& nameSpace, |
const String& className, |
const CIMName& className, |
const Array<KeyBinding>& keyBindings) | const Array<KeyBinding>& keyBindings) |
{ | { |
// Test the objectName out to see if we get an exception | // Test the objectName out to see if we get an exception |
|
|
| |
void CIMObjectPath::set( | void CIMObjectPath::set( |
const String& host, | const String& host, |
const String& nameSpace, |
const CIMNamespaceName& nameSpace, |
const String& className, |
const CIMName& className, |
const Array<KeyBinding>& keyBindings) throw(IllformedObjectName, IllegalName) | const Array<KeyBinding>& keyBindings) throw(IllformedObjectName, IllegalName) |
{ | { |
setHost(host); | setHost(host); |
|
|
Boolean CIMObjectPath::_parseNamespaceElement( | Boolean CIMObjectPath::_parseNamespaceElement( |
const String& objectName, | const String& objectName, |
char*& p, | char*& p, |
String& nameSpace) |
CIMNamespaceName& nameSpace) |
{ | { |
// If we don't find a valid namespace name followed by a ':', we | // If we don't find a valid namespace name followed by a ':', we |
// assume we're not looking at a namespace name. | // assume we're not looking at a namespace name. |
| |
|
char* colon = strchr(p, ':'); |
|
if (!colon) |
|
{ |
|
return false; |
|
} |
|
|
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- |
// Validate the namespace path. Namespaces must match the following | // Validate the namespace path. Namespaces must match the following |
// regular expression: "[A-Za-z_]+(/[A-Za-z_]+)*" | // regular expression: "[A-Za-z_]+(/[A-Za-z_]+)*" |
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- |
| |
char* q = p; |
String namespaceName = String(p, colon - p); |
|
if (!CIMNamespaceName::legal(namespaceName)) |
for (;;) |
|
{ | { |
// Pass the next token: |
throw IllformedObjectName(objectName); |
|
|
if (!*q || (!isalpha(*q) && *q != '_')) |
|
return false; |
|
|
|
q++; |
|
|
|
while (isalnum(*q) || *q == '_') |
|
q++; |
|
|
|
if (!*q) |
|
return false; |
|
|
|
if (*q == ':') |
|
break; |
|
|
|
if (*q == '/') |
|
{ |
|
q++; |
|
continue; |
|
} |
|
|
|
return false; |
|
} | } |
|
nameSpace = namespaceName; |
| |
nameSpace.assign(p, q - p); |
p = colon+1; |
p = ++q; |
|
return true; | return true; |
} | } |
| |
|
|
} | } |
| |
*equalsign = 0; | *equalsign = 0; |
String keyString(p); |
CIMName keyString(p); |
| |
if (!CIMName::legal(keyString)) | if (!CIMName::legal(keyString)) |
throw IllformedObjectName(objectName); | throw IllformedObjectName(objectName); |
|
|
// ATTN: remove this later: a reference should only be able to hold | // ATTN: remove this later: a reference should only be able to hold |
// an instance name. | // an instance name. |
| |
_rep->_className.assign(p); |
_rep->_className = p; |
return; | return; |
} | } |
| |
_rep->_className.assign(p, dot - p); |
String className = String(p, dot - p); |
|
if (!CIMName::legal(className)) |
|
{ |
|
throw IllformedObjectName(objectName); |
|
} |
|
_rep->_className = className; |
| |
// Advance past dot: | // Advance past dot: |
| |
|
|
_rep->_host = host; | _rep->_host = host; |
} | } |
| |
const String& CIMObjectPath::getNameSpace() const |
const CIMNamespaceName& CIMObjectPath::getNameSpace() const |
{ | { |
return _rep->_nameSpace; | return _rep->_nameSpace; |
} | } |
| |
void CIMObjectPath::setNameSpace(const String& nameSpace) throw(IllegalName) |
void CIMObjectPath::setNameSpace(const CIMNamespaceName& nameSpace) |
{ |
|
String temp; |
|
|
|
// check each namespace segment (delimted by '/') for correctness |
|
|
|
for(Uint32 i = 0; i < nameSpace.size(); i += temp.size() + 1) |
|
{ |
|
// isolate the segment beginning at i and ending at the first |
|
// ocurrance of '/' after i or eos |
|
|
|
temp = nameSpace.subString(i, nameSpace.subString(i).find('/')); |
|
|
|
// check segment for correctness |
|
|
|
if(!CIMName::legal(temp)) |
|
{ | { |
throw IllegalName() ; |
|
} |
|
} |
|
|
|
_rep->_nameSpace = nameSpace; | _rep->_nameSpace = nameSpace; |
} | } |
| |
const String& CIMObjectPath::getClassName() const |
const CIMName& CIMObjectPath::getClassName() const |
{ | { |
return _rep->_className; | return _rep->_className; |
} | } |
| |
void CIMObjectPath::setClassName(const String& className) throw(IllegalName) |
void CIMObjectPath::setClassName(const CIMName& className) |
{ | { |
if (!CIMName::legal(className)) |
|
throw IllegalName(); |
|
|
|
_rep->_className = className; | _rep->_className = className; |
} | } |
| |
|
|
| |
// Get the namespace (if we have a host name, we must write namespace): | // Get the namespace (if we have a host name, we must write namespace): |
| |
if (_rep->_nameSpace.size() || _rep->_host.size()) |
if (!_rep->_nameSpace.isNull() || _rep->_host.size()) |
{ | { |
objectName += _rep->_nameSpace; | objectName += _rep->_nameSpace; |
objectName += ":"; | objectName += ":"; |
|
|
| |
// ATTN-RK-P2-20020510: Need to make hostname and namespace lower case? | // ATTN-RK-P2-20020510: Need to make hostname and namespace lower case? |
| |
ref._rep->_className.toLower(); |
String classNameLower = ref._rep->_className; |
|
classNameLower.toLower(); |
|
ref._rep->_className = classNameLower; |
| |
for (Uint32 i = 0, n = ref._rep->_keyBindings.size(); i < n; i++) | for (Uint32 i = 0, n = ref._rep->_keyBindings.size(); i < n; i++) |
{ | { |
ref._rep->_keyBindings[i]._rep->_name.toLower(); |
String keyBindingNameLower = ref._rep->_keyBindings[i]._rep->_name; |
|
keyBindingNameLower.toLower(); |
|
ref._rep->_keyBindings[i]._rep->_name = keyBindingNameLower; |
} | } |
| |
return ref.toString(includeHost); | return ref.toString(includeHost); |
|
|
{ | { |
return | return |
String::equal(_rep->_host, x._rep->_host) && | String::equal(_rep->_host, x._rep->_host) && |
CIMName::equal(_rep->_nameSpace, x._rep->_nameSpace) && |
_rep->_nameSpace.equal(x._rep->_nameSpace) && |
CIMName::equal(_rep->_className, x._rep->_className) && |
_rep->_className.equal(x._rep->_className) && |
_rep->_keyBindings == x._rep->_keyBindings; | _rep->_keyBindings == x._rep->_keyBindings; |
} | } |
| |