Flip Reference

BackEndMl Class Reference

Declared in

flip/BackEndMl.h

class BackEndMl;

flip::BackEndMl represents a concrete format data type which, using a DataProvider or DataConsumer, allows to read or write and fill a generic back end representation of a document.

The object itself does not hold any data, and just act as a parser/formatter from the intermediate representation of the document to the provider/consumer.

BackEndMl will format the data in a textual format with a specific markup language :

See BackEndBinary for a a format ready for production.

Normally, this class is used through the use of BackEndIR directly. See the documentation for more details.

DataProviders and DataConsumers provides an abstraction to the underlying storage media from which to read or write to.

Member Functions Synopsys

Constructor

Constructs the BackEndMl

Destructor

Destructs the BackEndMl

write

Format the data from the intermediate representation to the data consumer

read

Parse the data from the data provider to the intermediate representation

Member Functions

Constructor

BackEndMl ();

Default constructor.


Destructor

~BackEndMl ();

Destructor.


write

void  write (DataConsumerBase & consumer, const BackEndIR & ir);

Format the data from the intermediate representation of the document and feed them to the consumer.

Example :

#include "flip/BackEndMl.h"
#include "flip/BackEndIR.h"
#include "flip/contrib/DataConsumerFile.h"
Document document (Model::use (), user_id, manufacturer_id, component_id);
[...]
// put the result of document serialisation in a file
DataConsumerFile consumer ("/path/to/file");
// get the backend intermediate representation
BackEndIR backend = document.write ();
// write the backend intermediate representation to markup language, using the consumer
backend.write <BackEndMl> (consumer);
// now the file is filled with the document serialisation in markup language format

read

void   read (DataProviderBase & provider, BackEndIR & ir);

Parse the data from the data provider and fill the intermediate representation of the document.

Example :

#include "flip/BackEndMl.h"
#include "flip/BackEndIR.h"
#include "flip/cotnrib/DataProviderFile.h"
DataProviderFile provider ("/path/to/file");
// tell the backend to automatically recognize the markup language format
BackEndIR backend;
backend.register_backend <BackEndMl> ();
bool ok_flag = backend.read (provider);
if (!ok_flag) return;   // a corruption occured
Document document (Model::use (), user_id, manufacturer_id, component_id);
// change the document with the content of the backend
document.read (backend);
// commit the changes
document.commit ();