Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
mrpt::utils::CSimpleDatabaseTable Class Reference

Detailed Description

This class implements the tables of databases.

See also
CSimpleDatabase

Definition at line 23 of file CSimpleDatabase.h.

#include <mrpt/utils/CSimpleDatabase.h>

Inheritance diagram for mrpt::utils::CSimpleDatabaseTable:
Inheritance graph

Public Member Functions

voidoperator new (size_t size)
 
voidoperator new[] (size_t size)
 
void operator delete (void *ptr) noexcept
 
void operator delete[] (void *ptr) noexcept
 
void operator delete (void *memory, void *ptr) noexcept
 
voidoperator 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 mxArraywriteToMatlab () 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
mrpt::utils::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 voidoperator new (size_t size, void *ptr)
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const override
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version) override
 Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori. More...
 

Private Attributes

vector_string field_names
 Field names. More...
 
std::vector< vector_stringdata
 Data for each cell. More...
 

RTTI stuff

using Ptr = std::shared_ptr< CSimpleDatabaseTable >
 
using ConstPtr = std::shared_ptr< const CSimpleDatabaseTable >
 
static mrpt::utils::CLASSINIT _init_CSimpleDatabaseTable
 
static const mrpt::utils::TRuntimeClassId runtimeClassId
 
static constexpr const char * className = "CSimpleDatabaseTable"
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
static const mrpt::utils::TRuntimeClassIdGetRuntimeClassIdStatic ()
 
static mrpt::utils::CObjectCreateObject ()
 
template<typename... Args>
static Ptr Create (Args &&... args)
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const override
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectclone () const override
 Returns a deep copy (clone) of the object, indepently of its class. More...
 

Member Typedef Documentation

◆ ConstPtr

Definition at line 25 of file CSimpleDatabase.h.

◆ Ptr

A typedef for the associated smart pointer

Definition at line 25 of file CSimpleDatabase.h.

Constructor & Destructor Documentation

◆ CSimpleDatabaseTable()

CSimpleDatabaseTable::CSimpleDatabaseTable ( )

Default constructor.

Definition at line 216 of file CSimpleDatabase.cpp.

◆ ~CSimpleDatabaseTable()

CSimpleDatabaseTable::~CSimpleDatabaseTable ( )
virtual

Destructor.

Definition at line 220 of file CSimpleDatabase.cpp.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId* mrpt::utils::CSimpleDatabaseTable::_GetBaseClass ( )
staticprotected

◆ addField() [1/2]

void CSimpleDatabaseTable::addField ( const char *  fieldName)

Add a new field to the table.

The table is cleared in this operation.

Definition at line 228 of file CSimpleDatabase.cpp.

◆ addField() [2/2]

void mrpt::utils::CSimpleDatabaseTable::addField ( const std::string fieldName)
inline

Add a new field to the table.

The table is cleared in this operation.

Definition at line 49 of file CSimpleDatabase.h.

References addField().

Referenced by addField().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendRecord()

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.

See also
deleteRecord

Definition at line 347 of file CSimpleDatabase.cpp.

◆ clone()

virtual mrpt::utils::CObject* mrpt::utils::CSimpleDatabaseTable::clone ( ) const
overridevirtual

Returns a deep copy (clone) of the object, indepently of its class.

Implements mrpt::utils::CObject.

◆ Create()

template<typename... Args>
static Ptr mrpt::utils::CSimpleDatabaseTable::Create ( Args &&...  args)
inlinestatic

Definition at line 25 of file CSimpleDatabase.h.

◆ CreateObject()

static mrpt::utils::CObject* mrpt::utils::CSimpleDatabaseTable::CreateObject ( )
static

◆ deleteRecord()

void CSimpleDatabaseTable::deleteRecord ( size_t  recordIndex)

Delete the record at the given index.

See also
appendRecord

Definition at line 360 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ fieldIndex() [1/2]

size_t CSimpleDatabaseTable::fieldIndex ( const char *  fieldName) const

Get the index for a given field name.

Exceptions
std::exceptionOn field not found

Definition at line 250 of file CSimpleDatabase.cpp.

References mrpt::system::os::_strcmpi(), MRPT_END, MRPT_START, and THROW_EXCEPTION_FMT.

Referenced by fieldIndex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fieldIndex() [2/2]

size_t mrpt::utils::CSimpleDatabaseTable::fieldIndex ( const std::string fieldName) const
inline

Get the index for a given field name.

Exceptions
std::exceptionOn field not found

Definition at line 63 of file CSimpleDatabase.h.

References fieldIndex().

Here is the call graph for this function:

◆ fieldsCount()

size_t CSimpleDatabaseTable::fieldsCount ( ) const

Get the count of fields.

Definition at line 224 of file CSimpleDatabase.cpp.

◆ get() [1/2]

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".

Exceptions
std::exceptionOn field or record not found

Definition at line 271 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ get() [2/2]

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.

Exceptions
std::exceptionOn field or record not found

Definition at line 282 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ getFieldName()

string CSimpleDatabaseTable::getFieldName ( size_t  fieldIndex) const

Get the name of a field by its index.

Exceptions
std::exceptionOn index out of bounds

Definition at line 237 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ getRecordCount()

size_t CSimpleDatabaseTable::getRecordCount ( ) const

Get the records count in the table.

Definition at line 267 of file CSimpleDatabase.cpp.

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId* mrpt::utils::CSimpleDatabaseTable::GetRuntimeClass ( ) const
overridevirtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

◆ GetRuntimeClassIdStatic()

static const mrpt::utils::TRuntimeClassId& mrpt::utils::CSimpleDatabaseTable::GetRuntimeClassIdStatic ( )
static

◆ operator delete() [1/3]

void mrpt::utils::CSimpleDatabaseTable::operator delete ( void ptr)
inlinenoexcept

Definition at line 25 of file CSimpleDatabase.h.

◆ operator delete() [2/3]

void mrpt::utils::CSimpleDatabaseTable::operator delete ( void memory,
void ptr 
)
inlinenoexcept

Definition at line 25 of file CSimpleDatabase.h.

◆ operator delete() [3/3]

void mrpt::utils::CSimpleDatabaseTable::operator delete ( void ptr,
const std::nothrow_t &   
)
inlinenoexcept

Definition at line 25 of file CSimpleDatabase.h.

◆ operator delete[]()

void mrpt::utils::CSimpleDatabaseTable::operator delete[] ( void ptr)
inlinenoexcept

Definition at line 25 of file CSimpleDatabase.h.

◆ operator new() [1/3]

static void* mrpt::utils::CSimpleDatabaseTable::operator new ( size_t  size,
void ptr 
)
inlinestatic

Definition at line 25 of file CSimpleDatabase.h.

◆ operator new() [2/3]

void* mrpt::utils::CSimpleDatabaseTable::operator new ( size_t  size,
const std::nothrow_t &   
)
inlinenoexcept

Definition at line 25 of file CSimpleDatabase.h.

◆ operator new() [3/3]

void* mrpt::utils::CSimpleDatabaseTable::operator new ( size_t  size)
inline

Definition at line 25 of file CSimpleDatabase.h.

◆ operator new[]()

void* mrpt::utils::CSimpleDatabaseTable::operator new[] ( size_t  size)
inline

Definition at line 25 of file CSimpleDatabase.h.

◆ query()

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 322 of file CSimpleDatabase.cpp.

References mrpt::system::os::_strcmpi().

Here is the call graph for this function:

◆ readFromStream()

void CSimpleDatabaseTable::readFromStream ( mrpt::utils::CStream in,
int  version 
)
overrideprotectedvirtual

Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.

Parameters
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions
std::exceptionOn any error, see CStream::ReadBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 110 of file CSimpleDatabase.cpp.

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION.

◆ set() [1/2]

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".

Exceptions
std::exceptionOn field or record not found

Definition at line 294 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ set() [2/2]

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.

Exceptions
std::exceptionOn field or record not found

Definition at line 307 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ writeToMatlab()

virtual mxArray* mrpt::utils::CSerializable::writeToMatlab ( ) const
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.

Returns
A new mxArray (caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB.

Definition at line 89 of file CSerializable.h.

◆ writeToStream()

void CSimpleDatabaseTable::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
overrideprotectedvirtual

Introduces a pure virtual method responsible for writing to a CStream.

This can not be used directly be users, instead use "stream << object;" for writing it to a stream.

Parameters
outThe output binary stream where object must be dumped.
getVersionIf nullptr, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data.
Exceptions
std::exceptionOn any error, see CStream::WriteBuffer
See also
CStream

Implements mrpt::utils::CSerializable.

Definition at line 89 of file CSimpleDatabase.cpp.

Member Data Documentation

◆ _init_CSimpleDatabaseTable

mrpt::utils::CLASSINIT mrpt::utils::CSimpleDatabaseTable::_init_CSimpleDatabaseTable
staticprotected

Definition at line 25 of file CSimpleDatabase.h.

◆ className

constexpr const char* mrpt::utils::CSimpleDatabaseTable::className = "CSimpleDatabaseTable"
static

Definition at line 25 of file CSimpleDatabase.h.

◆ data

std::vector<vector_string> mrpt::utils::CSimpleDatabaseTable::data
private

Data for each cell.

Definition at line 108 of file CSimpleDatabase.h.

◆ field_names

vector_string mrpt::utils::CSimpleDatabaseTable::field_names
private

Field names.

Definition at line 106 of file CSimpleDatabase.h.

◆ runtimeClassId

const mrpt::utils::TRuntimeClassId mrpt::utils::CSimpleDatabaseTable::runtimeClassId
staticprotected

Definition at line 25 of file CSimpleDatabase.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019