databases::XMLWriter Class Reference

Class for writing XML file from databases. More...

#include <xml.h>

List of all members.

Public Member Functions

 XMLWriter ()
 Constructor.
 XMLWriter (XMLWriter const &xw)
 Copy constructor.
XMLWriteroperator= (XMLWriter const &right)
 Assignment operator.
 ~XMLWriter ()
 Destructor.
bool database (uint16_t version)
 Sets the database information.
bool add_field (char const *name, uint16_t type, size_t size, uint16_t attrs, char const *defval)
 Adds a field to the database header.
bool count (uint32_t count)
 Sets the number of records in the database.
bool begin_record ()
 Begins a record.
bool add_value (char const *field, char const *value)
 Adds a value to the database data.
bool add_ivalue (char const *field, int32_t value)
 Same as add_value(), but the value is an integer.
bool add_uivalue (char const *field, uint32_t value)
 Same as add_value(), but the value is an unsigned integer.
bool add_utvalue (char const *field, time_t value)
 Same as add_value(), but the value is a Unix timestamp.
bool add_rivalue (char const *field, Record::identifier_type value)
 Same as add_value(), but the value is a record identifier.
bool end_record ()
 Ends a record.
void dump_record ()
 Frees the current record without adding it to the file.
bool save (std::string const &filename)
 Saves the XML file.
char const * error () const
 Returns the error that occured if save() returns false.


Detailed Description

This class may be used to write database XML files that can then be imported through the XMLImport interface. It is generally used when implementing the XMLExport interface as it saves a lot of time in writing a suited XML file.


Member Function Documentation

bool databases::XMLWriter::database ( uint16_t  version  ) 

Sets the database information.

Parameters:
[in] version The database version (same as Database::version(Database::vtExport)).
Returns:
true if successful, false otherwise.

bool databases::XMLWriter::add_field ( char const *  name,
uint16_t  type,
size_t  size,
uint16_t  attrs,
char const *  defval 
)

Adds a field to the database header.

Parameters:
[in] name The field name (same as Field::name()).
[in] type The field type (same as Field::type()).
[in] size The field size (same as Field::size()).
[in] attrs The field attributes (same as Field::attrs()).
[in] defval The field default value (same as Field::default_value()).
Returns:
true if successful, false otherwise.

bool databases::XMLWriter::count ( uint32_t  count  ) 

Sets the number of records in the database.

Parameters:
[in] count The number of records.
Returns:
true if successful, false otherwise.

bool databases::XMLWriter::begin_record (  ) 

Begins a record. All calls to add_value() and other record-related functions until end_record() is called is relative to this record.

Returns:
true if successful, false otherwise.

bool databases::XMLWriter::add_value ( char const *  field,
char const *  value 
)

Adds a value to the database data.

Parameters:
[in] field The field name.
[in] value The value.
Returns:
true if successful, false otherwise.

bool databases::XMLWriter::end_record (  ) 

Ends a record. Must have been preceded by a call to begin_record() and one or more calls to add_value() and other related values.

Returns:
true if successful, false otherwise.

void databases::XMLWriter::dump_record (  ) 

Frees the current record without adding it to the file. Use this method if you don't wish to write a record for which begin_record() was already called.

bool databases::XMLWriter::save ( std::string const &  filename  ) 

Saves the XML file.

Parameters:
[in] filename The name of the file to write, either absolute or relative to the current working directory.
Returns:
true if successful, false otherwise.


The documentation for this class was generated from the following file:
Generated on Wed Aug 15 00:37:23 2007 for Epona API by  doxygen 1.5.2