#include <xml.h>
Public Member Functions | |
XMLWriter () | |
Constructor. | |
XMLWriter (XMLWriter const &xw) | |
Copy constructor. | |
XMLWriter & | operator= (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. |
bool databases::XMLWriter::database | ( | uint16_t | version | ) |
Sets the database information.
[in] | version | The database version (same as Database::version(Database::vtExport)). |
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.
[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()). |
bool databases::XMLWriter::count | ( | uint32_t | count | ) |
Sets the number of records in the database.
[in] | count | The number of records. |
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.
bool databases::XMLWriter::add_value | ( | char const * | field, | |
char const * | value | |||
) |
Adds a value to the database data.
[in] | field | The field name. |
[in] | value | The value. |
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.
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.
[in] | filename | The name of the file to write, either absolute or relative to the current working directory. |