Ejemplo n.º 1
0
string EncodeDicti( const CAtomDicti &x )
{
	map<string, CAtom *> *pmapDicti = x.getValuePtr( );

	string strDest;

	strDest += "d";

	for( map<string, CAtom *> :: iterator i = pmapDicti->begin( ); i != pmapDicti->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;
}
Ejemplo n.º 2
0
CAtomDicti :: CAtomDicti( const CAtomDicti &c )
{
	// copy constructor

	map<string, CAtom *> *pmapDicti = c.getValuePtr( );

	for( map<string, CAtom *> :: iterator itAtom = pmapDicti->begin( ); itAtom != pmapDicti->end( ); itAtom++ )
	{
		if( dynamic_cast<CAtomInt *>( (*itAtom).second ) )
			setItem( (*itAtom).first, new CAtomInt( *dynamic_cast<CAtomInt *>( (*itAtom).second ) ) );
		else if( dynamic_cast<CAtomLong *>( (*itAtom).second ) )
			setItem( (*itAtom).first, new CAtomLong( *dynamic_cast<CAtomLong *>( (*itAtom).second ) ) );
		else if( dynamic_cast<CAtomString *>( (*itAtom).second ) )
			setItem( (*itAtom).first, new CAtomString( *dynamic_cast<CAtomString *>( (*itAtom).second ) ) );
		else if( dynamic_cast<CAtomList *>( (*itAtom).second ) )
			setItem( (*itAtom).first, new CAtomList( *dynamic_cast<CAtomList *>( (*itAtom).second ) ) );
		else if( dynamic_cast<CAtomDicti *>( (*itAtom).second ) )
			setItem( (*itAtom).first, new CAtomDicti( *dynamic_cast<CAtomDicti *>( (*itAtom).second ) ) );
		else
			UTIL_LogPrint( ( gmapLANG_CFG["atomdicti_copy_warning"] + "\n" ).c_str( ) );
	}
}
Ejemplo n.º 3
0
CAtomDicti :: CAtomDicti( const CAtomDicti &c )
{
	// copy constructor

	map<string, CAtom *> *pmapDicti = c.getValuePtr( );

	for( map<string, CAtom *> :: iterator i = pmapDicti->begin( ); i != pmapDicti->end( ); i++ )
	{
		if( dynamic_cast<CAtomInt *>( (*i).second ) && dynamic_cast<CAtomInt *>( (*i).second ) != NULL )
			setItem( (*i).first, new CAtomInt( *dynamic_cast<CAtomInt *>( (*i).second ) ) );
		else if( dynamic_cast<CAtomLong *>( (*i).second ) && dynamic_cast<CAtomLong *>( (*i).second ) != NULL )
			setItem( (*i).first, new CAtomLong( *dynamic_cast<CAtomLong *>( (*i).second ) ) );
		else if( dynamic_cast<CAtomString *>( (*i).second ) && dynamic_cast<CAtomString *>( (*i).second ) != NULL )
			setItem( (*i).first, new CAtomString( *dynamic_cast<CAtomString *>( (*i).second ) ) );
		else if( dynamic_cast<CAtomList *>( (*i).second ) && dynamic_cast<CAtomList *>( (*i).second ) != NULL )
			setItem( (*i).first, new CAtomList( *dynamic_cast<CAtomList *>( (*i).second ) ) );
		else if( dynamic_cast<CAtomDicti *>( (*i).second ) && dynamic_cast<CAtomDicti *>( (*i).second ) != NULL )
			setItem( (*i).first, new CAtomDicti( *dynamic_cast<CAtomDicti *>( (*i).second ) ) );
		else
			UTIL_LogPrint( "error copying dictionary - found invalid atom, ignoring\n" );
	}
}