Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

TextPersistenceManager Class Reference
[Object Persistence.]

Text-format-based persistence manager. More...

#include <textPersistenceManager.h>

Inheritance diagram for TextPersistenceManager:

PersistenceManager List of all members.

Public Member Functions

Constructors and Destructors
 TextPersistenceManager ()
 Default constructor.
 TextPersistenceManager (std::istream &is)
 Detailed constructor with an input stream.
 TextPersistenceManager (std::ostream &os)
 Detailed constructor with an output stream.
 TextPersistenceManager (std::istream &is, std::ostream &os)
 Detailed constructor with an input stream and an output stream.
Layer 0 methods
virtual void writeHeader (const char *type_name, const char *name, LongSize ptr)
 Write an object header.
virtual bool checkHeader (const char *type_name, const char *name, LongSize &ptr)
 Check for an an object header.
virtual void writeTrailer (const char *name=0)
 Write the trailer for an object.
virtual bool checkTrailer (const char *name=0)
 Check an object trailer.
virtual void writeStreamHeader ()
 Write a start marker to the output stream.
virtual void writeStreamTrailer ()
 Write a end marker to the output stream.
virtual bool checkStreamHeader ()
 Check for the start marker in the input stream.
virtual bool checkStreamTrailer ()
 Check for the end marker in the output stream.
virtual bool getObjectHeader (String &type_name, LongSize &ptr)
 Get an (unknown) object header.
virtual void writeName (const char *name)
 Write a variable/member name.
virtual bool checkName (const char *name)
 Check for variable/member name.
virtual void writeStorableHeader (const char *type_name, const char *name)
 Write storable object header.
virtual bool checkStorableHeader (const char *type_name, const char *name)
 Check for storable object header.
virtual void writePrimitiveHeader (const char *type_name, const char *name)
 Write type header and name for a primitive type.
virtual bool checkPrimitiveHeader (const char *type_name, const char *name)
 Check for a type header and name for a primitive type.
virtual void writeStorableTrailer ()
 Write storable object trailer.
virtual bool checkStorableTrailer ()
 Check for storable object trailer.
virtual void writePrimitiveTrailer ()
 Write the trailer for a primitive type.
virtual bool checkPrimitiveTrailer ()
 Check the trailer of a primitive type.
virtual void writeObjectPointerHeader (const char *type_name, const char *name)
 Write header for a pointer to a PersistentObject.
virtual bool checkObjectPointerHeader (const char *type_name, const char *name)
 Check for header for a pointer to a PersistentObject.
virtual void writeObjectReferenceHeader (const char *type_name, const char *name)
 Write header for a reference to a PersistentObject.
virtual bool checkObjectReferenceHeader (const char *type_name, const char *name)
 Check for header for a reference to a PersistentObject.
virtual void writeObjectPointerArrayHeader (const char *type_name, const char *name, Size size)
 Write header for an array of pointers to PersistentObjects.
virtual bool checkObjectPointerArrayHeader (const char *type_name, const char *name, Size &size)
 Check for header for an array of pointers to PersistentObjects.
virtual void writeObjectPointerArrayTrailer ()
 Write trailer for an array of pointers to PersistentObjects.
virtual bool checkObjectPointerArrayTrailer ()
 Check for trailer for an array of pointers to PersistentObjects.
Put methods for primitive data types.
virtual void put (const char c)
 Write a signed char to the output stream.
virtual void put (const Byte c)
 Write an unsigned char to the output stream.
virtual void put (const Index s)
 Write an Index to the output stream.
virtual void put (const Size s)
 Write a Size or a Position to the output stream.
virtual void put (const bool b)
 Write a boolean value to the output stream.
virtual void put (const Real f)
 Write a single precision floating point number to the output stream.
virtual void put (const DoubleReal d)
 Write a double precision floating point number to the output stream.
virtual void put (const string &s)
 Write a string to the output.
virtual void put (const LongSize p)
 Write a 64-bit pointer to the output.
Get methods for primitive data types.
virtual void get (char &c)
 Read a signed char from the input stream.
virtual void get (Byte &b)
 Read an unsigned char from the input stream.
virtual void get (Index &i)
 Read an Index from the input stream.
virtual void get (Size &s)
 Read a Size or a Position from the input stream.
virtual void get (bool &b)
 Read a boolean value from the input stream.
virtual void get (Real &f)
 Read a single precision floating point number from the input stream.
virtual void get (DoubleReal &d)
 Read a double precision floating point number from the input stream.
virtual void get (string &s)
 Read a string from the output stream.
virtual void get (LongSize &p)
 Read a pointer from the input stream.

Protected Member Functions

virtual bool expect (const String &value)
 Check whether the streams contains a given string.
virtual const char * indent ()
 Return a string for the current indentation level.

Detailed Description

Text-format-based persistence manager.

This class implements a persistnece manager that reads and writes its objects in a human-readable text format. This is slow and objects get huge , but the format is clear and comprehensible - the ideal format to debug persistence-related programs. For production use, the XDRPersistenceManager is preferred.

See also:
XDRPersistenceManager


Constructor & Destructor Documentation

TextPersistenceManager::TextPersistenceManager  ) 
 

Default constructor.

Initializes just an internal variable.

TextPersistenceManager::TextPersistenceManager std::istream &  is  ) 
 

Detailed constructor with an input stream.

TextPersistenceManager::TextPersistenceManager std::ostream &  os  ) 
 

Detailed constructor with an output stream.

TextPersistenceManager::TextPersistenceManager std::istream &  is,
std::ostream &  os
 

Detailed constructor with an input stream and an output stream.


Member Function Documentation

