本文整理汇总了C++中Any::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::empty方法的具体用法?C++ Any::empty怎么用?C++ Any::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Any
的用法示例。
在下文中一共展示了Any::empty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyPropertiesDict
void MenuBar::applyPropertiesDict(Color*color, const Dictionary&properties)
{
if(color == nullptr)
{
return;
}
Any r = properties.get("r");
Any g = properties.get("g");
Any b = properties.get("b");
Any a = properties.get("a");
if(!r.empty() && r.is<Number>())
{
color->r = r.as<Number>(false).asUnsignedChar();
}
if(!g.empty() && g.is<Number>())
{
color->g = g.as<Number>(false).asUnsignedChar();
}
if(!b.empty() && b.is<Number>())
{
color->b = b.as<Number>(false).asUnsignedChar();
}
if(!a.empty() && a.is<Number>())
{
color->a = a.as<Number>(false).asUnsignedChar();
}
}
示例2:
bool Any::operator == ( const Any& rhs ) const
{
if( (this == &rhs) || (empty() && rhs.empty( )))
return true;
if( empty() != rhs.empty() || type() != rhs.type( ))
return false;
return *content == *rhs.content;
}
示例3: testEmptyCopy
void AnyTest::testEmptyCopy()
{
const Any null;
Any copied = null, assigned;
assigned = null;
assert (null.empty());
assert (copied.empty());
assert (assigned.empty());
}
示例4: testDefaultCtor
void AnyTest::testDefaultCtor()
{
const Any value;
assert (value.empty());
assert (0 == AnyCast<int>(&value));
assert (value.type() == typeid(void));
}
示例5: testConvertingCtor
void AnyTest::testConvertingCtor()
{
std::string text = "test message";
Any value = text;
assert (!value.empty());
assert (value.type() == typeid(std::string));
assert (0 == AnyCast<int>(&value));
assert (0 != AnyCast<std::string>(&value));
assert (AnyCast<std::string>(value) == text);
assert (AnyCast<std::string>(&value) != &text);
}
示例6: testConvertingAssign
void AnyTest::testConvertingAssign()
{
std::string text = "test message";
Any value;
Any* assignResult = &(value = text);
assert (!value.empty());
assert (value.type() == typeid(std::string));
assert (0 == AnyCast<int>(&value));
assert (0 != AnyCast<std::string>(&value));
assert (AnyCast<std::string>(value) == text);
assert (AnyCast<std::string>(&value) != &text);
assert (assignResult == &value);
}
示例7: testSwap
void AnyTest::testSwap()
{
std::string text = "test message";
Any original = text, swapped;
std::string* originalPtr = AnyCast<std::string>(&original);
Any* swapResult = &original.swap(swapped);
assert (original.empty());
assert (!swapped.empty());
assert (swapped.type() == typeid(std::string));
assert (text == AnyCast<std::string>(swapped));
assert (0 != originalPtr);
#ifdef POCO_NO_SOO // pointers only match when heap-allocated
assert (originalPtr == AnyCast<std::string>(&swapped));
#endif
assert (swapResult == &original);
}
示例8: testInt
void AnyTest::testInt()
{
Any e;
assert (e.empty());
Any a = 13;
assert (a.type() == typeid(int));
int* i = AnyCast<int>(&a);
assert (*i == 13);
Any b = a;
assert (b.type() == typeid(int));
int *cpyI = AnyCast<int>(&b);
assert (*cpyI == *i);
*cpyI = 20;
assert (*cpyI != *i);
std::string* s = AnyCast<std::string>(&a);
assert (s == NULL);
int tmp = AnyCast<int>(a);
const Any c = a;
tmp = AnyCast<int>(a);
}
示例9: is_empty
bool is_empty(Any const& operand)
{
return operand.empty();
}