###################
Loading a .red File
###################

The .red file API is exposed through the ``RED::IREDFile`` interface. To create an instance of a .red file, you need to use the ``RED::Factory``:

.. code:: cpp

    RED::Object* red_file = RED::Factory::CreateInstance( CID_REDFile );

and get back its interface with:

.. code:: cpp

    RED::IREDFile* ired_file = red_file->As< RED::IREDFile >();

Now we can load a .red file using our object:

Case of File on Disk
====================

.. code:: cpp 
        
    // iresmgr is a pointer to the RED::IResourceManager interface.
    RED::StreamingPolicy policy;
    RED::FileHeader fheader;
    RED::FileInfo finfo;
    RED::Vector< unsigned int > context;

    RC_TEST( ired_file->Load( "./my_file.red", iresmgr->GetState(), policy, fheader, finfo, context ) );

More Generic Case of a ``RED::IStream``
=======================================

.. code:: cpp 
        
    // iresmgr is a pointer to the RED::IResourceManager interface.
    // stream is a pointer to a RED stream.
    RC_TEST( ired_file->Load( *stream, iresmgr->GetState(), policy, fheader, finfo, context ) );