42 void addField(
const char* fieldName);
54 size_t fieldIndex(
const char* fieldName)
const;
104 std::vector<std::vector<std::string>>
data;
185 using TTableList = std::map<std::string, CSimpleDatabaseTable::Ptr>;
186 using iterator = std::map<std::string, CSimpleDatabaseTable::Ptr>::iterator;
188 std::map<std::string, CSimpleDatabaseTable::Ptr>::const_iterator;
CSimpleDatabaseTable()
Default constructor.
std::map< std::string, CSimpleDatabaseTable::Ptr >::const_iterator const_iterator
bool saveAsXML(const std::string &fileName) const
Saves this database as a XML file.
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...
size_t fieldsCount() const
Get the count of fields.
This class impements a very simple database system.
size_t tablesCount() const
Returns the tables count in the DB.
std::string getFieldName(size_t fieldIndex) const
Get the name of a field by its index.
CSimpleDatabaseTable::Ptr createTable(const std::string &name)
Creates a new table in the DB, initially empty.
size_t fieldIndex(const char *fieldName) const
Get the index for a given field name.
~CSimpleDatabase() override
Destructor.
std::string tablesName(size_t tableIndex) const
Returns the tables names in the DB.
void addField(const char *fieldName)
Add a new field to the table.
std::vector< std::string > field_names
Field names.
std::map< std::string, CSimpleDatabaseTable::Ptr >::iterator iterator
void dropTable(const std::string &tableName)
Deletes the given table.
CSimpleDatabase()
Default constructor.
std::map< std::string, CSimpleDatabaseTable::Ptr > TTableList
The tables of the DB indexed by their names:
void clear()
Clears the DB.
size_t appendRecord()
Append a new and empty record at the end of the table, and return the index of the newly added record...
void deleteRecord(size_t recordIndex)
Delete the record at the given index.
GLsizei const GLchar ** string
CSimpleDatabaseTable::Ptr getTable(const std::string &tableName)
Returns the table with the indicated name.
std::vector< std::vector< std::string > > data
Data for each cell.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
GLuint const GLchar * name
void addField(const std::string &fieldName)
Add a new field to the table.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
~CSimpleDatabaseTable() override
Destructor.
This class implements the tables of databases.
GLsizei const GLfloat * value
void renameTable(const std::string &tableName, const std::string &newTableName)
Changes the name of a given table.
size_t getRecordCount() const
Get the records count in the table.
bool loadFromXML(const std::string &fileName)
Loads the content of this database from a a XML file.
size_t fieldIndex(const std::string &fieldName) const
Get the index for a given field name.