Base class for writing XML formatted data to an output stream. More...

#include <utils.h>

Inheritance diagram for frepple::utils::XMLOutput:

Public Types

typedef unsigned short content_type
 

Public Member Functions

void BeginObject (const Keyword &t)
 
void BeginObject (const Keyword &t, const string &atts)
 
template<class T >
void BeginObject (const Keyword &t, const Keyword &attr1, const T &val1)
 
template<class T , class U >
void BeginObject (const Keyword &t, const Keyword &attr1, const T &val1, const Keyword &attr2, const U &val2)
 
template<class T , class U , class V >
void BeginObject (const Keyword &t, const Keyword &attr1, const T &val1, const Keyword &attr2, const U &val2, const Keyword &attr3, const V &val3)
 
unsigned long countObjects () const
 
void EndObject (const Keyword &t)
 
content_type getContentType () const
 
ObjectgetCurrentObject () const
 
string getHeaderAtts () const
 
string getHeaderStart () const
 
const char * getIndent ()
 
ObjectgetPreviousObject () const
 
bool getReferencesOnly () const
 
void setContentType (content_type c)
 
void setHeaderAtts (const string &s)
 
void setHeaderStart (const string &s)
 
void setReferencesOnly (bool b)
 
void writeElement (const Keyword &t, const long unsigned int val)
 
void writeElement (const Keyword &t, const int val)
 
void writeElement (const Keyword &t, const double val)
 
void writeElement (const Keyword &t, const bool val)
 
void writeElement (const Keyword &t, const string &val)
 
void writeElement (const Keyword &u, const Keyword &t, const string &val)
 
void writeElement (const Keyword &u, const Keyword &t, const long val)
 
void writeElement (const Keyword &u, const Keyword &t, const Date &val)
 
void writeElement (const Keyword &u, const Keyword &t1, const string &val1, const Keyword &t2, const string &val2)
 
void writeElement (const Keyword &u, const Keyword &t1, unsigned long val1, const Keyword &t2, const string &val2)
 
void writeElement (const Keyword &t, const char *val)
 
void writeElement (const Keyword &t, const TimePeriod d)
 
void writeElement (const Keyword &t, const Date d)
 
void writeElement (const Keyword &t, const DateRange &d)
 
void writeElement (const Keyword &, const Object *, mode=DEFAULT)
 
void writeElement (const Keyword &t, const Object &o, mode m=DEFAULT)
 
void writeElementWithHeader (const Keyword &tag, const Object *object)
 
void writeHeader (const Keyword &tag)
 
void writeString (const string &c)
 
 XMLOutput (ostream &os)
 
 XMLOutput ()
 

Static Public Attributes

static const content_type PLAN = 2
 
static const content_type PLANDETAIL = 4
 
static const content_type STANDARD = 1
 

Protected Member Functions

void setOutput (ostream &o)
 

Detailed Description

Base class for writing XML formatted data to an output stream.

Subclasses implement writing to specific stream types, such as files and strings.

Definition at line 2002 of file utils.h.

Member Typedef Documentation

This type is used to define different types of output.

See Also
STANDARD
PLAN
PLANDETAIL

Definition at line 2014 of file utils.h.

Constructor & Destructor Documentation

frepple::utils::XMLOutput::XMLOutput ( ostream &  os)
inline

Constructor with a given stream.

Definition at line 2078 of file utils.h.

frepple::utils::XMLOutput::XMLOutput ( )
inline

Default constructor.

Definition at line 2085 of file utils.h.

Member Function Documentation

void frepple::utils::XMLOutput::BeginObject ( const Keyword t)
inline

Start writing a new object. This method will open a new XML-tag.
Output: <TAG>

Definition at line 2100 of file utils.h.

void frepple::utils::XMLOutput::BeginObject ( const Keyword t,
const string &  atts 
)
inline

Start writing a new object. This method will open a new XML-tag. Output: <TAG attributes>

Definition at line 2109 of file utils.h.

template<class T >
void frepple::utils::XMLOutput::BeginObject ( const Keyword t,
const Keyword attr1,
const T &  val1 
)
inline

Start writing a new object. This method will open a new XML-tag.
The user is responsible to assure string values are escaped correctly with the XMLEscape class.
Output: <TAG TAG1="val1">

See Also
XMLEscape

Definition at line 2121 of file utils.h.

