当前位置: 首页>>代码示例>>C++>>正文


C++ CIMProperty::getDataType方法代码示例

本文整理汇总了C++中CIMProperty::getDataType方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMProperty::getDataType方法的具体用法?C++ CIMProperty::getDataType怎么用?C++ CIMProperty::getDataType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIMProperty的用法示例。


在下文中一共展示了CIMProperty::getDataType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>";
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:51,代码来源:OW_CIMtoXML.cpp

示例2: if

void
CIMtoXML(CIMProperty const& cp, ostream& ostr)
{
	bool isArray = false;
	bool isRef = false;
	if (cp.getName().empty())
	{
		OW_THROWCIMMSG(CIMException::FAILED, "property must have a name");
	}
	if (cp.getDataType())
	{
		isArray = cp.getDataType().isArrayType();
		isRef = cp.getDataType().isReferenceType();
		if (isArray)
		{
			ostr
				<<  "<PROPERTY.ARRAY NAME=\""
				<<  cp.getName()
				<< "\" TYPE=\"";
			CIMtoXML(cp.getDataType(), ostr);
			ostr << "\" ";
			if (cp.getDataType().getSize() != -1)
			{
				ostr
					<< "ARRAYSIZE=\""
					<< cp.getDataType().getSize()
					<< "\" ";
			}
		}
		else if (isRef)
		{
			ostr
				<< "<PROPERTY.REFERENCE NAME=\""
				<< cp.getName()
				<< "\" REFERENCECLASS=\""
				<< cp.getDataType().getRefClassName()
				<< "\" ";
		}
		else
		{
			ostr
				<< "<PROPERTY NAME=\""
				<< cp.getName()
				<< "\" TYPE=\"";
			CIMtoXML(cp.getDataType(), ostr);
			ostr << "\" ";
		}
	}
	else
	{
		String msg("Property ");
		msg += cp.getName();
		msg += " has no type defined";
		OW_THROWCIMMSG(CIMException::FAILED, msg.c_str());
	}
	if (!cp.getOriginClass().empty())
	{
		ostr
			<< "CLASSORIGIN=\""
			<< cp.getOriginClass()
			<< "\" ";
	}
	if (cp.getPropagated())
	{
		ostr << "PROPAGATED=\"true\" ";
	}
	
	CIMValue val = cp.getValue();
	if (cp.getDataType().isEmbeddedObjectType() || (val && val.getCIMDataType().isEmbeddedObjectType()))
	{
		ostr << "EmbeddedObject=\"object\" ";
	}

	ostr << '>';
	for (size_t i = 0; i < cp.getQualifiers().size(); i++)
	{
		CIMtoXML(cp.getQualifiers()[i], ostr);
	}

	if (val)
	{
		// if there isn't an EmbeddedObject qualifier on an embedded object, then output one.
		if (val.getType() == CIMDataType::EMBEDDEDINSTANCE || val.getType() == CIMDataType::EMBEDDEDCLASS)
		{
			if (!cp.getQualifier(CIMQualifier::CIM_QUAL_EMBEDDEDOBJECT))
			{
				CIMQualifier embeddedObject(CIMQualifier::CIM_QUAL_EMBEDDEDOBJECT);
				embeddedObject.setValue(CIMValue(true));
				CIMtoXML(embeddedObject, ostr);
			}
		}

		CIMtoXML(val, ostr);
	}
	if (isArray)
	{
		ostr << "</PROPERTY.ARRAY>";
	}
	else if (isRef)
	{
//.........这里部分代码省略.........
开发者ID:kkaempf,项目名称:openwbem,代码行数:101,代码来源:OW_CIMtoXML.cpp


注:本文中的CIMProperty::getDataType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。