version 1.19, 2003/08/12 17:45:57
|
version 1.26, 2004/06/15 18:38:24
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2003//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
{ | { |
if (!legal(name)) | if (!legal(name)) |
{ | { |
// ATTN: Does this clean up String memory properly? |
|
throw InvalidNameException(name); | throw InvalidNameException(name); |
} | } |
} | } |
|
|
{ | { |
if (!legal(name)) | if (!legal(name)) |
{ | { |
// ATTN: Does this clean up String memory properly? |
|
throw InvalidNameException(name); | throw InvalidNameException(name); |
} | } |
} | } |
|
|
return *this; | return *this; |
} | } |
| |
#ifndef PEGASUS_REMOVE_DEPRECATED |
|
CIMName& CIMName::operator=(const char* name) |
|
{ |
|
cimName=name; |
|
return *this; |
|
} |
|
#endif |
|
|
|
const String& CIMName::getString() const | const String& CIMName::getString() const |
{ | { |
return cimName; | return cimName; |
} | } |
| |
#ifndef PEGASUS_REMOVE_DEPRECATED |
|
CIMName::operator String() const |
|
{ |
|
return cimName; |
|
} |
|
#endif |
|
|
|
Boolean CIMName::isNull() const | Boolean CIMName::isNull() const |
{ | { |
return (cimName.size() == 0); | return (cimName.size() == 0); |
|
|
Boolean CIMName::legal(const String& name) | Boolean CIMName::legal(const String& name) |
{ | { |
Uint32 length = name.size(); | Uint32 length = name.size(); |
Uint32 i = 0; |
Uint16 chkchr; |
|
|
| |
if (length == 0) | if (length == 0) |
return false; | return false; |
| |
CString temp = name.getCStringUTF8(); |
chkchr = name[0]; |
const char* UTF8name = temp; |
|
| |
char currentChar; |
// First character must be alphabetic or '_' if ASCII |
|
if(!( |
|
(chkchr == 0x005F) || |
|
((chkchr >= 0x0041) && (chkchr <= 0x005A)) || |
|
((chkchr >= 0x0061) && (chkchr <= 0x007A)) || |
|
((chkchr >= 0x0080) && (chkchr <= 0xFFEF)))) |
|
{ |
|
return false; |
|
} |
| |
while(i<length) |
// Remaining characters must be alphanumeric or '_' if ASCII |
|
for(Uint32 i = 1; i < length; ++i) |
|
{ |
|
chkchr = name[i]; |
|
if(!( |
|
(chkchr == 0x005F) || |
|
((chkchr >= 0x0041) && (chkchr <= 0x005A)) || |
|
((chkchr >= 0x0061) && (chkchr <= 0x007A)) || |
|
((chkchr >= 0x0080) && (chkchr <= 0xFFEF)) || |
|
((chkchr >= 0x0030) && (chkchr <= 0x0039)))) |
{ | { |
UTF8_NEXT(UTF8name,i,currentChar); |
|
if (!(String::isUTF8(&UTF8name[i]))) |
|
return false; | return false; |
} | } |
|
} |
| |
return true; | return true; |
} | } |
|
|
} | } |
| |
CIMNamespaceName::CIMNamespaceName(const String& name) | CIMNamespaceName::CIMNamespaceName(const String& name) |
: cimNamespaceName(name) |
|
{ |
|
if (!legal(name)) |
|
{ | { |
// ATTN: Does this clean up String memory properly? |
*this = name; |
throw InvalidNamespaceNameException(name); |
|
} |
|
} | } |
| |
CIMNamespaceName::CIMNamespaceName(const char* name) | CIMNamespaceName::CIMNamespaceName(const char* name) |
: cimNamespaceName(name) |
|
{ |
|
if (!legal(name)) |
|
{ | { |
// ATTN: Does this clean up String memory properly? |
*this = String(name); |
throw InvalidNamespaceNameException(name); |
|
} |
|
} | } |
| |
CIMNamespaceName& CIMNamespaceName::operator=(const CIMNamespaceName& name) | CIMNamespaceName& CIMNamespaceName::operator=(const CIMNamespaceName& name) |
|
|
{ | { |
throw InvalidNamespaceNameException(name); | throw InvalidNamespaceNameException(name); |
} | } |
cimNamespaceName=name; |
|
return *this; |
|
} |
|
| |
#ifndef PEGASUS_REMOVE_DEPRECATED |
if (name[0] == '/') |
CIMNamespaceName& CIMNamespaceName::operator=(const char* name) |
{ |
|
// Strip off the meaningless leading '/' |
|
cimNamespaceName=name.subString(1); |
|
} |
|
else |
{ | { |
cimNamespaceName=name; | cimNamespaceName=name; |
return *this; |
|
} | } |
#endif |
|
| |
const String& CIMNamespaceName::getString() const |
return *this; |
{ |
|
return cimNamespaceName; |
|
} | } |
| |
#ifndef PEGASUS_REMOVE_DEPRECATED |
const String& CIMNamespaceName::getString() const |
CIMNamespaceName::operator String() const |
|
{ | { |
return cimNamespaceName; | return cimNamespaceName; |
} | } |
#endif |
|
| |
Boolean CIMNamespaceName::isNull() const | Boolean CIMNamespaceName::isNull() const |
{ | { |
|
|
| |
Boolean CIMNamespaceName::legal(const String& name) | Boolean CIMNamespaceName::legal(const String& name) |
{ | { |
Uint32 i = 0; |
|
Uint32 length = name.size(); | Uint32 length = name.size(); |
if (length == 0) return true; // ATTN: Cheap hack! |
Uint32 index = 0; |
| |
if (length == 0) return true; // ATTN: Cheap hack! |
// Skip a leading '/' because the CIM specification is ambiguous |
|
if (name[0] == '/') |
|
{ |
|
index++; |
|
} |
| |
CString temp = name.getCStringUTF8(); |
Boolean moreElements = true; |
const char* UTF8name = temp; |
|
| |
char currentChar; |
// Check each namespace element (delimited by '/' characters) |
|
while (moreElements) |
|
{ |
|
moreElements = false; |
| |
while(i<length) |
if (index == length) |
{ | { |
UTF8_NEXT(UTF8name,i,currentChar); |
|
if (!(String::isUTF8(&UTF8name[i]))) |
|
return false; | return false; |
} | } |
| |
return true; |
Uint16 chkchr = name[index++]; |
|
|
// Alternate implementation |
|
#if 0 |
|
String temp; |
|
|
|
// check each namespace segment (delimited by '/') for correctness |
|
| |
for(Uint32 i = 0; i < name.size(); i += temp.size() + 1) |
// First character must be alphabetic or '_' if ASCII |
|
if(!( |
|
(chkchr == 0x005F) || |
|
((chkchr >= 0x0041) && (chkchr <= 0x005A)) || |
|
((chkchr >= 0x0061) && (chkchr <= 0x007A)) || |
|
((chkchr >= 0x0080) && (chkchr <= 0xFFEF)))) |
{ | { |
// isolate the segment beginning at i and ending at the first |
return false; |
// ocurrance of '/' after i or eos |
} |
| |
temp = name.subString(i, name.subString(i).find('/')); |
// Remaining characters must be alphanumeric or '_' if ASCII |
|
while (index < length) |
|
{ |
|
chkchr = name[index++]; |
| |
// check segment for correctness |
// A '/' indicates another namespace element follows |
|
if (chkchr == '/') |
|
{ |
|
moreElements = true; |
|
break; |
|
} |
| |
if (!CIMName::legal(temp)) |
if(!( |
|
(chkchr == 0x005F) || |
|
((chkchr >= 0x0041) && (chkchr <= 0x005A)) || |
|
((chkchr >= 0x0061) && (chkchr <= 0x007A)) || |
|
((chkchr >= 0x0080) && (chkchr <= 0xFFEF)) || |
|
((chkchr >= 0x0030) && (chkchr <= 0x0039)))) |
{ | { |
return false; | return false; |
} | } |
} | } |
|
} |
| |
return true; | return true; |
#endif |
|
} | } |
| |
Boolean CIMNamespaceName::equal(const CIMNamespaceName& name) const | Boolean CIMNamespaceName::equal(const CIMNamespaceName& name) const |