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


C++ CIMValue::getType方法代码示例

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


在下文中一共展示了CIMValue::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: equal

Boolean CIMKeyBinding::equal(CIMValue value)
{
    if (value.isArray())
    {
        return false;
    }

    CIMValue kbValue;

    try
    {
        switch (value.getType())
        {
        case CIMTYPE_CHAR16:
            if (getType() != STRING) return false;
            kbValue.set(getValue()[0]);
            break;
        case CIMTYPE_DATETIME:
            if (getType() != STRING) return false;
            kbValue.set(CIMDateTime(getValue()));
            break;
        case CIMTYPE_STRING:
            if (getType() != STRING) return false;
            kbValue.set(getValue());
            break;
        case CIMTYPE_REFERENCE:
            if (getType() != REFERENCE) return false;
            kbValue.set(CIMObjectPath(getValue()));
            break;
        case CIMTYPE_BOOLEAN:
            if (getType() != BOOLEAN) return false;
            kbValue = XmlReader::stringToValue(0, getValue().getCString(),
                                               value.getType());
            break;
//      case CIMTYPE_REAL32:
//      case CIMTYPE_REAL64:
        case CIMTYPE_OBJECT:
        case CIMTYPE_INSTANCE:
            // From PEP 194: EmbeddedObjects cannot be keys.
            return false;
        default:  // Numerics
            if (getType() != NUMERIC) return false;
            kbValue = XmlReader::stringToValue(0, getValue().getCString(),
                                               value.getType());
            break;
        }
    }
    catch (Exception&)
    {
        return false;
    }

    return value.equal(kbValue);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:54,代码来源:CIMObjectPath.cpp

示例2: mbGetProperty

    static CMPIData mbGetProperty(
        const CMPIBroker *mb,
        const CMPIContext *ctx,
        const CMPIObjectPath *cop,
        const char *name,
        CMPIStatus *rc)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbGetProperty()");
        mb = CM_BROKER;
        CMPIData data = {0,CMPI_nullValue,{0}};

        SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
        CIMObjectPath qop;
        scmoObjPath->getCIMObjectPath(qop);

        try
        {
            CIMValue v = CM_CIMOM(mb)->getProperty(
                *CM_Context(ctx),
                SCMO_ObjectPath(cop)->getNameSpace(),
                qop,
                String(name));
            CIMType vType = v.getType();
            CMPIType t = type2CMPIType(vType,v.isArray());
            value2CMPIData(v,t,&data);
            CMSetStatus(rc,CMPI_RC_OK);
        }
        HandlerCatchSetStatus(rc, data);

        PEG_METHOD_EXIT();
        return data; // "data" will be valid data or nullValue (in error case)
    }
开发者ID:rdobson,项目名称:openpegasus,代码行数:34,代码来源:CMPI_Broker.cpp

示例3: _checkStringValue

void _checkStringValue (CIMValue & theValue,
    const String & value,
    Boolean null = false)
{
    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_STRING);
    PEGASUS_TEST_ASSERT (!theValue.isArray ());
    if (null)
    {
        PEGASUS_TEST_ASSERT (theValue.isNull ());
    }
    else
    {
        PEGASUS_TEST_ASSERT (!theValue.isNull ());
        String result;
        theValue.get (result);

        if (verbose)
        {
            if (result != value)
            {
                cerr << "Property value comparison failed.  ";
                cerr << "Expected " << value << "; ";
                cerr << "Actual property value was " << result << "." << endl;
            }
        }

        PEGASUS_TEST_ASSERT (result == value);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:29,代码来源:TestCMPIBroker.cpp

示例4: _getKeyValue

void _getKeyValue (
    const CIMInstance& namespaceInstance,
    CIMNamespaceName& childNamespaceName,
    Boolean& isRelativeName)

{
    //Validate key property

    Uint32 pos;
    CIMValue propertyValue;

    // [Key, MaxLen (256), Description (
    //       "A string that uniquely identifies the Namespace "
    //       "within the ObjectManager.") ]
    // string Name;

    pos = namespaceInstance.findProperty(NAMESPACE_PROPERTYNAME);
    if (pos == PEG_NOT_FOUND)
    {
        throw CIMPropertyNotFoundException
        (NAMESPACE_PROPERTYNAME.getString());
    }

    propertyValue = namespaceInstance.getProperty(pos).getValue();
    if (propertyValue.getType() != CIMTYPE_STRING)
    {
        //l10n
        //throw CIMInvalidParameterException("Invalid type for property: "
        //+ NAMESPACE_PROPERTYNAME.getString());
        throw CIMInvalidParameterException(MessageLoaderParms(
                                               "ControlProviders.NamespaceProvider.NamespaceProvider.INVALID_TYPE_FOR_PROPERTY",
                                               "Invalid type for property: $0",
                                               NAMESPACE_PROPERTYNAME.getString()));
    }

    String cnsName;
    propertyValue.get(cnsName);
    if (cnsName == String::EMPTY)
    {
        childNamespaceName = CIMNamespaceName();
    }
    else
    {
        childNamespaceName = CIMNamespaceName(cnsName);
    }

    isRelativeName = !(childNamespaceName.isNull());

}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:49,代码来源:NamespaceProvider.cpp

示例5: UninitializedObjectException

CIMPropertyRep::CIMPropertyRep(
    const CIMName& name,
    const CIMValue& value,
    Uint32 arraySize,
    const CIMName& referenceClassName,
    const CIMName& classOrigin,
    Boolean propagated)
    :
    _name(name), _value(value), _arraySize(arraySize),
    _referenceClassName(referenceClassName), _classOrigin(classOrigin),
    _propagated(propagated), _refCounter(1), _ownerCount(0)
{
    // ensure name is not null
    if (name.isNull())
    {
        throw UninitializedObjectException();
    }

    // Set the CIM name tag.
    _nameTag = generateCIMNameTag(_name);

    if ((arraySize != 0) &&
        (!value.isArray() || value.getArraySize() != arraySize))
    {
        throw TypeMismatchException();
    }

    // A CIM Property may not be of reference array type
    if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))
    {
        throw TypeMismatchException();
    }

    // if referenceClassName exists, must be CIMType REFERENCE.
    if (!referenceClassName.isNull())
    {
        if (_value.getType() != CIMTYPE_REFERENCE)
        {
            throw TypeMismatchException();
        }
    }

    // Can a property be of reference type with a null referenceClassName?
    // The DMTF says yes if it is a property of an instance; no if it is a
    // property of a class.  We'll allow it here, but check in the CIMClass
    // addProperty() method.
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:47,代码来源:CIMPropertyRep.cpp

示例6: setValue

void CIMPropertyRep::setValue(const CIMValue& value)
{
    // CIMType of value is immutable:

    if (!value.typeCompatible(_value))
        throw TypeMismatchException();

    if (_arraySize && _arraySize != value.getArraySize())
        throw TypeMismatchException();

    // A CIM Property may not be of reference array type
    if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))
    {
        throw TypeMismatchException();
    }

    _value = value;
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:18,代码来源:CIMPropertyRep.cpp

示例7: mbInvokeMethod

    static CMPIData mbInvokeMethod(
        const CMPIBroker *mb,
        const CMPIContext *ctx,
        const CMPIObjectPath *cop,
        const char *method,
        const CMPIArgs *in,
        CMPIArgs *out,
        CMPIStatus *rc)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbInvokeMethod()");
        CMPIData data = {0,CMPI_nullValue,{0}};
        mb = CM_BROKER;


        SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
        CIMObjectPath qop;
        try
        {
            scmoObjPath->getCIMObjectPath(qop);

            CIMValue v = CM_CIMOM(mb)->invokeMethod(
                *CM_Context(ctx),
                SCMO_ObjectPath(cop)->getNameSpace(),
                qop,
                method ? String(method) : String::EMPTY,
                *CM_Args(in),
                *CM_Args(out));

            CIMType vType=v.getType();
            CMPIType t = type2CMPIType(vType,v.isArray());
            value2CMPIData(v,t,&data);

            if (rc)
            {
                CMSetStatus(rc,CMPI_RC_OK);
            }
        }
        HandlerCatchSetStatus(rc, data);

        PEG_METHOD_EXIT();
        return data; // "data" will be valid data or nullValue (in error case)
    }
开发者ID:rdobson,项目名称:openpegasus,代码行数:44,代码来源:CMPI_Broker.cpp

示例8: _testDeliveryRetryIntervalValue