virtual bool TextPersistenceManager::checkHeader const char *  type_name,
const char *  name,
LongSize ptr
[virtual]
 

Check for an an object header.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkName const char *  name  )  [virtual]
 

Check for variable/member name.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkObjectPointerArrayHeader const char *  type_name,
const char *  name,
Size size
[virtual]
 

Check for header for an array of pointers to PersistentObjects.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkObjectPointerArrayTrailer  )  [virtual]
 

Check for trailer for an array of pointers to PersistentObjects.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkObjectPointerHeader const char *  type_name,
const char *  name
[virtual]
 

Check for header for a pointer to a PersistentObject.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkObjectReferenceHeader const char *  type_name,
const char *  name
[virtual]
 

Check for header for a reference to a PersistentObject.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkPrimitiveHeader const char *  type_name,
const char *  name
[virtual]
 

Check for a type header and name for a primitive type.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkPrimitiveTrailer  )  [virtual]
 

Check the trailer of a primitive type.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkStorableHeader const char *  type_name,
const char *  name
[virtual]
 

Check for storable object header.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkStorableTrailer  )  [virtual]
 

Check for storable object trailer.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkStreamHeader  )  [virtual]
 

Check for the start marker in the input stream.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkStreamTrailer  )  [virtual]
 

Check for the end marker in the output stream.

Implements PersistenceManager.

virtual bool TextPersistenceManager::checkTrailer const char *  name = 0  )  [virtual]
 

Check an object trailer.

This method checks the trailer of an object.

Parameters:
name the name of the object
Returns:
true if the trailer was correct

Implements PersistenceManager.

virtual bool TextPersistenceManager::expect const String value  )  [protected, virtual]
 

Check whether the streams contains a given string.

This method reads the next string from the persistence manager's istream and compares it to the value given. If both strings are equal, true is returned.

Parameters:
value the expected string
Returns:
bool, true if the expected string was found, false otherwise

virtual void TextPersistenceManager::get LongSize p  )  [virtual]
 

Read a pointer from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get string &  s  )  [virtual]
 

Read a string from the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get DoubleReal d  )  [virtual]
 

Read a double precision floating point number from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get Real f  )  [virtual]
 

Read a single precision floating point number from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get bool &  b  )  [virtual]
 

Read a boolean value from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get Size s  )  [virtual]
 

Read a Size or a Position from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get Index i  )  [virtual]
 

Read an Index from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get Byte b  )  [virtual]
 

Read an unsigned char from the input stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::get char &  c  )  [virtual]
 

Read a signed char from the input stream.

Implements PersistenceManager.

virtual bool TextPersistenceManager::getObjectHeader String type_name,
LongSize ptr
[virtual]
 

Get an (unknown) object header.

Implements PersistenceManager.

virtual const char* TextPersistenceManager::indent  )  [protected, virtual]
 

Return a string for the current indentation level.

virtual void TextPersistenceManager::put const LongSize  p  )  [virtual]
 

Write a 64-bit pointer to the output.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const string &  s  )  [virtual]
 

Write a string to the output.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const DoubleReal  d  )  [virtual]
 

Write a double precision floating point number to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const Real  f  )  [virtual]
 

Write a single precision floating point number to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const bool  b  )  [virtual]
 

Write a boolean value to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const Size  s  )  [virtual]
 

Write a Size or a Position to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const Index  s  )  [virtual]
 

Write an Index to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const Byte  c  )  [virtual]
 

Write an unsigned char to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::put const char  c  )  [virtual]
 

Write a signed char to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeHeader const char *  type_name,
const char *  name,
LongSize  ptr
[virtual]
 

Write an object header.

This method write an object header. It starts with the current number of spaces needed for a correct indentation. If name is a null pointer, the object is a base object of the current object. This method then writes the string BASEOBJECT. If name is a name or an empty string, OBJECT is written.

Then, the object's type_name is written, followed by a blank, the character "@" to indicate an address and then the object's this pointer in decimal format. The last string in the line is either "-" (for a base object or an object without name) or the object's name.
The indentation level is incremented. Example for a base object: BASEOBJECT Composite @ 1145254238 - Example for a member object: BASEOBJECT Bond @ 2334208924 bond_

Implements PersistenceManager.

virtual void TextPersistenceManager::writeName const char *  name  )  [virtual]
 

Write a variable/member name.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeObjectPointerArrayHeader const char *  type_name,
const char *  name,
Size  size
[virtual]
 

Write header for an array of pointers to PersistentObjects.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeObjectPointerArrayTrailer  )  [virtual]
 

Write trailer for an array of pointers to PersistentObjects.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeObjectPointerHeader const char *  type_name,
const char *  name
[virtual]
 

Write header for a pointer to a PersistentObject.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeObjectReferenceHeader const char *  type_name,
const char *  name
[virtual]
 

Write header for a reference to a PersistentObject.

Implements PersistenceManager.

virtual void TextPersistenceManager::writePrimitiveHeader const char *  type_name,
const char *  name
[virtual]
 

Write type header and name for a primitive type.

Implements PersistenceManager.

virtual void TextPersistenceManager::writePrimitiveTrailer  )  [virtual]
 

Write the trailer for a primitive type.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeStorableHeader const char *  type_name,
const char *  name
[virtual]
 

Write storable object header.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeStorableTrailer  )  [virtual]
 

Write storable object trailer.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeStreamHeader  )  [virtual]
 

Write a start marker to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeStreamTrailer  )  [virtual]
 

Write a end marker to the output stream.

Implements PersistenceManager.

virtual void TextPersistenceManager::writeTrailer const char *  name = 0  )  [virtual]
 

Write the trailer for an object.

Parameters:
name the name of the object

Implements PersistenceManager.