Main MRPT website > C++ reference
MRPT logo

mrpt::utils::CSimpleDatabase Class Reference

This class impements a very simple database system. More...

#include <mrpt/utils/CSimpleDatabase.h>

Inheritance diagram for mrpt::utils::CSimpleDatabase:
Inheritance graph
[legend]
Collaboration diagram for mrpt::utils::CSimpleDatabase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CSimpleDatabase ()
 Default constructor.
virtual ~CSimpleDatabase ()
 Destructor.
void clear ()
 Clears the DB.
CSimpleDatabaseTablePtr createTable (const std::string &name)
 Creates a new table in the DB, initially empty.
CSimpleDatabaseTablePtr getTable (const std::string &tableName)
 Returns the table with the indicated name

Exceptions:
std::exception On table not found.

void dropTable (const std::string &tableName)
 Deletes the given table.
void renameTable (const std::string &tableName, const std::string &newTableName)
 Changes the name of a given table

Exceptions:
std::exception On table not found or new name already existed.

CSimpleDatabaseTablePtr getTable (size_t tableIndex)
 Returns the table by index.
size_t tablesCount () const
 Returns the tables count in the DB.
std::string tablesName (size_t tableIndex) const
 Returns the tables names in the DB.
bool saveAsXML (const std::string &fileName) const
 Saves this database as a XML file.
bool loadFromXML (const std::string &fileName)
 Loads the content of this database from a a XML file.

Private Types

typedef std::map< std::string,
CSimpleDatabaseTablePtr > 
TTableList
 The tables of the DB indexed by their names:.
typedef std::map< std::string,
CSimpleDatabaseTablePtr >
::iterator 
iterator
typedef std::map< std::string,
CSimpleDatabaseTablePtr >
::const_iterator 
const_iterator

Private Attributes

TTableList m_tables

Detailed Description

This class impements a very simple database system.

A database is a collection of tables, each one being a CSimpleDatabaseTable object. Tables are a rectangular arrrangement of cells, organized as records of fields. There are XML export/import methods in saveAsXML, loadFromXML.

Note:
This class is NOT safe for read/write access from different threads. If needed, use critical sections.
See also:
CSimpleDatabaseTable

Definition at line 140 of file CSimpleDatabase.h.


Member Typedef Documentation

typedef std::map<std::string, CSimpleDatabaseTablePtr>::const_iterator mrpt::utils::CSimpleDatabase::const_iterator [private]

Definition at line 211 of file CSimpleDatabase.h.

typedef std::map<std::string, CSimpleDatabaseTablePtr>::iterator mrpt::utils::CSimpleDatabase::iterator [private]

Definition at line 210 of file CSimpleDatabase.h.

typedef std::map<std::string, CSimpleDatabaseTablePtr> mrpt::utils::CSimpleDatabase::TTableList [private]

The tables of the DB indexed by their names:.

Definition at line 209 of file CSimpleDatabase.h.


Constructor & Destructor Documentation

mrpt::utils::CSimpleDatabase::CSimpleDatabase (  ) 

Default constructor.

virtual mrpt::utils::CSimpleDatabase::~CSimpleDatabase (  )  [virtual]

Destructor.


Member Function Documentation

void mrpt::utils::CSimpleDatabase::clear (  ) 

Clears the DB.

CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::createTable ( const std::string &  name  ) 

Creates a new table in the DB, initially empty.

void mrpt::utils::CSimpleDatabase::dropTable ( const std::string &  tableName  ) 

Deletes the given table.

Exceptions:
std::exception On table not found.
CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::getTable ( size_t  tableIndex  ) 

Returns the table by index.

Exceptions:
std::exception On index out of bounds
CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabase::getTable ( const std::string &  tableName  ) 

Returns the table with the indicated name

Exceptions:
std::exception On table not found.

bool mrpt::utils::CSimpleDatabase::loadFromXML ( const std::string &  fileName  ) 

Loads the content of this database from a a XML file.

Returns:
false on any error, true if successful.
See also:
saveAsXML
void mrpt::utils::CSimpleDatabase::renameTable ( const std::string &  tableName,
const std::string &  newTableName 
)

Changes the name of a given table

Exceptions:
std::exception On table not found or new name already existed.

bool mrpt::utils::CSimpleDatabase::saveAsXML ( const std::string &  fileName  )  const

Saves this database as a XML file.

Returns:
false on any error, true if successful.
See also:
loadFromXML
size_t mrpt::utils::CSimpleDatabase::tablesCount (  )  const

Returns the tables count in the DB.

std::string mrpt::utils::CSimpleDatabase::tablesName ( size_t  tableIndex  )  const

Returns the tables names in the DB.

Exceptions:
std::exception On index out of bounds

Member Data Documentation

Definition at line 213 of file CSimpleDatabase.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010