本文整理汇总了C++中Var::isInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ Var::isInteger方法的具体用法?C++ Var::isInteger怎么用?C++ Var::isInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Var
的用法示例。
在下文中一共展示了Var::isInteger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testNumberElement
void JSONTest::testNumberElement()
{
std::string json = "[ 1969 ]";
Parser parser;
Var result;
try
{
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(json);
result = handler.result();
}
catch(JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
assert(false);
}
assert(result.type() == typeid(Array::Ptr));
Array::Ptr array = result.extract<Array::Ptr>();
Var test = array->get(0);
assert(test.isInteger());
int value = test;
assert(value == 1969);
}
示例2: testNumberProperty
void JSONTest::testNumberProperty()
{
std::string json = "{ \"test\" : 1969 }";
Parser parser;
Var result;
try
{
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(json);
result = handler.result();
}
catch(JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
assert(false);
}
assert(result.type() == typeid(Object::Ptr));
Object::Ptr object = result.extract<Object::Ptr>();
Var test = object->get("test");
assert(test.isInteger());
int value = test;
assert(value == 1969);
}
示例3: testEmpty
void VarTest::testEmpty()
{
Var da;
assert (da.isEmpty());
assert (da.type() == typeid(void));
assert (!da.isArray());
assert (!da.isInteger());
assert (!da.isNumeric());
assert (!da.isSigned());
assert (!da.isString());
assert (!(da == da));
assert (!(da != da));
da = "123";
int i = da.convert<int>();
assert (123 == i);
std::string s = da.extract<std::string>();
assert ("123" == s);
assert (!da.isEmpty());
da.empty();
assert (da.isEmpty());
assert (da.type() == typeid(void));
assert (!da.isArray());
assert (!da.isInteger());
assert (!da.isNumeric());
assert (!da.isSigned());
assert (!da.isString());
assert (!(da == da));
assert (!(da != da));
assert (da != "");
assert ("" != da);
assert (!(da == ""));
assert (!("" == da));
testEmptyComparisons<unsigned char>();
testEmptyComparisons<char>();
testEmptyComparisons<Poco::UInt8>();
testEmptyComparisons<Poco::Int8>();
testEmptyComparisons<Poco::UInt16>();
testEmptyComparisons<Poco::Int16>();
testEmptyComparisons<Poco::UInt32>();
testEmptyComparisons<Poco::Int32>();
testEmptyComparisons<Poco::UInt64>();
testEmptyComparisons<Poco::Int64>();
#ifdef POCO_LONG_IS_64_BIT
testEmptyComparisons<unsigned long>();
testEmptyComparisons<long>();
#endif
testEmptyComparisons<float>();
testEmptyComparisons<double>();
try
{
int i = da;
fail ("must fail");
} catch (InvalidAccessException&) { }
try
{
int i = da.extract<int>();
fail ("must fail");
} catch (InvalidAccessException&) { }
}