예제 #1
0
string EncodeDicti( const CAtomDicti &x )
{
	map<string, CAtom *> mapDicti = x.getValue( );

	string strDest;

	strDest += "d";

	for( map<string, CAtom *> :: iterator i = mapDicti.begin( ); i != mapDicti.end( ); i++ )
	{
		strDest += EncodeString( CAtomString( (*i).first ) );

		if( dynamic_cast<CAtomInt *>( (*i).second ) )
			strDest += EncodeInt( *dynamic_cast<CAtomInt *>( (*i).second ) );
		else if( dynamic_cast<CAtomLong *>( (*i).second ) )
			strDest += EncodeLong( *dynamic_cast<CAtomLong *>( (*i).second ) );
		else if( dynamic_cast<CAtomString *>( (*i).second ) )
			strDest += EncodeString( *dynamic_cast<CAtomString *>( (*i).second ) );
		else if( dynamic_cast<CAtomList *>( (*i).second ) )
			strDest += EncodeList( *dynamic_cast<CAtomList *>( (*i).second ) );
		else if( dynamic_cast<CAtomDicti *>( (*i).second ) )
			strDest += EncodeDicti( *dynamic_cast<CAtomDicti *>( (*i).second ) );
	}

	strDest += "e";

	return strDest;
}
예제 #2
0
int CAtomDicti :: EncodedLength( )
{
	int iLen = 0;

	for( map<string, CAtom *> :: iterator itAtom = m_mapDicti.begin( ); itAtom != m_mapDicti.end( ); itAtom++ )
		iLen += CAtomString( (*itAtom).first ).EncodedLength( ) + (*itAtom).second->EncodedLength( );

	return iLen + 2;
}