Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | 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 29 of file CSimpleDatabase.h.

#include <mrpt/utils/CSimpleDatabase.h>

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

Public Member Functions

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

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_OVERRIDE
 

Private Attributes

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

RTTI stuff <br>

typedef CSimpleDatabaseTablePtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CSimpleDatabaseTable
 
static mrpt::utils::TRuntimeClassId classCSimpleDatabaseTable
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const MRPT_OVERRIDE
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 
static mrpt::utils::CObjectCreateObject ()
 
static CSimpleDatabaseTablePtr Create ()
 

Member Typedef Documentation

◆ SmartPtr

A typedef for the associated smart pointer

Definition at line 32 of file CSimpleDatabase.h.

Constructor & Destructor Documentation

◆ CSimpleDatabaseTable()

mrpt::utils::CSimpleDatabaseTable::CSimpleDatabaseTable ( )

Default constructor.

◆ ~CSimpleDatabaseTable()

virtual mrpt::utils::CSimpleDatabaseTable::~CSimpleDatabaseTable ( )
virtual

Destructor.

Member Function Documentation

◆ _GetBaseClass()

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

◆ addField() [1/2]

void mrpt::utils::CSimpleDatabaseTable::addField ( const char *  fieldName)

Add a new field to the table.

The table is cleared in this operation.

◆ 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 55 of file CSimpleDatabase.h.

◆ appendRecord()

size_t mrpt::utils::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

◆ Create()

static CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabaseTable::Create ( )
static

◆ CreateObject()

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

◆ deleteRecord()

void mrpt::utils::CSimpleDatabaseTable::deleteRecord ( size_t  recordIndex)

Delete the record at the given index.

See also
appendRecord

◆ duplicate()

virtual mrpt::utils::CObject * mrpt::utils::CSimpleDatabaseTable::duplicate ( ) const
virtual

◆ fieldIndex() [1/2]

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

Get the index for a given field name.

Exceptions
std::exceptionOn field not found

◆ 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 72 of file CSimpleDatabase.h.

◆ fieldsCount()

size_t mrpt::utils::CSimpleDatabaseTable::fieldsCount ( ) const

Get the count of fields.

◆ get() [1/2]

std::string mrpt::utils::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

◆ get() [2/2]

std::string mrpt::utils::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

◆ getFieldName()

std::string mrpt::utils::CSimpleDatabaseTable::getFieldName ( size_t  fieldIndex) const

Get the name of a field by its index.

Exceptions
std::exceptionOn index out of bounds

◆ getRecordCount()

size_t mrpt::utils::CSimpleDatabaseTable::getRecordCount ( ) const

Get the records count in the table.

◆ GetRuntimeClass()

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

◆ query()

int mrpt::utils::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.

◆ readFromStream()

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

◆ set() [1/2]

void mrpt::utils::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

◆ set() [2/2]

void mrpt::utils::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

◆ writeToStream()

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

Member Data Documentation

◆ _init_CSimpleDatabaseTable

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

Definition at line 32 of file CSimpleDatabase.h.

◆ classCSimpleDatabaseTable

mrpt::utils::TRuntimeClassId mrpt::utils::CSimpleDatabaseTable::classCSimpleDatabaseTable
static

Definition at line 32 of file CSimpleDatabase.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::utils::CSimpleDatabaseTable::classinfo
static

Definition at line 32 of file CSimpleDatabase.h.

◆ data

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

Data for each cell.

Definition at line 109 of file CSimpleDatabase.h.

◆ field_names

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

Field names.

Definition at line 108 of file CSimpleDatabase.h.




Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Tue Dec 27 00:54:45 UTC 2022