コード例 #1
0
bool IObjectMapPropertyType<KeyType, ValueType>::DoSerialize(
	BidirectionalSerializer &bidi, KeyType &key, ValueType &value)
{
	bool result = true;
	ISerializer *serializer = bidi.Serializer();

	Command item(Command::EITEM);

	Command attribute(Command::EATTRIBUTE, "key");

	if(false == serializer->BeginCommand(item))
		result = false;
	if(false == serializer->BeginCommand(attribute))
		result = false;

	serializer->Hint( "map_key" );
	bidi | key;
	if(false == serializer->EndCommand(attribute))
		result = false;
		
	serializer->Hint( "map_value" );
	bidi | value;
	if(false == serializer->EndCommand(item))
		result = false;

	if(false == result)
		bidi.Fail();

	return bidi.Succeeded();
}
コード例 #2
0
ファイル: enum_serializer.cpp プロジェクト: andemi02/orkid
const char *DoSerializeEnum(int value, EnumNameMap *enum_map, BidirectionalSerializer &bidi)
{
	ISerializer *pser = bidi.Serializer();

	pser->Hint( "EnumMap", reinterpret_cast<intptr_t>(enum_map) );

	for(int i = 0; enum_map[i].name; i++)
	{
		if(value == enum_map[i].value)
		{
			return enum_map[i].name;
		}
	}

	bidi.Fail();

	return "<<BAD_ENUM>>";
}