template<class T , class U >
void frepple::utils::XMLOutput::BeginObject ( const Keyword t,
const Keyword attr1,
const T &  val1,
const Keyword attr2,
const U &  val2 
)
inline

Start writing a new object. This method will open a new XML-tag.
The user is responsible to assure string values are escaped correctly with the XMLEscape class.
Output: <TAG TAG1="val1" TAG2="val2">

See Also
XMLEscape

Definition at line 2134 of file utils.h.

template<class T , class U , class V >
void frepple::utils::XMLOutput::BeginObject ( const Keyword t,
const Keyword attr1,
const T &  val1,
const Keyword attr2,
const U &  val2,
const Keyword attr3,
const V &  val3 
)
inline

Start writing a new object. This method will open a new XML-tag.
The user is responsible to assure string values are escaped correctly with the XMLEscape class.
Output: <TAG TAG1="val1" TAG2="val2" TAG3="val3">

See Also
XMLEscape

Definition at line 2149 of file utils.h.

unsigned long frepple::utils::XMLOutput::countObjects ( ) const
inline

Returns the number of objects that have been serialized.

Definition at line 2343 of file utils.h.

void frepple::utils::XMLOutput::EndObject ( const Keyword t)
inline

Write the closing tag of this object and decrease the indentation level.
Output: </TAG_T>

Definition at line 2164 of file utils.h.

content_type frepple::utils::XMLOutput::getContentType ( ) const
inline

Returns which type of export is requested. Constants have been defined for each type.

See Also
STANDARD
PLAN
PLANDETAIL

Definition at line 2047 of file utils.h.

Object* frepple::utils::XMLOutput::getCurrentObject ( ) const
inline

Returns a pointer to the object that is currently being saved.

Definition at line 2335 of file utils.h.

string frepple::utils::XMLOutput::getHeaderAtts ( ) const
inline

Returns the attributes that are written for the root element of each XML document.

Definition at line 2075 of file utils.h.

string frepple::utils::XMLOutput::getHeaderStart ( ) const
inline

Returns the string that is printed as the first line of each XML document.

Definition at line 2065 of file utils.h.

const char* frepple::utils::XMLOutput::getIndent ( )
inline

Get a string suitable for correctly indenting the output.

Definition at line 2346 of file utils.h.

Object* frepple::utils::XMLOutput::getPreviousObject ( ) const
inline

Returns a pointer to the parent of the object that is being saved.

Definition at line 2339 of file utils.h.

bool frepple::utils::XMLOutput::getReferencesOnly ( ) const
inline

Returns whether we write only references for nested objects or not.

Definition at line 2095 of file utils.h.

void frepple::utils::XMLOutput::setContentType ( content_type  c)
inline

Specify the type of export.

See Also
STANDARD
PLAN
PLANDETAIL

Definition at line 2054 of file utils.h.

void frepple::utils::XMLOutput::setHeaderAtts ( const string &  s)
inline

Updates the attributes that are written for the root element of each XML document.
The default value is an empty string.

Definition at line 2071 of file utils.h.

void frepple::utils::XMLOutput::setHeaderStart ( const string &  s)
inline

Updates the string that is printed as the first line of each XML document.
The default value is: <?xml version="1.0" encoding="UTF-8"?>

Definition at line 2061 of file utils.h.

void frepple::utils::XMLOutput::setOutput ( ostream &  o)
inlineprotected

Updating the output stream.

Definition at line 2006 of file utils.h.

void frepple::utils::XMLOutput::setReferencesOnly ( bool  b)
inline

Force writing only references for nested objects.

Definition at line 2092 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const long unsigned int  val 
)
inline

Write an unsigned long value enclosed opening and closing tags.
Output: <TAG_T>uint</TAG_T>

Definition at line 2179 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const int  val 
)
inline

Write an integer value enclosed opening and closing tags.
Output: <TAG_T>integer</TAG_T>

Definition at line 2186 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const double  val 
)
inline

Write a double value enclosed opening and closing tags.
Output: <TAG_T>double</TAG_T>

Definition at line 2193 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const bool  val 
)
inline

Write a boolean value enclosed opening and closing tags. The boolean is written out as the string 'true' or 'false'.
Output: <TAG_T>true</TAG_T>

Definition at line 2202 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const string &  val 
)
inline

