本文整理汇总了C++中CIMValue::set方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMValue::set方法的具体用法?C++ CIMValue::set怎么用?C++ CIMValue::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMValue
的用法示例。
在下文中一共展示了CIMValue::set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: value2CIMValue
//.........这里部分代码省略.........
else
if( aType == CMPI_charsptr )
{
CopyCharsptrToStringArray(String,chars)
}
else
if( aType == CMPI_string )
{
CopyToStringArray(String,string->hdl)
}
// Checks for Unsigned Integers
else
if( (aType & (CMPI_UINT|CMPI_SINT))==CMPI_UINT )
{
switch( aType )
{
case CMPI_uint32:
CopyToArray(Uint32,uint32);
break;
case CMPI_uint16:
CopyToArray(Uint16,uint16);
break;
case CMPI_uint8:
CopyToArray(Uint8,uint8);
break;
case CMPI_uint64:
CopyToArray(Uint64,uint64);
break;
default: ;
}
}
else
{
switch( aType )
{
case CMPI_ref:
{
Array<CIMObjectPath> arCIMObjectPath(aSize);
ArrayIterator<CIMObjectPath> iterator(arCIMObjectPath);
for (int i=0; i<aSize; i++)
{
SCMOInstance* scmoInst =
(SCMOInstance*)aData[i].value.ref->hdl;
scmoInst->getCIMObjectPath(iterator[i]);
}
v.set(arCIMObjectPath);
}
break;
case CMPI_dateTime:
CopyToEncArray(CIMDateTime,dateTime);
break;
case CMPI_instance:
{
Array<CIMObject> arCIMInstance(aSize);
ArrayIterator<CIMObject> iterator(arCIMInstance);
for (int i=0; i<aSize; i++)
{
SCMOInstance* scmoInst =
(SCMOInstance*)aData[i].value.inst->hdl;
CIMInstance inst;
scmoInst->getCIMInstance(inst);
CIMObject obj(inst);
iterator[i]=obj;
}
v.set(arCIMInstance);
}
break;
case CMPI_boolean:
CopyToArray(Boolean,boolean);
break;
case CMPI_char16:
CopyToArray(Char16,char16);
break;
case CMPI_real32:
CopyToArray(Real32,real32);
break;
case CMPI_real64:
CopyToArray(Real64,real64);
break;
default:
if( rc )
{
*rc=CMPI_RC_ERR_NOT_SUPPORTED;
}
}
}
return CIMValue(v);
} // end of array processing
//Start of non - array types processing
else
if( type == CMPI_chars )
示例3: testEmbeddedValueArray
void testEmbeddedValueArray(const CIMInstance & startInstance,
const CIMNamespaceName & NAMESPACE,
SimpleDeclContext * context)
{
CIMInstance instance1(startInstance.clone());
// Test an array of CIMObjects that are CIMInstances
CIMInstance instance2(CIMName ("MyClass"));
instance2.addQualifier(CIMQualifier(CIMName ("classcounter"), true));
instance2.addProperty(CIMProperty(CIMName ("message"), String("Adios")));
Resolver::resolveInstance (instance2, context, NAMESPACE, true);
CIMInstance instance3(CIMName ("MyClass"));
instance3.addQualifier(CIMQualifier(CIMName ("classcounter"), false));
instance3.addProperty(CIMProperty(CIMName ("message"),
String("Au Revoir")));
Resolver::resolveInstance (instance3, context, NAMESPACE, true);
Array<EmbeddedType> arr16;
arr16.append(EmbeddedType(instance1));
arr16.append(EmbeddedType(instance2));
arr16.append(EmbeddedType(instance3));
test02(arr16);
// Specific test to verify the cloning of CIMObjects when set as and
// gotten from a CIMValue.
CIMValue v1array;
// Create CIMValue v1 of type CIMTYPE_OBJECT (ie. CIMObject)
v1array.set(arr16);
// Change the "count" property of arr16[1], and then verify
// that the CIMValue v1array, that was set from arr16, is
// not affected (ie. tests clone() on CIMValue::set() ).
Uint32 propIx = arr16[1].findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v2 = arr16[1].getProperty(propIx).getValue();
Uint32 propCount;
v2.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
arr16[1].removeProperty(propIx);
arr16[1].addProperty(CIMProperty(CIMName ("count"), Uint32(65))
.addQualifier(CIMQualifier(CIMName ("counter"), true))
.addQualifier(CIMQualifier(CIMName ("min"), String("0")))
.addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
Array<EmbeddedType> object2array;
v1array.get(object2array);
CIMInstance instance2a(object2array[1]);
propIx = instance2a.findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v3 = instance2a.getProperty(propIx).getValue();
v3.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
// Now change the "count" property of instance2a, which was obtained
// from a get of CIMValue v1array. Again, the underlying CIMValue should
// not be affected (ie. tests clone() on CIMValue::get() ).
instance2a.removeProperty(propIx);
instance2a.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
.addQualifier(CIMQualifier(CIMName ("counter"), true))
.addQualifier(CIMQualifier(CIMName ("min"), String("0")))
.addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
Array<EmbeddedType> object3array;
v1array.get(object3array);
CIMInstance instance2b(object3array[1]);
propIx = instance2b.findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v4 = instance2b.getProperty(propIx).getValue();
v4.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
// Specific test for setting value as a null CIMObject() (see bug 3373).
// Confirm that CIMValue() with an uninitialized CIMObject in the input
// array will throw exception.
arr16.append(EmbeddedType());
bool caught_exception = false;
try
{
CIMValue y(arr16);
}
catch(UninitializedObjectException&)
{
caught_exception = true;
}
PEGASUS_TEST_ASSERT (caught_exception == true);
// Confirm that set() with an uninitialized CIMObject in the input
// array will throw exception.
caught_exception = false;
try
{
CIMValue y;
y.set(arr16);
}
catch(UninitializedObjectException&)
{
caught_exception = true;
}
PEGASUS_TEST_ASSERT (caught_exception == true);
}
示例4: testEmbeddedValue
void testEmbeddedValue(const CIMInstance & instance)
{
CIMInstance instance1 = instance.clone();
// Specific test to verify the cloning of CIMObjects/CIMInstances when set
// and gotten from a CIMValue.
CIMValue v1;
// Create CIMValue v1 of type CIMTYPE_OBJECT/CIMTYPE_INSTANCE
v1.set(EmbeddedType(instance1));
// Change the "count" property of instance1, and then verify
// that the CIMValue v1, that was set from instance1, is
// not affected (ie. tests clone() on CIMValue::set() ).
Uint32 propIx = instance1.findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v2 = instance1.getProperty(propIx).getValue();
Uint32 propCount;
v2.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
instance1.removeProperty(propIx);
instance1.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
.addQualifier(CIMQualifier(CIMName ("counter"), true))
.addQualifier(CIMQualifier(CIMName ("min"), String("0")))
.addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
EmbeddedType object2;
v1.get(object2);
CIMInstance instance1a(object2);
propIx = instance1a.findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v3 = instance1a.getProperty(propIx).getValue();
v3.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
// Now change the "count" property of instance1a, which was obtained
// from a get of CIMValue v1. Again, the underlying CIMValue should
// not be affected (ie. tests clone() on CIMValue::get() ).
instance1a.removeProperty(propIx);
instance1a.addProperty(CIMProperty(CIMName ("count"), Uint32(65))
.addQualifier(CIMQualifier(CIMName ("counter"), true))
.addQualifier(CIMQualifier(CIMName ("min"), String("0")))
.addQualifier(CIMQualifier(CIMName ("max"), String("1"))));
EmbeddedType object3;
v1.get(object3);
CIMInstance instance1b(object3);
propIx = instance1b.findProperty(CIMName("count"));
PEGASUS_TEST_ASSERT(propIx != PEG_NOT_FOUND);
CIMValue v4 = instance1b.getProperty(propIx).getValue();
v4.get(propCount);
PEGASUS_TEST_ASSERT(propCount == 55);
// Specific test for setting value as a null CIMObject/CIMInstance
// (see bug 3373).
// Confirm that CIMValue() with an uninitialized CIMObject/CIMInstance will
// throw exception.
Boolean caught_exception = false;
try
{
EmbeddedType obj = EmbeddedType();
CIMValue y(obj);
}
catch(UninitializedObjectException&)
{
caught_exception = true;
}
PEGASUS_TEST_ASSERT (caught_exception == true);
// Confirm that set() with an uninitialized CIMObject/CIMInstance will
// throw exception.
caught_exception = false;
try
{
CIMValue y;
y.set(EmbeddedType());
}
catch(UninitializedObjectException&)
{
caught_exception = true;
}
PEGASUS_TEST_ASSERT (caught_exception == true);
}
示例5: initialize
void ComputerSystem::initialize(void)
{
// fills in the values of all properties that are not
// hardcoded (i.e., are obtained from the system) but not
// going to change dynamically (which is most, for this
// provider)
// _hostName
struct hostent *he;
char hn[PEGASUS_MAXHOSTNAMELEN];
// fill hn with what this system thinks is name
gethostname(hn,PEGASUS_MAXHOSTNAMELEN);
// find out what nameservices think is full name
if (he=gethostbyname(hn)) _hostName = he->h_name;
else _hostName = hn;
size_t bufSize;
// get serial number using confstr
bufSize = confstr(_CS_MACHINE_SERIAL, NULL, 0);
if (bufSize != 0)
{
char* serialNumber = new char[bufSize];
try
{
if (confstr(_CS_MACHINE_SERIAL, serialNumber, bufSize) != 0)
{
_serialNumber.set(String(serialNumber));
}
}
catch(...)
{
delete [] serialNumber;
throw;
}
delete [] serialNumber;
}
// get model using command
FILE *s = popen("/usr/bin/model","r");
if (s == 0) throw CIMOperationFailedException("/usr/bin/model: command not found");
char buf[100];
if (fgets(buf,100,s) == 0)
throw CIMOperationFailedException("/usr/bin/model: no output");
pclose(s);
_model = String(buf);
// get system UUID using confstr.
bufSize = confstr(_CS_MACHINE_IDENT, NULL, 0);
if (bufSize != 0)
{
char* uuid = new char[bufSize];
try
{
if (confstr(_CS_MACHINE_IDENT, uuid, bufSize) != 0)
{
_uuid.set(String(uuid));
}
}
catch(...)
{
delete [] uuid;
throw;
}
delete [] uuid;
}
// InstallDate
/*
A CIM date has the following form:
yyyymmddhhmmss.mmmmmmsutc
Where
yyyy = year (0-1999)
mm = month (1-12)
dd = day (1-31)
hh = hour (0-23)
mm = minute (0-59)
ss = second (0-59)
mmmmmm = microseconds.
s = '+' or '-' to represent the UTC sign.
utc = UTC offset (same as GMT offset).
*/
// creation date of /stand/vmunix
struct stat st;
// get get modification time of file
if (0 != stat("/stand/vmunix", &st))
throw CIMOperationFailedException("/stand/vmunix: can't access");
// convert to a usable format
struct tm tmBuffer;
struct tm *t = localtime_r(&st.st_mtime, &tmBuffer);
// convert to CIMDateTime format
char timstr[26];
sprintf(timstr,"%04d%02d%02d%02d%02d%02d.000000%c%03d",t->tm_year+1900,
t->tm_mon+1,
t->tm_mday,
t->tm_hour,
t->tm_min,
t->tm_sec,
//.........这里部分代码省略.........
示例6: main
int main(int argc, char** argv)
{
#ifdef IO
verbose = getenv("PEGASUS_TEST_VERBOSE");
if (verbose)
cout << "Test CIMValue. To turn off display, compile with IO undefined\n";
#endif
// Test the primitive CIMValue types with test01
test01(Boolean(true));
test01(Boolean(false));
test01(Char16('Z'));
test01(Uint8(77));
test01(Sint8(-77));
test01(Sint16(77));
test01(Uint16(-77));
test01(Sint32(77));
test01(Uint32(-77));
test01(Sint64(77));
test01(Uint64(-77));
test01(Real32(1.5));
test01(Real64(55.5));
test01(Uint64(123456789));
test01(Sint64(-123456789));
test01(String("Hello world"));
test01(CIMDateTime("19991224120000.000000+360"));
test01(CIMObjectPath("//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\""));
// Create and populate a declaration context:
const CIMNamespaceName NAMESPACE = CIMNamespaceName ("/zzz");
SimpleDeclContext* context = new SimpleDeclContext;
context->addQualifierDecl(
NAMESPACE, CIMQualifierDecl(CIMName ("counter"), false,
CIMScope::PROPERTY));
context->addQualifierDecl(
NAMESPACE, CIMQualifierDecl(CIMName ("classcounter"), false,
CIMScope::CLASS));
context->addQualifierDecl(
NAMESPACE, CIMQualifierDecl(CIMName ("min"), String(),
CIMScope::PROPERTY));
context->addQualifierDecl(
NAMESPACE, CIMQualifierDecl(CIMName ("max"), String(),
CIMScope::PROPERTY));
context->addQualifierDecl(NAMESPACE,
CIMQualifierDecl(CIMName ("Description"), String(),
CIMScope::PROPERTY));
CIMClass class1(CIMName ("MyClass"));
class1
.addProperty(CIMProperty(CIMName ("count"), Uint32(55))
.addQualifier(CIMQualifier(CIMName ("counter"), true))
.addQualifier(CIMQualifier(CIMName ("min"), String("0")))
.addQualifier(CIMQualifier(CIMName ("max"), String("1"))))
.addProperty(CIMProperty(CIMName ("message"), String("Hello"))
.addQualifier(CIMQualifier(CIMName ("description"),
String("My Message"))))
.addProperty(CIMProperty(CIMName ("ratio"), Real32(1.5)));
Resolver::resolveClass (class1, context, NAMESPACE);
context->addClass(NAMESPACE, class1);
// Test a CIMObject that is a CIMClass
test01(CIMObject(class1));
// Test a CIMObject that is a CIMInstance
CIMInstance instance1(CIMName ("MyClass"));
instance1.addQualifier(CIMQualifier(CIMName ("classcounter"), true));
instance1.addProperty(CIMProperty(CIMName ("message"), String("Goodbye")));
Resolver::resolveInstance (instance1, context, NAMESPACE, true);
test01(CIMObject(instance1));
// Specific test for setting value as a null CIMObject() (see bug 3373).
// Confirm that CIMValue() with an uninitialized CIMObject will throw exception.
Boolean caught_exception = false;
try
{
CIMObject obj = CIMObject();
CIMValue y(obj);
}
catch(UninitializedObjectException& e)
{
caught_exception = true;
}
assert (caught_exception == true);
// Confirm that set() with an uninitialized CIMObject will throw exception.
caught_exception = false;
try
{
CIMValue y;
y.set(CIMObject());
}
//.........这里部分代码省略.........