Main MRPT website > C++ reference for MRPT 1.5.7
List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | 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

voidoperator new (size_t size)
 
voidoperator new[] (size_t size)
 
void operator delete (void *ptr) throw ()
 
void operator delete[] (void *ptr) throw ()
 
void operator delete (void *memory, void *ptr) throw ()
 
voidoperator new (size_t size, const std::nothrow_t &) throw ()
 
void operator delete (void *ptr, const std::nothrow_t &) throw ()
 
 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

Exceptions
std::exceptionOn index out of bounds.
More...
 
size_t fieldIndex (const char *fieldName) const
 Get the index for a given field name

Exceptions
std::exceptionOn field not found.
More...
 
size_t fieldIndex (const std::string &fieldName) const
 Get the index for a given field name

Exceptions
std::exceptionOn field not found.
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...
 
mrpt::utils::CObjectPtr 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...
 
CObjectclone () const
 Cloning interface for smart pointers. More...
 

Static Public Member Functions

static voidoperator new (size_t size, void *ptr)
 

Static Public Attributes

static const mrpt::utils::TRuntimeClassId classCObject
 
RTTI stuff
static const mrpt::utils::TRuntimeClassId classCSerializable
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version)
 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

typedef CSimpleDatabaseTablePtr Ptr
 
typedef CSimpleDatabaseTablePtr ConstPtr
 
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
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class. More...
 
static mrpt::utils::CObjectCreateObject ()
 
static CSimpleDatabaseTablePtr Create ()
 

Member Typedef Documentation

typedef CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabaseTable::ConstPtr

Definition at line 32 of file CSimpleDatabase.h.

typedef CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabaseTable::Ptr

A typedef for the associated smart pointer

Definition at line 32 of file CSimpleDatabase.h.

Constructor & Destructor Documentation

CSimpleDatabaseTable::CSimpleDatabaseTable ( )

Default constructor.

Definition at line 233 of file CSimpleDatabase.cpp.

CSimpleDatabaseTable::~CSimpleDatabaseTable ( )
virtual

Destructor.

Definition at line 240 of file CSimpleDatabase.cpp.

Member Function Documentation

static const mrpt::utils::TRuntimeClassId* mrpt::utils::CSimpleDatabaseTable::_GetBaseClass ( )
staticprotected
void CSimpleDatabaseTable::addField ( const char *  fieldName)

Add a new field to the table.

The table is cleared in this operation.

Definition at line 255 of file CSimpleDatabase.cpp.

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.

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

CObject* mrpt::utils::CObject::clone ( ) const
inlineinherited

Cloning interface for smart pointers.

Definition at line 143 of file CObject.h.

static CSimpleDatabaseTablePtr mrpt::utils::CSimpleDatabaseTable::Create ( )
static
static mrpt::utils::CObject* mrpt::utils::CSimpleDatabaseTable::CreateObject ( )
static
void CSimpleDatabaseTable::deleteRecord ( size_t  recordIndex)

Delete the record at the given index.

See also
appendRecord

Definition at line 404 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

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

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

mrpt::utils::CObjectPtr mrpt::utils::CObject::duplicateGetSmartPtr ( ) const
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 140 of file CObject.h.

Referenced by mrpt::obs::CRawlog::addActions(), mrpt::slam::CIncrementalMapPartitioner::addMapFrame(), and mrpt::obs::CRawlog::addObservations().

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

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

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.

size_t CSimpleDatabaseTable::fieldsCount ( ) const

Get the count of fields.

Definition at line 247 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".

Exceptions
std::exceptionOn field or record not found

Definition at line 303 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.

Exceptions
std::exceptionOn field or record not found

Definition at line 316 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

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

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

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

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

Definition at line 32 of file CSimpleDatabase.h.

void mrpt::utils::CSimpleDatabaseTable::operator delete ( void ptr)
throw (
)
inline

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 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 363 of file CSimpleDatabase.cpp.

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

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

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

References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION.

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

Exceptions
std::exceptionOn field or record not found

Definition at line 346 of file CSimpleDatabase.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

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 NULL is class does not support conversion to MATLAB.

Definition at line 79 of file CSerializable.h.

References BASE_IMPEXP, DEFINE_MRPT_OBJECT_POST, mrpt::utils::ObjectToOctetVector(), mrpt::utils::ObjectToRawString(), mrpt::utils::ObjectToString(), mrpt::utils::OctetVectorToObject(), mrpt::utils::RawStringToObject(), and mrpt::utils::StringToObject().

Referenced by mrpt::poses::operator<<(), mrpt::utils::TCamera::readFromStream(), mrpt::obs::CObservationImage::readFromStream(), mrpt::obs::CObservationStereoImages::readFromStream(), mrpt::obs::CObservation2DRangeScan::readFromStream(), and mrpt::utils::CImage::readFromStream().

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

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 NULL, 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 88 of file CSimpleDatabase.cpp.

Member Data Documentation

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

Definition at line 32 of file CSimpleDatabase.h.

const mrpt::utils::TRuntimeClassId mrpt::utils::CObject::classCObject
staticinherited

Definition at line 128 of file CObject.h.

const mrpt::utils::TRuntimeClassId mrpt::utils::CSerializable::classCSerializable
staticinherited

Definition at line 42 of file CSerializable.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Definition at line 32 of file CSimpleDatabase.h.

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

Data for each cell.

Definition at line 109 of file CSimpleDatabase.h.

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

Field names.

Definition at line 108 of file CSimpleDatabase.h.




Page generated by Doxygen 1.8.11 for MRPT 1.5.7 Git: 2190203 Tue May 15 02:01:15 2018 +0200 at miƩ may 16 12:40:16 CEST 2018