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


C++ Var::isNumeric方法代码示例

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


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

示例1: testDoubleElement

void JSONTest::testDoubleElement()
{
	std::string json = "[ 123.45 ]";
	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.isNumeric());
	double value = test;
	assert(value == 123.45);
}
开发者ID:RageStormers,项目名称:poco,代码行数:27,代码来源:JSONTest.cpp

示例2: typeid

void JSONTest::testDouble3Property()
{
	std::string json = "{ \"test\" : 12e-34 }";
	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.isNumeric());
	double value = test;
	assert(value == 12e-34);
}
开发者ID:RageStormers,项目名称:poco,代码行数:27,代码来源:JSONTest.cpp

示例3: stringify

void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int indent, int step, int options)
{
	bool escapeUnicode = ((options & Poco::JSON_ESCAPE_UNICODE) != 0);

	if (step == -1) step = indent;

	if (any.type() == typeid(Object))
	{
		Object& o = const_cast<Object&>(any.extract<Object>());
		o.setEscapeUnicode(escapeUnicode);
		o.stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if (any.type() == typeid(Array))
	{
		Array& a = const_cast<Array&>(any.extract<Array>());
		a.setEscapeUnicode(escapeUnicode);
		a.stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if (any.type() == typeid(Object::Ptr))
	{
		Object::Ptr& o = const_cast<Object::Ptr&>(any.extract<Object::Ptr>());
		o->setEscapeUnicode(escapeUnicode);
		o->stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if (any.type() == typeid(Array::Ptr))
	{
		Array::Ptr& a = const_cast<Array::Ptr&>(any.extract<Array::Ptr>());
		a->setEscapeUnicode(escapeUnicode);
		a->stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if (any.isEmpty())
	{
		out << "null";
	}
	else if (any.isNumeric() || any.isBoolean())
	{
		std::string value = any.convert<std::string>();
		if (any.type() == typeid(char)) formatString(value, out, options);
		else out << value;
	}
	else if (any.isString() || any.isDateTime() || any.isDate() || any.isTime())
	{
		std::string value = any.convert<std::string>();
		formatString(value, out, options);
	}
	else
	{
		out << any.convert<std::string>();
	}
}
开发者ID:macchina-io,项目名称:macchina.io,代码行数:50,代码来源:Stringifier.cpp

示例4: 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&) { }
}
开发者ID:RageStormers,项目名称:poco,代码行数:65,代码来源:VarTest.cpp


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