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


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

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


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

示例1: find

Var Query::find(const std::string& path) const
{
	Var result = _source;
	StringTokenizer tokenizer(path, ".");
	for(StringTokenizer::Iterator token = tokenizer.begin(); token != tokenizer.end(); token++)
	{
		if ( !result.isEmpty() )
		{
			std::vector<int> indexes;
			RegularExpression::MatchVec matches;
			int firstOffset = -1;
			int offset = 0;
			RegularExpression regex("\\[([0-9]+)\\]");
			while(regex.match(*token, offset, matches) > 0 )
			{
				if ( firstOffset == -1 )
				{
					firstOffset = static_cast<int>(matches[0].offset);
				}
				std::string num = token->substr(matches[1].offset, matches[1].length);
				indexes.push_back(NumberParser::parse(num));
				offset = static_cast<int>(matches[0].offset + matches[0].length);
			}

			std::string name(*token);
			if ( firstOffset != -1 )
			{
				name = name.substr(0, firstOffset);
			}

			if ( name.length() > 0 )
			{
				if ( result.type() == typeid(Object::Ptr) )
				{
					Object::Ptr o = result.extract<Object::Ptr>();
					result = o->get(name);
				}
			}

			if (    !result.isEmpty()
			        && !indexes.empty() )
			{
				for(std::vector<int>::iterator it = indexes.begin(); it != indexes.end(); ++it )
				{
					if ( result.type() == typeid(Array::Ptr) )
					{
						Array::Ptr array = result.extract<Array::Ptr>();
						result = array->get(*it);
						if ( result.isEmpty() )
						{
							break;
						}
					}
				}
			}
		}
	}
	return result;
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:59,代码来源:Query.cpp

示例2: testNullProperty

void JSONTest::testNullProperty()
{
	std::string json = "{ \"test\" : null }";
	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>();
	assert(object->isNull("test"));
	Var test = object->get("test");
	assert(test.isEmpty());
}
开发者ID:RageStormers,项目名称:poco,代码行数:25,代码来源:JSONTest.cpp

示例3: testNullElement

void JSONTest::testNullElement()
{
	std::string json = "[ null ]";
	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>();
	assert(array->isNull(0));
	Var test = array->get(0);
	assert(test.isEmpty());
}
开发者ID:RageStormers,项目名称:poco,代码行数:26,代码来源:JSONTest.cpp

示例4: InvalidArgumentException

Query::Query(const Var& source): _source(source)
{
	if (!source.isEmpty() &&
		source.type() != typeid(Object) &&
		source.type() != typeid(Object::Ptr) &&
		source.type() != typeid(Array) &&
		source.type() != typeid(Array::Ptr))
		throw InvalidArgumentException("Only JSON Object, Array or pointers thereof allowed.");
}
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:9,代码来源:Query.cpp

示例5: 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

示例6:

JSONEntity::JSONEntity(Type type, const Var& value): _type(type)
{
	switch (type)
	{
		case JSON_T_INTEGER:
		case JSON_T_FLOAT:
		case JSON_T_STRING:
		case JSON_T_KEY:
			_value = value;
			break;
		default:
			poco_assert (value.isEmpty());
			break;
	}
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例7: appendJSONValue

void appendJSONValue(std::string& val, const Var& any)
{
	if (any.isEmpty()) 
	{
		val.append("null");
	}
	else 
	{
		bool isStr = isJSONString(any);
		if (isStr) 
		{
			appendJSONString(val, any.convert<std::string>());
		}
		else
		{
			val.append(any.convert<std::string>());
		}
	}
}
开发者ID:kutabar,项目名称:of,代码行数:19,代码来源:VarHolder.cpp

示例8: stringify

void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int indent, int step, bool preserveInsertionOrder)
{
	if (step == -1) step = indent;

	if ( any.type() == typeid(Object) )
	{
		const Object& o = any.extract<Object>();
		o.stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if ( any.type() == typeid(Array) )
	{
		const Array& a = any.extract<Array>();
		a.stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if ( any.type() == typeid(Object::Ptr) )
	{
		const Object::Ptr& o = any.extract<Object::Ptr>();
		o->stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if ( any.type() == typeid(Array::Ptr) )
	{
		const Array::Ptr& a = any.extract<Array::Ptr>();
		a->stringify(out, indent == 0 ? 0 : indent, step);
	}
	else if ( any.isEmpty() )
	{
		out << "null";
	}
	else if ( any.isString() )
	{
		std::string value = any.convert<std::string>();
		formatString(value, out);
	}
	else
	{
		out << any.convert<std::string>();
	}
}
开发者ID:bistromath,项目名称:pothos,代码行数:38,代码来源:Stringifier.cpp

示例9: 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

示例10: stringify

void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int indent)
{
	if ( any.type() == typeid(Object) )
	{
		const Object& o = any.extract<Object>();
		o.stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.type() == typeid(Array) )
	{
		const Array& a = any.extract<Array>();
		a.stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.type() == typeid(Object::Ptr) )
	{
		const Object::Ptr& o = any.extract<Object::Ptr>();
		o->stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.type() == typeid(Array::Ptr) )
	{
		const Array::Ptr& a = any.extract<Array::Ptr>();
		a->stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.isEmpty() )
	{
		out << "null";
	}
	else if ( any.isString() )
	{
		out << '"';
		std::string value = any.convert<std::string>();
		for(std::string::const_iterator it = value.begin(); it != value.end(); ++it)
		{
			switch (*it)
			{
			case '"':
				out << "\\\"";
				break;
			case '\\':
				out << "\\\\";
				break;
			case '\b':
				out << "\\b";
				break;
			case '\f':
				out << "\\f";
				break;
			case '\n':
				out << "\\n";
				break;
			case '\r':
				out << "\\r";
				break;
			case '\t':
				out << "\\t";
				break;
			default:
			{
				if ( *it > 0 && *it <= 0x1F )
				{
					out << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*it);
				}
				else
				{
					out << *it;
				}
				break;
			}
			}
		}
		out << '"';
	}
	else
	{
		out << any.convert<std::string>();
	}
}
开发者ID:babafall,项目名称:Sogeti-MasterThesis-CrossPlatformMobileDevelopment,代码行数:76,代码来源:Stringifier.cpp

示例11: OnGetRoomList

//得到房间列表
void MeetingConnImpl::OnGetRoomList(Object::Ptr object)
{
	FastMutex::ScopedLock autoLock(m_lock);
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{
		try
		{
			Var resultObj = object->get("result");
			Poco::JSON::Array::Ptr array =resultObj.extract<Poco::JSON::Array::Ptr>();
			for(Poco::Int32 i = 0; i<array->size();i++)
			{
				Parser parser;
				Var result;
				Var item = array->get(i);
				string strItem = item;
				result = parser.parse(strItem);
				Object::Ptr tempObj = result.extract<Object::Ptr>();
				Var varRoomID = tempObj->get("roomID");
				Var varRoomName = tempObj->get("roomName");
				Var varRoomPassword = tempObj->get("roomPassword");
				Var varAdminPassword = tempObj->get("adminPassword");
				Var varMixAudio = tempObj->get("mixAudio");
				Var varAudioSamplerate = tempObj->get("audioSamplerate");
				Var varDefaultVideoSize = tempObj->get("defaultVideoSize");
				Var varIsPublic = tempObj->get("isPublic");
				Var varMaxUser = tempObj->get("maxUser");
				Var varOnlineUser = tempObj->get("onlineUser");
				Var varStartTime = tempObj->get("startTime");
				Var varEndTime = tempObj->get("endTime");
				Var varAudioType = tempObj->get("audioType");   //类型 会议,直播
				PROOM_INFO pRoomInfo = new ROOM_INFO();
				FastMutex::ScopedLock autoLock(m_lock);
				pRoomInfo->ulRoomID = varRoomID;
				strcpy(pRoomInfo->strRoomName,varRoomName.toString().data());
				strcpy(pRoomInfo->strPassword,varRoomPassword.toString().data());
				strcpy(pRoomInfo->strAdminPwd,varAdminPassword.toString().data());
				pRoomInfo->bMixAudio = varMixAudio;
				pRoomInfo->speakMode = varAudioType;
				pRoomInfo->sampleRate = varAudioSamplerate;
				pRoomInfo->defaultVideoSize = varDefaultVideoSize;
				pRoomInfo->maxUser = varMaxUser;
				pRoomInfo->startTime = varStartTime;
				pRoomInfo->endTime = varEndTime;
				if(varOnlineUser.isEmpty())
				{
					pRoomInfo->onlineUser = 0;
				}
				else
				{
					pRoomInfo->onlineUser = varOnlineUser;
				}
				//m_mapRoom.insert(UINT_VOID_MAP::ValueType(pRoomInfo->ulRoomID,pRoomInfo));
				m_pRoomList.push_back(vector<PROOM_INFO>::value_type(pRoomInfo));
			}
			if(array->size()>0)
				m_pIMeetingEvent->On_MeetingEvent_GetRoomList(array->size());
		}
		catch(Poco::Exception& exc)
		{
			std::cout <<"get room list error:"<< exc.message() << std::endl;
			return;
		}
	}
	else
	{
		Var varMsg = object->get("msg");
		string errMsg = varMsg;
		m_pIMeetingEvent->On_MeetingEvent_GetRoomList(0);
	}
}
开发者ID:ACEZLY,项目名称:openmeeting2,代码行数:72,代码来源:MeetingConnImpl.cpp

示例12: OnLogin

void MeetingConnImpl::OnLogin(Object::Ptr object)
{
	Var varStatus = object->get("status");
	uint32_t statusCode = varStatus;
	switch(statusCode)
	{
	case 0:
		{
			m_bHasLogined = true;
			Var varUserName = object->get("userName");
			
			string userName = varUserName;
			
			strcpy(m_strUserName,userName.data());
			//解析配置项
			Var varConfig = object->get("config");
			if(!varConfig.isEmpty())
			{
				std::string strConfig = varConfig;
				//解析内置命令,UserOnline,UserOffline,OnModifyUserFeeling
				Parser parser;
				Var result;
				try
				{
					result = parser.parse(strConfig);
				}
				catch(JSONException& jsone)
				{
					std::cout << jsone.message() << std::endl;
				}
				Object::Ptr subObj = result.extract<Object::Ptr>();
				Var varMediaHost = subObj->get("MediaHost");
				Var varRtpMediaPort = subObj->get("RtpMediaPort");
				Var varMixAudioPort = subObj->get("MixAudioPort");
				Var varBaseUrl = subObj->get("BaseUrl");
				if(!varMediaHost.isEmpty())
				{
					std::string strServer = varMediaHost;
					strcpy(MeetingFrameImpl::GetInstance()->m_strMediaHost,strServer.data());
				}

				if(!varBaseUrl.isEmpty())
				{
					std::string strBaseUrl = varBaseUrl;
					strcpy(MeetingFrameImpl::GetInstance()->m_strBaseUrl,strBaseUrl.data());
				}

				if(!varRtpMediaPort.isEmpty())
				{
					MeetingFrameImpl::GetInstance()->m_RtpMediaPort = (int)varRtpMediaPort;
				}
				if(!varMixAudioPort.isEmpty())
				{
					MeetingFrameImpl::GetInstance()->m_MixAudioPort = (int)varMixAudioPort;
				}
			}
			else
			{
				//没有取到配置项目
			}
			

			if(m_pIMeetingEvent)
			{
				MeetingFrameImpl::GetInstance()->On_MeetingEvent_Login_Result(0,"login success");
			}
			break;
		}
	default:
		{
			Var varMsg = object->get("msg");
			string strMsg = varMsg;
			if(m_pIMeetingEvent)
			{
				MeetingFrameImpl::GetInstance()->On_MeetingEvent_Login_Result(statusCode,(char*)strMsg.data());
			}
		}
	}
	
}
开发者ID:ACEZLY,项目名称:openmeeting2,代码行数:80,代码来源:MeetingConnImpl.cpp

示例13: OnGetRoomInfo

void MeetingConnImpl::OnGetRoomInfo(Object::Ptr object)
{
	FastMutex::ScopedLock autoLock(m_lock);
	Var varStatus = object->get("status");
	int docIndex = 0;
	int docTotal = 0;
	int shareDoc = 0;
	std::string docName = "";
	if(object->isNull("shareDoc")==false)
	{
		shareDoc = object->get("shareDoc");
		if(shareDoc == 1)
		{
			docIndex = object->get("docIndex");
			docTotal = object->get("docTotal");
			docName =  object->get("docName").toString();
		}
	}

	if(varStatus == 0)
	{
		Var resultObj;
		try
		{
			resultObj = object->get("result");
		}
		catch(JSONException& jsone)
		{
			std::cout << jsone.message() << std::endl;
			return;
		}
		Object::Ptr subObj = resultObj.extract<Object::Ptr>();
		Var varRoomName = subObj->get("roomName");
		Var varRoomID = subObj->get("roomID");
		Var varAdminPassword= subObj->get("adminPassword");
		Var varRoomPassword = subObj->get("roomPassword");
		Var varAudioType = subObj->get("audioType");
		Var varIsPublic = subObj->get("isPublic");
		Var varMixAudio = subObj->get("mixAudio");
		Var varDefaultVideoSize = subObj->get("defaultVideoSize");
		Var varAudioSamplate = subObj->get("audioSamplerate");
		Var varStartTime = subObj->get("startTime");
		Var varEndTime = subObj->get("endTime");
		Var varOnlineUser = subObj->get("onlineUser");
		string strRoomName = varRoomName;
		uint32_t roomID = varRoomID;
		string strPassword = varRoomPassword;
		string strAdminPassword = varAdminPassword;
		uint32_t defaultVideoSize = varDefaultVideoSize;
		uint32_t audioType = varAudioType;
		uint32_t isPublic = varIsPublic;
		uint32_t mixAudio = varMixAudio;
		uint32_t audioSamplate = 0;
		time_t startTime = varStartTime;
		time_t endTime = varEndTime;
		
		ROOM_INFO rs;
		rs.bMixAudio =mixAudio;
		rs.sampleRate = audioSamplate;
		rs.speakMode = audioType;
		rs.defaultVideoSize = defaultVideoSize;
		rs.ulRoomID = roomID;
		rs.ulIsPublic = isPublic;
		rs.roomMode = 1;
		rs.sampleRate = varAudioSamplate;
		rs.startTime = startTime;
		rs.endTime = endTime;
		if(varOnlineUser.isEmpty())
		{
			rs.onlineUser = 0;
		}
		else
		{
			rs.onlineUser = varOnlineUser;
		}
		if(subObj->has("roomType"))
		{
			Var varRoomType = subObj->get("roomType");
			unsigned int ulRoomType = varRoomType;
			rs.roomMode = ulRoomType;
		}

		if(subObj->has("bigVideoUser"))
		{
			Var varbigVideoUser = subObj->get("bigVideoUser");
			uint64_t ulBigVideoUser = varbigVideoUser;
			rs.bigVideoUser = ulBigVideoUser;
		}
		strcpy(rs.strAdminPwd,strAdminPassword.data());
		strcpy(rs.strRoomName,strRoomName.data());
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(0,(char*)&rs);
		if(shareDoc==1)
		{
			if(m_pIMeetingEvent)
			{
				m_pIMeetingEvent->On_MeetingEvent_OpenDoc(docName,docIndex,docTotal);
			}
		}
		GetRoomUserList(m_ulRoomID);
	}
//.........这里部分代码省略.........
开发者ID:ACEZLY,项目名称:openmeeting2,代码行数:101,代码来源:MeetingConnImpl.cpp


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