The storage class uses a view, with additional functionality to be able to store and reload the data it contains (including nested subviews).

By default, data is loaded on demand, i.e. whenever data which has not yet been referenced is used for the first time. Loading is limited to the lifetime of this storage object, since the storage object carries the file descriptor with it that is needed to access the data file.

To save changes, call the Commit member. This is the only time that data is written to file - when using a read-only file simply avoid calling Commit.

The LoadFromStream and SaveToStream members can be used to serialize the contents of this storage row using only sequential I/O (no seeking, only read or write calls).

The data storage mechanism implementation provides fail-safe operation: if anything prevents Commit from completing its task, the last succesfully committed version of the saved data will be recovered on the next open. This also includes changes made to the table structure.

The following code creates a view with 1 row and stores it on file:

        c4_StringProp pName ("Name");
        c4_IntProp pAge ("Age");

        c4_Storage storage ("myfile.dat", true);
        c4_View myView = storage.GetAs("Musicians[Name:S,Age:I]");

        myView.Add(pName ["John Williams"] + pAge [43]);

        storage.Commit();

void AutoCommit ();
  Set storage up to always call Commit in the destructor

bool Commit ();
  Flush pending changes to file right now

c4_RowRef Contents () const;
  Give access to the stored data as a single row

const char* Description (const char* name_ =0);
  Return a description of the view structure (default is all)

c4_View GetAs (const char* description_);
  Get a named view, redefining it to match the given structure

void Initialize (const char*, bool);

void LoadFrom (c4_Stream& stream_);
  Load contents from the specified input stream

bool Rollback ();
  Calling Rollback will cancel all uncommitted changes.

c4_HandlerSeq& RootTable () const;
  Return the root table entry

void SaveTo (c4_Stream& stream_);
  Save contents to the specified output stream

void SetStructure (const char*);

c4_View Store (const char* name_, const c4_View& view_);
  Attach a view using specified name in this storage object

c4_Strategy& Strategy () const;
  Return the strategy object associated with this storage

c4_ViewRef View (const char* name_);
  Get or set a named view in this storage object

c4_Persist* _persist;

c4_Storage ();
  Construct streaming-only storage object

c4_Storage (c4_Strategy& strategy_, bool owned_ =false);
  Construct a storage using the specified strategy handler

c4_Storage (const c4_Storage&);
  Copy constructor

c4_Storage (const char* filename_, bool canModify_);
  Construct a storage object, keeping the current structure

c4_Storage (const char* filename_, const char* description_);
  Construct a storage object for given file and format

c4_Storage& operator= (const c4_Storage&);
  Assignment of storage implements reference semantics

~c4_Storage ();
  Destructor, usually closes file, but does not commit by default

class c4_Storage