本文整理汇总了C++中OCRepresentation::isNULL方法的典型用法代码示例。如果您正苦于以下问题:C++ OCRepresentation::isNULL方法的具体用法?C++ OCRepresentation::isNULL怎么用?C++ OCRepresentation::isNULL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCRepresentation
的用法示例。
在下文中一共展示了OCRepresentation::isNULL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGD
/*
* Class: org_iotivity_base_OcRepresentation
* Method: isNull
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull
(JNIEnv *env, jobject thiz, jstring jAttributeKey)
{
LOGD("OcRepresentation_isNull");
if (!jAttributeKey)
{
ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
return false;
}
OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
if (!rep) return false;
std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
return static_cast<jboolean>(rep->isNULL(attributeKey));
}
示例2: printRepresentation
void printRepresentation(const OCRepresentation& rep)
{
// Check if attribute "name" exists, and then getValue
if(rep.hasAttribute("name"))
{
myGarage.m_name = rep.getValue<std::string>("name");
}
std::cout << "\tname: " << myGarage.m_name << std::endl;
// You can directly try to get the value. this function
// return false if there is no attribute "state"
if(!rep.getValue("state", myGarage.m_state))
{
std::cout << "Attribute state doesn't exist in the representation\n";
}
std::cout << "\tstate: " << myGarage.m_state << std::endl;
OCRepresentation rep2 = rep;
std::cout << "Number of attributes in rep2: "
<< rep2.numberOfAttributes() << std::endl;
if(rep2.erase("name"))
{
std::cout << "attribute: name, was removed successfully from rep2.\n";
}
std::cout << "Number of attributes in rep2: "
<< rep2.numberOfAttributes() << std::endl;
if(rep.isNULL("nullAttribute"))
{
std::cout << "\tnullAttribute is null." << std::endl;
}
else
{
std::cout << "\tnullAttribute is not null." << std::endl;
}
rep.getValue("light", myGarage.m_lightRep);
myGarage.m_lightRep.getValue("states", myGarage.m_lightStates);
myGarage.m_lightRep.getValue("powers", myGarage.m_lightPowers);
std::cout << "\tlightRep: states: ";
int first = 1;
for(auto state: myGarage.m_lightStates)
{
if(first)
{
std::cout << state;
first = 0;
}
else
{
std::cout << "," << state;
}
}
std::cout << std::endl;
std::cout << "\tlightRep: powers: ";
first = 1;
for(auto power: myGarage.m_lightPowers)
{
if(first)
{
std::cout << power;
first = 0;
}
else
{
std::cout << "," << power;
}
}
std::cout << std::endl;
// Get vector of representations
rep.getValue("reps", myGarage.m_reps);
// Client know that server is sending two representations
// and has key1 and key2 repsectively
std::cout << "\treps[0].key1: " << myGarage.m_reps[0].getValue<int>("key1") << std::endl;
std::cout << "\treps[0].key2: " << myGarage.m_reps[1].getValue<int>("key2") << std::endl;
std::cout << "\tjson: " << rep.getValue<std::string>("json") << std::endl;
}
示例3: printRepresentation
void printRepresentation(const OCRepresentation& rep)
{
// Check if attribute "name" exists, and then getValue
if(rep.hasAttribute("name"))
{
myGarage.m_name = rep["name"];
}
std::cout << "\tname: " << myGarage.m_name << std::endl;
// You can directly try to get the value. this function
// return false if there is no attribute "state"
if(!rep.getValue("state", myGarage.m_state))
{
std::cout << "Attribute state doesn't exist in the representation\n";
}
std::cout << "\tstate: " << myGarage.m_state << std::endl;
OCRepresentation rep2 = rep;
std::cout << "Number of attributes in rep2: "
<< rep2.numberOfAttributes() << std::endl;
if(rep2.erase("name"))
{
std::cout << "attribute: name, was removed successfully from rep2.\n";
}
std::cout << "Number of attributes in rep2: "
<< rep2.numberOfAttributes() << std::endl;
if(rep.isNULL("nullAttribute"))
{
std::cout << "\tnullAttribute is null." << std::endl;
}
else
{
std::cout << "\tnullAttribute is not null." << std::endl;
}
myGarage.m_lightRep = rep["light"];
myGarage.m_lightStates = myGarage.m_lightRep["states"];
myGarage.m_lightPowers = myGarage.m_lightRep["powers"];
std::cout << "\tlightRep: states: ";
int first = 1;
for(auto state: myGarage.m_lightStates)
{
if(first)
{
std::cout << state;
first = 0;
}
else
{
std::cout << "," << state;
}
}
std::cout << std::endl;
std::cout << "\tlightRep: powers: ";
first = 1;
for(auto power: myGarage.m_lightPowers)
{
if(first)
{
std::cout << power;
first = 0;
}
else
{
std::cout << "," << power;
}
}
std::cout << std::endl;
// Get vector of representations
myGarage.m_reps = rep["reps"];
int ct = 0;
for(auto& rep : myGarage.m_reps)
{
for(auto& attribute : rep)
{
std::cout<< "\treps["<<ct<<"]."<<attribute.attrname()<<":"
<< attribute.type()<<" with value " <<attribute.getValueToString() <<std::endl;
}
++ct;
}
std::cout << "\tjson: " << rep["json"] << std::endl;
myGarage.m_hingeStates = rep["hinges"];
std::cout<< "\tHinge parameter is type: " << rep["hinges"].type() << " with depth "<<
rep["hinges"].depth() << " and a base type of "<< rep["hinges"].base_type()<<std::endl;
//.........这里部分代码省略.........