Write a string value enclosed opening and closing tags. Special characters (i.e. & < > " ' ) are appropriately escaped.
Output: <TAG_T>val</TAG_T>

Definition at line 2211 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword u,
const Keyword t,
const string &  val 
)
inline

Writes an element with a string attribute.
Output: <TAG_U TAG_T="string"/>

Definition at line 2220 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword u,
const Keyword t,
const long  val 
)
inline

Writes an element with a long attribute.
Output: <TAG_U TAG_T="val"/>

Definition at line 2232 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword u,
const Keyword t,
const Date val 
)
inline

Writes an element with a date attribute.
Output: <TAG_U TAG_T="val"/>

Definition at line 2240 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword u,
const Keyword t1,
const string &  val1,
const Keyword t2,
const string &  val2 
)
inline

Writes an element with 2 string attributes.
Output: <TAG_U TAG_T1="val1" TAG_T2="val2"/>

Definition at line 2248 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword u,
const Keyword t1,
unsigned long  val1,
const Keyword t2,
const string &  val2 
)
inline

Writes an element with a string and a long attribute.
Output: <TAG_U TAG_T1="val1" TAG_T2="val2"/>

Definition at line 2262 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const char *  val 
)
inline

Writes a C-type character string.
Output: <TAG_T>val</TAG_T>

Definition at line 2273 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const TimePeriod  d 
)
inline

Writes an timeperiod element.
Output: <TAG_T>d</TAG_T> />

Definition at line 2282 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const Date  d 
)
inline

Writes an date element.
Output: <TAG_T>d</TAG_T> />

Definition at line 2289 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const DateRange d 
)
inline

Writes an daterange element.
Output: <TAG_T>d</TAG_T>

Definition at line 2296 of file utils.h.

void frepple::utils::XMLOutput::writeElement ( const Keyword tag,
const Object object,
mode  m = DEFAULT 
)

This method writes a serializable object.
If an object is nested more than 2 levels deep only a reference to it is written, rather than the complete object. You should call this method for all objects in your xml document, except for the root object.

See Also
writeElementWithHeader(const Keyword&, Object*)

Definition at line 614 of file xmlparser.cpp.

void frepple::utils::XMLOutput::writeElement ( const Keyword t,
const Object o,
mode  m = DEFAULT 
)
inline
See Also
writeElement(const Keyword&, const Object*, mode)

Definition at line 2311 of file utils.h.

void frepple::utils::XMLOutput::writeElementWithHeader ( const Keyword tag,
const Object object 
)

This method writes a serializable object with a complete XML compliant header.
You should call this method for the root object of your xml document, and writeElement for all objects nested in it.

See Also
writeElement(const Keyword&, Object*)
writeHeader
Exceptions
RuntimeExceptionGenerated when multiple root elements are available for the output document.

Definition at line 642 of file xmlparser.cpp.

void frepple::utils::XMLOutput::writeHeader ( const Keyword tag)

This method writes the opening tag for an XML output.
You should call this method or writeElementWithHeader() when writing the first element of an xml document.

See Also
writeElementWithHeader
Exceptions
RuntimeExceptionGenerated when multiple root elements are available for the output document.

Definition at line 672 of file xmlparser.cpp.

void frepple::utils::XMLOutput::writeString ( const string &  c)
inline

Write the string to the output. No XML-tags are added, so this method is used for passing text straight into the output file.

Definition at line 2172 of file utils.h.

Member Data Documentation

const XMLOutput::content_type frepple::utils::XMLOutput::PLAN = 2
static

Constant to mark an export of the standard information plus the plan information. In this format, every entity is saved with the details on how it is used in the plan.
E.g. a resource will be saved with a reference to all its loadplans. E.g. an operation will be saved with all its operationplans.

See Also
STANDARD
PLANDETAIL

Definition at line 2032 of file utils.h.

const XMLOutput::content_type frepple::utils::XMLOutput::PLANDETAIL = 4
static

Constant to mark an export of the lowest level of plan information. In addition to the plan information pegging information is now saved.

See Also
STANDARD
PLAN

Definition at line 2039 of file utils.h.

const XMLOutput::content_type frepple::utils::XMLOutput::STANDARD = 1
static

Constant used to mark standard export for the export. The standard export saves just enough information to persist the full state of the model as brief as possible.

See Also
PLAN
PLANDETAIL

Definition at line 2022 of file utils.h.


The documentation for this class was generated from the following files: