MRPT
1.9.9
|
This class implements the tables of databases.
Definition at line 19 of file CSimpleDatabase.h.
#include <mrpt/db/CSimpleDatabase.h>
Public Member Functions | |
void * | operator new (size_t size) |
void * | operator new[] (size_t size) |
void | operator delete (void *ptr) noexcept |
void | operator delete[] (void *ptr) noexcept |
void | operator delete (void *memory, void *ptr) noexcept |
void * | operator new (size_t size, const std::nothrow_t &) noexcept |
void | operator delete (void *ptr, const std::nothrow_t &) noexcept |
CSimpleDatabaseTable () | |
Default constructor. More... | |
virtual | ~CSimpleDatabaseTable () |
Destructor. More... | |
size_t | fieldsCount () const |
Get the count of fields. More... | |
size_t | appendRecord () |
Append a new and empty record at the end of the table, and return the index of the newly added record. More... | |
void | addField (const char *fieldName) |
Add a new field to the table. More... | |
void | addField (const std::string &fieldName) |
Add a new field to the table. More... | |
std::string | getFieldName (size_t fieldIndex) const |
Get the name of a field by its index. More... | |
size_t | fieldIndex (const char *fieldName) const |
Get the index for a given field name. More... | |
size_t | fieldIndex (const std::string &fieldName) const |
Get the index for a given field name. More... | |
size_t | getRecordCount () const |
Get the records count in the table. More... | |
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". More... | |
std::string | get (size_t recordIndex, size_t fieldIndex) const |
Returns the cell content of the record indicates by its index, and the field indicated by its index. More... | |
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". More... | |
void | set (size_t recordIndex, size_t fieldIndex, std::string value) |
Sets the cell content of the record indicates by its index, and the field indicated by its index. More... | |
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, case insensitive, or -1 if not found. More... | |
void | deleteRecord (size_t recordIndex) |
Delete the record at the given index. More... | |
virtual mxArray * | writeToMatlab () const |
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More... | |
RTTI classes and functions for polymorphic hierarchies | |
mrpt::rtti::CObject::Ptr | duplicateGetSmartPtr () const |
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer). More... | |
Static Public Member Functions | |
static void * | operator new (size_t size, void *ptr) |
Protected Member Functions | |
CSerializable virtual methods | |
uint8_t | serializeGetVersion () const override |
Must return the current versioning number of the object. More... | |
void | serializeTo (mrpt::serialization::CArchive &out) const override |
Pure virtual method for writing (serializing) to an abstract archive. More... | |
void | serializeFrom (mrpt::serialization::CArchive &in, uint8_t serial_version) override |
Pure virtual method for reading (deserializing) from an abstract archive. More... | |
Private Attributes | |
std::vector< std::string > | field_names |
Field names. More... | |
std::vector< std::vector< std::string > > | data |
Data for each cell. More... | |
RTTI stuff | |
using | Ptr = std::shared_ptr< CSimpleDatabaseTable > |
using | ConstPtr = std::shared_ptr< const CSimpleDatabaseTable > |
using | UniquePtr = std::unique_ptr< CSimpleDatabaseTable > |
using | ConstUniquePtr = std::unique_ptr< const CSimpleDatabaseTable > |
static mrpt::rtti::CLASSINIT | _init_CSimpleDatabaseTable |
static const mrpt::rtti::TRuntimeClassId | runtimeClassId |
static constexpr const char * | className = "CSimpleDatabaseTable" |
static const mrpt::rtti::TRuntimeClassId * | _GetBaseClass () |
static constexpr auto | getClassName () |
static const mrpt::rtti::TRuntimeClassId & | GetRuntimeClassIdStatic () |
static mrpt::rtti::CObject * | CreateObject () |
template<typename... Args> | |
static Ptr | Create (Args &&... args) |
template<typename... Args> | |
static UniquePtr | CreateUnique (Args &&... args) |
virtual const mrpt::rtti::TRuntimeClassId * | GetRuntimeClass () const override |
Returns information about the class of an object in runtime. More... | |
virtual mrpt::rtti::CObject * | clone () const override |
Returns a deep copy (clone) of the object, indepently of its class. More... | |
Definition at line 21 of file CSimpleDatabase.h.
using mrpt::db::CSimpleDatabaseTable::ConstUniquePtr = std::unique_ptr<const CSimpleDatabaseTable > |
Definition at line 21 of file CSimpleDatabase.h.
A type for the associated smart pointer
Definition at line 21 of file CSimpleDatabase.h.
using mrpt::db::CSimpleDatabaseTable::UniquePtr = std::unique_ptr< CSimpleDatabaseTable > |
Definition at line 21 of file CSimpleDatabase.h.
CSimpleDatabaseTable::CSimpleDatabaseTable | ( | ) |
Default constructor.
Definition at line 195 of file CSimpleDatabase.cpp.
|
virtual |
Destructor.
Definition at line 199 of file CSimpleDatabase.cpp.
|
staticprotected |
void CSimpleDatabaseTable::addField | ( | const char * | fieldName | ) |
Add a new field to the table.
The table is cleared in this operation.
Definition at line 207 of file CSimpleDatabase.cpp.
|
inline |
Add a new field to the table.
The table is cleared in this operation.
Definition at line 45 of file CSimpleDatabase.h.
References addField().
Referenced by addField().
size_t CSimpleDatabaseTable::appendRecord | ( | ) |
Append a new and empty record at the end of the table, and return the index of the newly added record.
Definition at line 326 of file CSimpleDatabase.cpp.
|
overridevirtual |
Returns a deep copy (clone) of the object, indepently of its class.
Implements mrpt::rtti::CObject.
|
inlinestatic |
Definition at line 21 of file CSimpleDatabase.h.
|
static |
|
inlinestatic |
Definition at line 21 of file CSimpleDatabase.h.
void CSimpleDatabaseTable::deleteRecord | ( | size_t | recordIndex | ) |
Delete the record at the given index.
Definition at line 339 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
|
inlineinherited |
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).
Definition at line 168 of file CObject.h.
References mrpt::rtti::CObject::clone().
Referenced by mrpt::obs::CRawlog::addActions(), and mrpt::obs::CRawlog::addObservations().
size_t CSimpleDatabaseTable::fieldIndex | ( | const char * | fieldName | ) | const |
Get the index for a given field name.
std::exception | On field not found |
Definition at line 229 of file CSimpleDatabase.cpp.
References mrpt::system::os::_strcmpi(), MRPT_END, MRPT_START, and THROW_EXCEPTION_FMT.
Referenced by fieldIndex().
|
inline |
Get the index for a given field name.
std::exception | On field not found |
Definition at line 59 of file CSimpleDatabase.h.
References fieldIndex().
size_t CSimpleDatabaseTable::fieldsCount | ( | ) | const |
Get the count of fields.
Definition at line 203 of file CSimpleDatabase.cpp.
string CSimpleDatabaseTable::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::exception | On field or record not found |
Definition at line 250 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
string CSimpleDatabaseTable::get | ( | size_t | recordIndex, |
size_t | fieldIndex | ||
) | const |
Returns the cell content of the record indicates by its index, and the field indicated by its index.
std::exception | On field or record not found |
Definition at line 261 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
|
inlinestatic |
Definition at line 21 of file CSimpleDatabase.h.
string CSimpleDatabaseTable::getFieldName | ( | size_t | fieldIndex | ) | const |
Get the name of a field by its index.
std::exception | On index out of bounds |
Definition at line 216 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
size_t CSimpleDatabaseTable::getRecordCount | ( | ) | const |
Get the records count in the table.
Definition at line 246 of file CSimpleDatabase.cpp.
|
overridevirtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::serialization::CSerializable.
|
static |
Definition at line 21 of file CSimpleDatabase.h.
|
inlinenoexcept |
Definition at line 21 of file CSimpleDatabase.h.
Definition at line 21 of file CSimpleDatabase.h.
Definition at line 21 of file CSimpleDatabase.h.
|
inline |
Definition at line 21 of file CSimpleDatabase.h.
Definition at line 21 of file CSimpleDatabase.h.
|
inlinenoexcept |
Definition at line 21 of file CSimpleDatabase.h.
|
inline |
Definition at line 21 of file CSimpleDatabase.h.
int CSimpleDatabaseTable::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, case insensitive, or -1 if not found.
Definition at line 301 of file CSimpleDatabase.cpp.
References mrpt::system::os::_strcmpi().
|
overrideprotectedvirtual |
Pure virtual method for reading (deserializing) from an abstract archive.
Users don't call this method directly. Instead, use stream >> object;
.
in | The input binary stream where the object data must read from. |
version | The version of the object stored in the stream: use this version number in your code to know how to read the incoming data. |
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 89 of file CSimpleDatabase.cpp.
References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION.
|
overrideprotectedvirtual |
Must return the current versioning number of the object.
Start in zero for new classes, and increments each time there is a change in the stored format.
Implements mrpt::serialization::CSerializable.
Definition at line 76 of file CSimpleDatabase.cpp.
|
overrideprotectedvirtual |
Pure virtual method for writing (serializing) to an abstract archive.
Users don't call this method directly. Instead, use stream << object;
.
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 77 of file CSimpleDatabase.cpp.
void CSimpleDatabaseTable::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".
std::exception | On field or record not found |
Definition at line 273 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
void CSimpleDatabaseTable::set | ( | size_t | recordIndex, |
size_t | fieldIndex, | ||
std::string | value | ||
) |
Sets the cell content of the record indicates by its index, and the field indicated by its index.
std::exception | On field or record not found |
Definition at line 286 of file CSimpleDatabase.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
|
inlinevirtualinherited |
Introduces a pure virtual method responsible for writing to a mxArray
Matlab object, typically a MATLAB struct
whose contents are documented in each derived class.
mxArray
(caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB. Definition at line 68 of file CSerializable.h.
|
staticprotected |
Definition at line 21 of file CSimpleDatabase.h.
|
static |
Definition at line 21 of file CSimpleDatabase.h.
|
private |
Data for each cell.
Definition at line 104 of file CSimpleDatabase.h.
|
private |
Field names.
Definition at line 102 of file CSimpleDatabase.h.
|
staticprotected |
Definition at line 21 of file CSimpleDatabase.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |