9 #ifndef CSimpleDatabase_H
10 #define CSimpleDatabase_H
46 void addField(
const char* fieldName);
58 size_t fieldIndex(
const char* fieldName)
const;
108 std::vector<vector_string>
data;
189 typedef std::map<std::string, CSimpleDatabaseTable::Ptr>
TTableList;
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
The virtual base class which provides a unified interface for all persistent objects in MRPT.
This class impements a very simple database system.
virtual ~CSimpleDatabase()
Destructor.
void clear()
Clears the DB.
std::string tablesName(size_t tableIndex) const
Returns the tables names in the DB.
std::map< std::string, CSimpleDatabaseTable::Ptr > TTableList
The tables of the DB indexed by their names:
std::map< std::string, CSimpleDatabaseTable::Ptr >::const_iterator const_iterator
bool saveAsXML(const std::string &fileName) const
Saves this database as a XML file.
void renameTable(const std::string &tableName, const std::string &newTableName)
Changes the name of a given table.
std::map< std::string, CSimpleDatabaseTable::Ptr >::iterator iterator
bool loadFromXML(const std::string &fileName)
Loads the content of this database from a a XML file.
CSimpleDatabaseTable::Ptr getTable(const std::string &tableName)
Returns the table with the indicated name.
CSimpleDatabaseTable::Ptr createTable(const std::string &name)
Creates a new table in the DB, initially empty.
void dropTable(const std::string &tableName)
Deletes the given table.
CSimpleDatabase()
Default constructor.
size_t tablesCount() const
Returns the tables count in the DB.
This class implements the tables of databases.
size_t fieldIndex(const char *fieldName) const
Get the index for a given field name.
void addField(const char *fieldName)
Add a new field to the table.
size_t fieldsCount() const
Get the count of fields.
void addField(const std::string &fieldName)
Add a new field to the table.
std::string get(size_t recordIndex, std::string field) const
Returns the cell content of the record indicates by its index, and the field indicated in "field".
std::vector< vector_string > data
Data for each cell.
void deleteRecord(size_t recordIndex)
Delete the record at the given index.
std::shared_ptr< CSimpleDatabaseTable > Ptr
int query(std::string field, std::string value) const
Executes a query in the table, returning the record index which a given field has a given value,...
vector_string field_names
Field names.
void set(size_t recordIndex, std::string field, std::string value)
Sets the cell content of the record indicates by its index, and the field indicated in "field".
CSimpleDatabaseTable()
Default constructor.
size_t getRecordCount() const
Get the records count in the table.
std::string getFieldName(size_t fieldIndex) const
Get the name of a field by its index.
size_t appendRecord()
Append a new and empty record at the end of the table, and return the index of the newly added record...
size_t fieldIndex(const std::string &fieldName) const
Get the index for a given field name.
virtual ~CSimpleDatabaseTable()
Destructor.
const Scalar * const_iterator
GLuint const GLchar * name
GLsizei const GLfloat * value
GLsizei const GLchar ** string
std::vector< std::string > vector_string
A type for passing a vector of strings.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.