void _testDeliveryRetryIntervalValue(
    CIMInstance& instance)
{
    CIMValue value =
        instance.getProperty(
            instance.findProperty(
                _PROPERTY_DELIVERYRETRYINTERVAL)).getValue();
    if (value.getType() == CIMTYPE_UINT64)
    {
        // CIM Schema 2.17 experimental class
        PEGASUS_TEST_ASSERT(
            Uint64(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE) == value);
    }
    else
    {
        // CIM Schema 2.22 and up
        PEGASUS_TEST_ASSERT(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE == value);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:19,代码来源:Configuration.cpp

示例9: _testSubscriptionRemovalIntervalValue

void _testSubscriptionRemovalIntervalValue(
    CIMInstance& instance)
{
    CIMValue value =
        instance.getProperty(
            instance.findProperty(
                _PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL)).getValue();
    if (value.getType() == CIMTYPE_UINT64)
    {
        // CIM Schema 2.17 experimental class
        PEGASUS_TEST_ASSERT(
            Uint64(_PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL_VALUE) == value);
    }
    else
    {
        // CIM Schema 2.22 and up
        PEGASUS_TEST_ASSERT(
            _PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL_VALUE == value);
    }
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:20,代码来源:Configuration.cpp

示例10: _checkUint32Value

void _checkUint32Value (CIMValue & theValue, Uint32 value)
{
    PEGASUS_TEST_ASSERT (theValue.getType () == CIMTYPE_UINT32);
    PEGASUS_TEST_ASSERT (!theValue.isArray ());
    PEGASUS_TEST_ASSERT (!theValue.isNull ());

    Uint32 result;
    theValue.get (result);

    if (verbose)
    {
        if (result != value)
        {
            cerr << "Property value comparison failed.  ";
            cerr << "Expected " << value << "; ";
            cerr << "Actual property value was " << result << "." << endl;
        }
    }

    PEGASUS_TEST_ASSERT (result == value);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:21,代码来源:TestCMPIBroker.cpp

示例11: 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);
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:37,代码来源:CIMObjectPath.cpp

示例12: 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

示例13: CIMtoXML

void CIMtoXML(CIMValue const& cv, ostream& out)
{
	if (!cv)
	{
		OW_THROWCIMMSG(CIMException::FAILED, "CIM value is NULL");
	}
	if (cv.isArray())
	{
		switch (cv.getType())
		{
			case CIMDataType::BOOLEAN:
			{
				BoolArray a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::UINT8:
			{
				UInt8Array a;
				cv.get(a);
				raToXmlNumeric(out, a);
				break;
			}
			case CIMDataType::SINT8:
			{
				Int8Array a;
				cv.get(a);
				raToXmlNumeric(out, a);
				break;
			}
			// ATTN: UTF8
			case CIMDataType::CHAR16:
			{
				Char16Array a;
				cv.get(a);
				raToXmlChar16(out, a);
				break;
			}
			case CIMDataType::UINT16:
			{
				UInt16Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::SINT16:
			{
				Int16Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::UINT32:
			{
				UInt32Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::SINT32:
			{
				Int32Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::UINT64:
			{
				UInt64Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::SINT64:
			{
				Int64Array a;
				cv.get(a);
				raToXml(out, a);
				break;
			}
			case CIMDataType::REAL32:
			{
				Real32Array a;
				cv.get(a);
				realArrayToXml(out, a);
				break;
			}
			case CIMDataType::REAL64:
			{
				Real64Array a;
				cv.get(a);
				realArrayToXml(out, a);
				break;
			}
			case CIMDataType::STRING:
			{
				StringArray a;
				cv.get(a);
				raToXmlSA(out, a);
//.........这里部分代码省略.........
开发者ID:kkaempf,项目名称:openwbem,代码行数:101,代码来源:OW_CIMtoXML.cpp

示例14: CIMDataType

void
CIMtoXML(CIMQualifier const& cq, ostream& ostr)
{
	CIMFlavor fv;
	
	if (cq.getName().empty())
	{
		OW_THROWCIMMSG(CIMException::FAILED, "qualifier must have a name");
	}
	CIMValue dv = cq.getDefaults().getDefaultValue();
	CIMDataType dt = cq.getDefaults().getDataType();
	CIMValue cv = cq.getValue();
	if (!cv)
	{
		cv = dv;
	}
	if (cv)
	{
		if (cv.isArray())
		{
			dt = CIMDataType(cv.getType(),cv.getArraySize());
		}
		else
		{
			dt = CIMDataType(cv.getType());
		}
	}
	OW_ASSERT(dt);
	ostr
		<< "<QUALIFIER NAME=\""
		<< cq.getName()
		<< "\" TYPE=\"";
	CIMtoXML(dt,ostr);
	ostr << "\" ";
	if (cq.getPropagated())
	{
		ostr << "PROPAGATED=\"true\" ";
	}
	//
	// Create flavors
	//
	fv = CIMFlavor(CIMFlavor::ENABLEOVERRIDE);
	if (cq.hasFlavor(fv))
	{
		//
		// Not needed, because OVERRIDABLE defaults to true!
	}
	else
	{
		fv = CIMFlavor(CIMFlavor::DISABLEOVERRIDE);
		if (cq.hasFlavor(fv))
		{
			CIMtoXML(fv, ostr);
			ostr <<  "=\"false\" ";
		}
	}
	fv = CIMFlavor(CIMFlavor::TOSUBCLASS);
	if (cq.hasFlavor(fv))
	{
		//
		// Not needed, because TOSUBCLASS defaults to true!
	}
	else
	{
		fv = CIMFlavor(CIMFlavor::RESTRICTED);
		if (cq.hasFlavor(fv))
		{
			CIMtoXML(fv, ostr);
			ostr <<  "=\"false\" ";
		}
	}
	// This is a bug in the spec, but we still support it for backward compatibility.
	//fv = CIMFlavor(CIMFlavor::TOINSTANCE);
	//if (cq.hasFlavor(fv))
	//{
	//	CIMtoXML(fv, ostr);
	//	ostr << "=\"true\" ";
	//}
	//else
	//{
		//
		// Not needed, because TOINSTANCE defaults to false!
	//}
	fv = CIMFlavor(CIMFlavor::TRANSLATE);
	if (cq.hasFlavor(fv))
	{
		CIMtoXML(fv, ostr);
		ostr << "=\"true\" ";
	}
	else
	{
		//
		// Not needed, because TRANSLATABLE defaults to false!
	}

	String lang = cq.getLanguage();
	if (!lang.empty())
	{
		ostr << " xml:lang=\"";
		ostr << lang;
//.........这里部分代码省略.........
开发者ID:kkaempf,项目名称:openwbem,代码行数:101,代码来源:OW_CIMtoXML.cpp

示例15: _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");
            }

//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:IndicationFormatter.cpp


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