本文整理汇总了C++中CIMValue::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMValue::toString方法的具体用法?C++ CIMValue::toString怎么用?C++ CIMValue::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMValue
的用法示例。
在下文中一共展示了CIMValue::toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lcp
static void
outputKEYVALUE(ostream& ostr, const CIMProperty& cp)
{
CIMDataType dtype = cp.getDataType();
String type;
if (dtype.isArrayType())
{
OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
"An array cannot be a KEY");
}
if (dtype.isReferenceType())
{
CIMProperty lcp(cp);
// This is sort of a bad thing to do, basically we are taking advantage
// of a side effect of setDataType. If the type isn't correct then
// the value will be cast to the correct type. This is to work around
// a problem that may happen if a provider writer sets the value of a
// reference property to a String instead of an CIMObjectPath.
// If the value is a string, the xml that is output will be malformed,
// and the client will throw an exception.
lcp.setDataType(lcp.getDataType());
CIMtoXML(lcp.getValue(), ostr);
return;
}
//
// Regular key value
switch (dtype.getType())
{
case CIMDataType::CHAR16:
case CIMDataType::DATETIME:
case CIMDataType::STRING:
type = "string";
break;
case CIMDataType::BOOLEAN:
type = "boolean";
break;
default:
type = "numeric";
}
CIMValue keyValue = cp.getValue();
if (!keyValue)
{
OW_THROWCIMMSG(CIMException::FAILED, "No key value");
}
ostr
<< "<KEYVALUE VALUETYPE=\""
<< type
<< "\">"
<< XMLEscape(keyValue.toString())
<< "</KEYVALUE>";
}
示例2: _getProperty
void _getProperty(CIMClient & client)
{
try
{
value = client.getProperty(
SOURCE_NAMESPACE,
objectNames[0],
CIMName("FileSize"));
if (verbose)
{
PEGASUS_STD (cout) << "+++++ getProperty completed successfully, "
<< "FileSize is: " << value.toString()
<< PEGASUS_STD (endl);
}
}
catch (Exception & e)
{
PEGASUS_STD (cerr) << "getProperty failed: " << e.getMessage ()
<< PEGASUS_STD (endl);
exit (-1);
}
}
示例3: TypeMismatchException
CIMKeyBinding::CIMKeyBinding(const CIMName& name, const CIMValue& value)
{
if (value.isArray())
{
throw TypeMismatchException();
}
String kbValue = value.toString();
Type kbType;
switch (value.getType())
{
case CIMTYPE_BOOLEAN:
kbType = BOOLEAN;
break;
case CIMTYPE_CHAR16:
case CIMTYPE_STRING:
case CIMTYPE_DATETIME:
kbType = STRING;
break;
case CIMTYPE_REFERENCE:
kbType = REFERENCE;
break;
// case CIMTYPE_REAL32:
// case CIMTYPE_REAL64:
case CIMTYPE_OBJECT:
case CIMTYPE_INSTANCE:
// From PEP 194: EmbeddedObjects cannot be keys.
throw TypeMismatchException();
break;
default:
kbType = NUMERIC;
break;
}
_rep = new CIMKeyBindingRep(name, kbValue, kbType);
}
示例4: _applyProjection
Boolean _applyProjection(QueryExpression& qe,
Array<CIMInstance>& _instances,
String testOption,
String lang)
{
if(testOption == String::EMPTY || testOption == "2")
{
cout << endl << lang << " ========Apply Projection Results========" << endl;
cout << qe.getQuery() << endl;
for(Uint32 j = 0; j < _instances.size(); j++)
{
cout << "Instance of class " << _instances[j].getClassName().getString() << endl;
try
{
CIMInstance projInst = _instances[j].clone();
Boolean gotPropExc = false;
try
{
qe.applyProjection(projInst, false);
}
catch (QueryRuntimePropertyException & qrpe)
{
// Got a missing property exception.
cout << "-----" << qrpe.getMessage() << endl;
gotPropExc = true;
}
if (gotPropExc)
{
// Got a missing property exception.
// Try again, allowing missing properties.
// Need to use a cloned instance because the original instance
// was partially projected.
cout << "Instance of class " << _instances[j].getClassName().getString()
<< ". Allow missing properties." << endl;
projInst = _instances[j].clone();
qe.applyProjection(projInst, true);
}
Uint32 cnt = projInst.getPropertyCount();
if (cnt == 0)
{
cout << "-----No properties left after projection" << endl;
}
if (cnt > 10)
{
// If more than 10 props, just print the count to keep
// the output file short
cout << "Instance has " << cnt << " properties" << endl;
}
else
{
for (Uint32 n = 0; n < cnt; n++)
{
CIMProperty prop = projInst.getProperty(n);
CIMValue val = prop.getValue();
cout << "-----Prop #" << n << " Name = " << prop.getName().getString();
if (val.isNull())
{
cout << " Value = NULL" << endl;
}
else
{
cout << " Value = " << val.toString() << endl;
}
}
}
}
catch(Exception& e) {
cout << "-----" << e.getMessage() << endl;
}
catch(...) {
cout << "Unknown Exception" << endl;
}
}
}
return true;
}
示例5: _getIndPropertyValue
String IndicationFormatter::_getIndPropertyValue(
const String & specifiedPropertyName,
const String & arrayIndexStr,
const CIMInstance & indication,
const ContentLanguages & contentLangs)
{
PEG_METHOD_ENTER (TRC_IND_FORMATTER,
"IndicationFormatter::_getIndPropertyValue");
CIMInstance indicationInstance = indication.clone();
String propertyName;
Boolean canLocalize = false;
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
Locale locale;
canLocalize = _canLocalize(contentLangs, locale);
#endif
for (Uint32 i=0; i < indicationInstance.getPropertyCount(); i++)
{
CIMProperty property = indicationInstance.getProperty(i);
propertyName = property.getName().getString();
// get specified property value
if (String::equalNoCase(propertyName, specifiedPropertyName))
{
CIMValue propertyValue = property.getValue();
Boolean valueIsNull = propertyValue.isNull();
CIMType type = propertyValue.getType();
if (!valueIsNull)
{
Boolean isArray = propertyValue.isArray();
if (isArray)
{
PEG_METHOD_EXIT();
return (_getArrayValues(propertyValue, arrayIndexStr,
contentLangs));
}
else // value is not an array
{
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
if (canLocalize)
{
if (type == CIMTYPE_DATETIME)
{
CIMDateTime dateTimeValue;
propertyValue.get(dateTimeValue);
PEG_METHOD_EXIT();
return(_localizeDateTime(dateTimeValue, locale));
}
else if (type == CIMTYPE_BOOLEAN)
{
Boolean booleanValue;
propertyValue.get(booleanValue);
PEG_METHOD_EXIT();
return(_localizeBooleanStr(booleanValue, locale));
}
else
{
PEG_METHOD_EXIT();
return (propertyValue.toString());
}
}
else
{
if (type == CIMTYPE_BOOLEAN)
{
PEG_METHOD_EXIT();
return (_getBooleanStr(propertyValue));
}
else
{
PEG_METHOD_EXIT();
return (propertyValue.toString());
}
}
#else
if (type == CIMTYPE_BOOLEAN)
{
PEG_METHOD_EXIT();
return (_getBooleanStr(propertyValue));
}
else
{
PEG_METHOD_EXIT();
return (propertyValue.toString());
}
#endif
}
}
else // value is NULL
{
PEG_METHOD_EXIT();
return ("NULL");
}
//.........这里部分代码省略.........
示例6: _formatDefaultIndicationText
String IndicationFormatter::_formatDefaultIndicationText(
const CIMInstance & indication,
const ContentLanguages & contentLangs)
{
PEG_METHOD_ENTER (TRC_IND_FORMATTER,
"IndicationFormatter::_formatDefaultIndicationText");
CIMInstance indicationInstance = indication.clone();
String propertyName;
String indicationStr;
Uint32 propertyCount = indicationInstance.getPropertyCount();
indicationStr.append("Indication (default format):");
Boolean canLocalize = false;
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
Locale locale;
canLocalize = _canLocalize(contentLangs, locale);
#endif
for (Uint32 i=0; i < propertyCount; i++)
{
CIMProperty property = indicationInstance.getProperty(i);
propertyName = property.getName().getString();
CIMValue propertyValue = property.getValue();
Boolean valueIsNull = propertyValue.isNull();
Boolean isArray = propertyValue.isArray();
indicationStr.append(propertyName);
indicationStr.append(" = ");
CIMType type = propertyValue.getType();
if (!valueIsNull)
{
if (isArray)
{
indicationStr.append(_getArrayValues(propertyValue, "",
contentLangs));
}
else // value is not an array
{
#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU)
if (canLocalize)
{
if (type == CIMTYPE_DATETIME)
{
CIMDateTime dateTimeValue;
propertyValue.get(dateTimeValue);
indicationStr.append(_localizeDateTime(dateTimeValue,
locale));
}
else if (type == CIMTYPE_BOOLEAN)
{
Boolean booleanValue;
propertyValue.get(booleanValue);
indicationStr.append(_localizeBooleanStr(booleanValue,
locale));
}
else
{
indicationStr.append(propertyValue.toString());
}
}
else
{
if (type == CIMTYPE_BOOLEAN)
{
indicationStr.append(_getBooleanStr(propertyValue));
}
else
{
indicationStr.append(propertyValue.toString());
}
}
#else
if (type == CIMTYPE_BOOLEAN)
{
indicationStr.append(_getBooleanStr(propertyValue));
}
else
{
indicationStr.append(propertyValue.toString());
}
#endif
}
}
else
{
indicationStr.append("NULL");
}
if (i < propertyCount -1)
{
indicationStr.append(", ");
}
propertyName.clear();
}
//.........这里部分代码省略.........
示例7: lns
bool
SimpleAuthorizer2::checkAccess(const String& opType, const String& ns,
const ServiceEnvironmentIFCRef& env, OperationContext& context)
{
OW_ASSERT(opType == ACCESS_READ || opType == ACCESS_WRITE
|| opType == ACCESS_READWRITE);
UserInfo userInfo = context.getUserInfo();
if (userInfo.getInternal())
{
return true;
}
CIMOMHandleIFCRef lch = env->getCIMOMHandle(context,
ServiceEnvironmentIFC::E_USE_PROVIDERS);
LoggerRef lgr = env->getLogger(COMPONENT_NAME);
if (!userInfo.getUserName().empty())
{
String superUser =
env->getConfigItem(ConfigOpts::ACL_SUPERUSER_opt);
if (superUser.equalsIgnoreCase(userInfo.getUserName()))
{
OW_LOG_DEBUG(lgr, "User is SuperUser: checkAccess returning.");
return true;
}
}
String lns(ns);
while (lns.startsWith('/'))
{
lns = lns.substring(1);
}
lns.toLowerCase();
for (;;)
{
if (!userInfo.getUserName().empty())
{
try
{
CIMClass cc = lch->getClass("root/security",
"OpenWBEM_UserACL", E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS,
E_INCLUDE_CLASS_ORIGIN, NULL);
}
catch(CIMException&)
{
OW_LOG_DEBUG(lgr, "OpenWBEM_UserACL class non-existent in"
" /root/security. ACLs disabled");
return true;
}
CIMObjectPath cop("OpenWBEM_UserACL");
cop.setKeyValue("username", CIMValue(userInfo.getUserName()));
cop.setKeyValue("nspace", CIMValue(lns));
CIMInstance ci(CIMNULL);
try
{
ci = lch->getInstance("root/security", cop,
E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS,
E_INCLUDE_CLASS_ORIGIN, NULL);
}
catch(const CIMException&)
{
ci.setNull();
}
if (ci)
{
String capability;
CIMProperty capabilityProp = ci.getProperty("capability");
if (capabilityProp)
{
CIMValue cv = capabilityProp.getValue();
if (cv)
{
capability = cv.toString();
}
}
capability.toLowerCase();
if (opType.length() == 1)
{
if (capability.indexOf(opType) == String::npos)
{
// Access to namespace denied for user
OW_THROWCIM(CIMException::ACCESS_DENIED);
}
}
else
{
if (!capability.equals("rw") && !capability.equals("wr"))
{
// Access to namespace denied for user
OW_THROWCIM(CIMException::ACCESS_DENIED);
}
}
// Access to namespace granted for user
return true;
}
//.........这里部分代码省略.........
示例8: CIMtoXML
//.........这里部分代码省略.........
break;
}
case CIMDataType::STRING:
{
StringArray a;
cv.get(a);
raToXmlSA(out, a);
break;
}
case CIMDataType::DATETIME:
{
CIMDateTimeArray a;
cv.get(a);
raToXml(out, a);
break;
}
case CIMDataType::REFERENCE:
{
CIMObjectPathArray a;
cv.get(a);
raToXmlCOP(out, a);
break;
}
case CIMDataType::EMBEDDEDCLASS:
{
CIMClassArray ca;
cv.get(ca);
StringArray sa;
for (size_t i = 0; i < ca.size(); ++i)
{
OStringStream ss;
CIMtoXML(ca[i], ss);
sa.push_back(ss.toString());
}
raToXmlSA(out, sa);
break;
}
case CIMDataType::EMBEDDEDINSTANCE:
{
CIMInstanceArray ia;
cv.get(ia);
StringArray sa;
for (size_t i = 0; i < ia.size(); ++i)
{
OStringStream ss;
CIMInstancetoXML(ia[i],ss);
sa.push_back(ss.toString());
}
raToXmlSA(out, sa);
break;
}
default:
OW_ASSERT(0);
}
}
else if (cv.getType() == CIMDataType::REFERENCE)
{
out << "<VALUE.REFERENCE>";
CIMObjectPath a(CIMNULL);
cv.get(a);
if (a.getFullNameSpace().isLocal())
{
if (a.getNameSpace().empty())
{