Ejemplo n.º 1
0
void load( Archive& archive, int mode, const char* name, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( object.get() == NULL );
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, name, 0, MODE_VALUE );
    object.reset( static_cast<Type*>(archive.create_and_persist<Type>()) );
}
Ejemplo n.º 2
0
void load( Archive& archive, int mode, const char* name, weak_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_REFERENCE );
    SWEET_ASSERT( object.lock() == ptr<Type>() );

    ObjectGuard<Archive> guard( archive, name, 0, MODE_REFERENCE );
    archive.reference( archive.get_address(), reinterpret_cast<void**>(&object), &resolver<weak_ptr<Type> >::resolve );
}
Ejemplo n.º 3
0
 void operator()( ParserStateMachine* parser_state_machine ) const
 {
     SWEET_ASSERT( parser_state_machine );
     SWEET_ASSERT( application_ );            
     application_->remove_parser_state_machine( parser_state_machine );
     delete parser_state_machine;
     parser_state_machine = NULL;
 }
Ejemplo n.º 4
0
void save( Archive& archive, int mode, const char* name, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, name, object.get(), mode, object.get() != 0 ? 1: 0 );
    if ( object.get() )
    {
        archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
    }
}
Ejemplo n.º 5
0
void load( Archive& archive, int mode, const char* name, ptr<Type>& object )
{
    SWEET_ASSERT( object.get() == NULL );

    ObjectGuard<Archive> guard( archive, name, 0, mode );
    switch ( mode )
    {
        case MODE_VALUE:
            object.reset( static_cast<Type*>(archive.template create_and_persist<Type>()) );
            break;

        case MODE_REFERENCE:
            archive.reference( archive.get_address(), reinterpret_cast<void**>(&object), &resolver<ptr<Type> >::resolve );
            break;

        default:
            SWEET_ASSERT( false );
            break;
    }
}
Ejemplo n.º 6
0
void resolve( Archive& archive, int mode, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, 0, object.get(), MODE_VALUE );
    if ( object.get() != NULL )
    {
        archive.track( object.get(), &object );
        archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
    }
}
Ejemplo n.º 7
0
    TestBody( const char* filename )
        : written_model_(),
          read_model_()
    {
        SWEET_ASSERT( filename );

        Writer writer;
        writer.write( filename, "model", written_model_ );
        read_model_.clear();
        Reader reader;
        reader.read( filename, "model", read_model_ );
    }
Ejemplo n.º 8
0
void save( Archive& archive, int mode, const char* name, weak_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_REFERENCE );

    ptr<Type> locked_object = object.lock();
    if ( locked_object )
    {
        ObjectGuard<Archive> guard( archive, name, locked_object.get(), MODE_REFERENCE, 1 );
    }
    else
    {
        ObjectGuard<Archive> guard( archive, name, NULL, MODE_REFERENCE, 0 );
    }
}
Ejemplo n.º 9
0
void save( Archive& archive, int mode, const char* name, ptr<Type>& object )
{
    ObjectGuard<Archive> guard( archive, name, object.get(), mode, object.get() != 0 ? 1 : 0 );
    switch ( mode )
    {
        case MODE_VALUE:
            if ( object.get() != 0 )
            {
                archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
            }
            break;

        case MODE_REFERENCE:
            break;

        default:
            SWEET_ASSERT( false );
            break;
    }
}
Ejemplo n.º 10
0
void resolve( Archive& archive, int mode, ptr<Type>& object )
{
    ObjectGuard<Archive> guard( archive, 0, object.get(), mode );
    switch ( mode )
    {
        case MODE_VALUE:
            if ( object.get() )
            {
                archive.track( object.get(), &object );
                archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
            }
            break;

        case MODE_REFERENCE:
            archive.reference( 0, reinterpret_cast<void**>(&object), &resolver<ptr<Type> >::resolve );
            break;

        default:
            SWEET_ASSERT( false );
            break;
    }
}
Ejemplo n.º 11
0
 bool operator()( const ReaderType* lhs, const ReaderType* rhs ) const
 {
     SWEET_ASSERT( lhs && rhs );
     return lhs->compare_by_name( *rhs );
 }
Ejemplo n.º 12
0
void resolve( Archive& archive, int mode, weak_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_REFERENCE );
    archive.reference( 0, reinterpret_cast<void**>(&object), &resolver<weak_ptr<Type> >::resolve );
}
Ejemplo n.º 13
0
void load( Archive& archive, int mode, const char* name, const char* child_name, std::deque<Type, ALLOCATOR>& container )
{
    SWEET_ASSERT( container.empty() );
    load_stl_sequence( archive, mode, name, child_name, container );
}
Ejemplo n.º 14
0
 ParserStateMachineDeleter( Application* application )
 : application_( application )
 {
     SWEET_ASSERT( application_ );            
 }