Пример #1
0
void NetworkClient::GetGroups()
{
	rMessage->Reset();
	peer->RPC("ServerPeer::GetGroups", NULL , NULL, HIGH_PRIORITY, RELIABLE, 0, UNASSIGNED_SYSTEM_ADDRESS, true, 0, UNASSIGNED_NETWORK_ID,rMessage);
	if( (rMessage->GetNumberOfUnreadBits()) > 0)
	{
		int count, groupId, len = 0;		
		char* groupName = "";
		GroupMap g;
		g.clear();
		rMessage->Read(count);
		for(int j = 0;j<count;j++)
		{
			rMessage->Read(groupId);
			rMessage->Read(len);
			groupName = new char[len+1];
			groupName[len] = 0;
			rMessage->Read(groupName, len);
			g.insert(GroupMap::value_type(groupId, groupName));
		}
		if(!g.empty())
		{
			dataMan->setGroups(g);
		}		
	}
}
Пример #2
0
	void writeStream(std::ostream &stream, int tabCount)
	{
		for(ValueMap::iterator vi = values.begin(); vi != values.end(); ++vi)
		{
			writeTabs(stream, tabCount);
			stream << (*vi).first << " = " << (*vi).second.first << std::endl;
		}

		for(GroupMap::iterator gi = groups.begin(); gi != groups.end(); ++gi)
		{
			if((gi != groups.begin()) || (!values.empty()))
				stream << std::endl;

			writeTabs(stream, tabCount);
			stream << (*gi).first << std::endl;

			writeTabs(stream, tabCount);
			stream << "{" << std::endl;

			(*gi).second->writeStream(stream, tabCount + 1),
			
			writeTabs(stream, tabCount);
			stream << "}" << std::endl;			
		}

		if(!lines.empty() && ((!groups.empty() || !values.empty())))
			stream << std::endl;

		for(LineList::iterator li = lines.begin(); li != lines.end(); ++li)
		{
			writeTabs(stream, tabCount);

			std::string &f = (*li);
			stream << (*li) << std::endl;
		}
	}