Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
mrpt::utils::CLog Class Reference

Detailed Description

A decorator of CStringList special for keeping logs.

Note
Class written by Vicente Arevalo

Definition at line 48 of file CLog.h.

#include <mrpt/utils/CLog.h>

Inheritance diagram for mrpt::utils::CLog:
Inheritance graph

Public Member Functions

 CLog ()
 
virtual ~CLog ()
 
void pushMessages (std::string message)
 push a message More...
 
void pushMessages (mrpt::utils::CStringList messages)
 push a list of messages More...
 
void popMessages (std::string &message)
 pop the current unpublished message (clear the content of "message") More...
 
void popMessages (mrpt::utils::CStringList &messages)
 pop all unpublished messages (clear the content of "messages") More...
 
void getMessages (size_t begin, size_t end, mrpt::utils::CStringList &messages)
 get messages from "begin" to "end" (clear the content of "messages") More...
 
void saveLog (std::string name)
 save the current log More...
 
void loadLog (std::string name)
 load a log (clear the previous content) More...
 
void clearLog ()
 clear the log content More...
 
void setLastMessageIndex (size_t index)
 change the last unpublished message. More...
 
size_t getLastMessageIndex ()
 get the current unpublished message index. More...
 

Protected Member Functions

void * operator new (size_t size)
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 
void * operator new[] (size_t size)
 
void operator delete (void *ptr) throw ()
 
void operator delete (void *memory, void *ptr) throw ()
 
void operator delete (void *ptr, const std::nothrow_t &) throw ()
 
void operator delete[] (void *ptr) throw ()
 
void add (const std::string &str)
 Appends a new string at the end of the string list. More...
 
CStringListoperator<< (const std::string &s)
 An alternative way of adding strings to the list. More...
 
void insert (size_t index, const std::string &str)
 Inserts a new item at a given position (0=insert at the beggining,1=put into the second position,...) More...
 
void set (size_t index, const std::string &str)
 Overwrites an existing position with a new value (0=first elements) More...
 
void set (const std::string &keyName, const std::string &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed. More...
 
void set (const std::string &keyName, const int &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed. More...
 
void set (const std::string &keyName, const float &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed. More...
 
void set (const std::string &keyName, const double &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed. More...
 
void set (const std::string &keyName, const bool &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed. More...
 
void clear ()
 Clear the whole list. More...
 
size_t size () const
 Returns the number of text lines in the list. More...
 
void remove (size_t index)
 Delete the element at a given position (0=first element) More...
 
bool find (const std::string &compareText, size_t foundIndex, bool caseSensitive=true) const
 Looks for a given string in the list, and returns its index, or returns "false" otherwise. More...
 
void get (size_t index, std::string &outText) const
 Returns one string from the line list. More...
 
std::string operator() (size_t index) const
 Returns one string from the line list. More...
 
std::string & operator() (size_t index)
 Returns a reference to one string from the line list. More...
 
void getText (std::string &outText) const
 Returns the whole string list as a single string with '\r
' characters for newlines. More...
 
std::string getText () const
 Returns the whole string list as a single string with '\r
' characters for newlines. More...
 
void setText (const std::string &inText)
 Fills the string list by parsing a single string with '\r', '
', or '\r
' characters indicatng newlines. More...
 
void loadFromFile (const std::string &fileName)
 Load the string list from a file. More...
 
void saveToFile (const std::string &fileName) const
 Save the string list to a file. More...
 
std::string get_string (const std::string &keyName)
 Returns the value of the given key ("key=value"). More...
 
float get_float (const std::string &keyName)
 Returns the value of the given key ("key=value"). More...
 
int get_int (const std::string &keyName)
 Returns the value of the given key ("key=value"). More...
 
double get_double (const std::string &keyName)
 Returns the value of the given key ("key=value"). More...
 
bool get_bool (const std::string &keyName)
 Returns the value of the given key ("key=value"). 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...
 
CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_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...
 
CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 Introduces a pure virtual method responsible for writing to a CStream. More...
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_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...
 

Static Protected Member Functions

static void * operator new (size_t size, void *ptr)
 

Protected Attributes

mrpt::synch::CCriticalSection semaphore
 
size_t last
 
std::deque< std::string > m_strings
 The internal list of strings. More...
 

Static Protected Attributes

static const mrpt::utils::TRuntimeClassId classCObject
 

RTTI stuff


typedef CStringListPtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CStringList
 
static mrpt::utils::TRuntimeClassId classCStringList
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
static mrpt::utils::CObjectCreateObject ()
 
static CStringListPtr Create ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const
 Returns information about the class of an object in runtime. More...
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 Returns a copy of the object, indepently of its class. More...
 

Member Typedef Documentation

◆ SmartPtr

typedef CStringListPtr mrpt::utils::CStringList::SmartPtr
inherited

A typedef for the associated smart pointer

Definition at line 35 of file CStringList.h.

Constructor & Destructor Documentation

◆ CLog()

mrpt::utils::CLog::CLog ( )

◆ ~CLog()

virtual mrpt::utils::CLog::~CLog ( )
virtual

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId* mrpt::utils::CStringList::_GetBaseClass ( )
staticprotectedinherited

◆ add()

void mrpt::utils::CStringList::add ( const std::string &  str)
inherited

Appends a new string at the end of the string list.

See also
insert,set

◆ clear()

void mrpt::utils::CStringList::clear ( )
inherited

Clear the whole list.

◆ clearLog()

void mrpt::utils::CLog::clearLog ( )

clear the log content

◆ clone()

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

Cloning interface for smart pointers.

Definition at line 139 of file CObject.h.

◆ Create()

static CStringListPtr mrpt::utils::CStringList::Create ( )
staticinherited

◆ CreateObject()

static mrpt::utils::CObject* mrpt::utils::CStringList::CreateObject ( )
staticinherited

◆ duplicate()

virtual mrpt::utils::CObject* mrpt::utils::CStringList::duplicate ( ) const
virtualinherited

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

Implements mrpt::utils::CObject.

◆ duplicateGetSmartPtr()

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 136 of file CObject.h.

◆ find()

bool mrpt::utils::CStringList::find ( const std::string &  compareText,
size_t  foundIndex,
bool  caseSensitive = true 
) const
inherited

Looks for a given string in the list, and returns its index, or returns "false" otherwise.

Returns
true if string has been found.

◆ get()

void mrpt::utils::CStringList::get ( size_t  index,
std::string &  outText 
) const
inherited

Returns one string from the line list.

◆ get_bool()

bool mrpt::utils::CStringList::get_bool ( const std::string &  keyName)
inherited

Returns the value of the given key ("key=value").

Exceptions
std::exceptionIf the key is not found in the string list.

◆ get_double()

double mrpt::utils::CStringList::get_double ( const std::string &  keyName)
inherited

Returns the value of the given key ("key=value").

Exceptions
std::exceptionIf the key is not found in the string list.

◆ get_float()

float mrpt::utils::CStringList::get_float ( const std::string &  keyName)
inherited

Returns the value of the given key ("key=value").

Exceptions
std::exceptionIf the key is not found in the string list.

◆ get_int()

int mrpt::utils::CStringList::get_int ( const std::string &  keyName)
inherited

Returns the value of the given key ("key=value").

Exceptions
std::exceptionIf the key is not found in the string list.

◆ get_string()

std::string mrpt::utils::CStringList::get_string ( const std::string &  keyName)
inherited

Returns the value of the given key ("key=value").

Exceptions
std::exceptionIf the key is not found in the string list.

◆ getLastMessageIndex()

size_t mrpt::utils::CLog::getLastMessageIndex ( )

get the current unpublished message index.

◆ getMessages()

void mrpt::utils::CLog::getMessages ( size_t  begin,
size_t  end,
mrpt::utils::CStringList messages 
)

get messages from "begin" to "end" (clear the content of "messages")

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId* mrpt::utils::CStringList::GetRuntimeClass ( ) const
virtualinherited

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

◆ getText() [1/2]

std::string mrpt::utils::CStringList::getText ( ) const
inlineinherited

Returns the whole string list as a single string with '\r
' characters for newlines.

Definition at line 116 of file CStringList.h.

◆ getText() [2/2]

void mrpt::utils::CStringList::getText ( std::string &  outText) const
inherited

Returns the whole string list as a single string with '\r
' characters for newlines.

◆ insert()

void mrpt::utils::CStringList::insert ( size_t  index,
const std::string &  str 
)
inherited

Inserts a new item at a given position (0=insert at the beggining,1=put into the second position,...)

See also
add,set

◆ loadFromFile()

void mrpt::utils::CStringList::loadFromFile ( const std::string &  fileName)
inherited

Load the string list from a file.

◆ loadLog()

void mrpt::utils::CLog::loadLog ( std::string  name)

load a log (clear the previous content)

◆ operator delete() [1/3]

void mrpt::utils::CStringList::operator delete ( void *  memory,
void *  ptr 
)
throw (
)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator delete() [2/3]

void mrpt::utils::CStringList::operator delete ( void *  ptr)
throw (
)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator delete() [3/3]

void mrpt::utils::CStringList::operator delete ( void *  ptr,
const std::nothrow_t &   
)
throw (
)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator delete[]()

void mrpt::utils::CStringList::operator delete[] ( void *  ptr)
throw (
)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator new() [1/3]

void* mrpt::utils::CStringList::operator new ( size_t  size)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator new() [2/3]

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

Definition at line 35 of file CStringList.h.

◆ operator new() [3/3]

static void* mrpt::utils::CStringList::operator new ( size_t  size,
void *  ptr 
)
inlinestaticinherited

Definition at line 35 of file CStringList.h.

◆ operator new[]()

void* mrpt::utils::CStringList::operator new[] ( size_t  size)
inlineinherited

Definition at line 35 of file CStringList.h.

◆ operator()() [1/2]

std::string& mrpt::utils::CStringList::operator() ( size_t  index)
inherited

Returns a reference to one string from the line list.

◆ operator()() [2/2]

std::string mrpt::utils::CStringList::operator() ( size_t  index) const
inherited

Returns one string from the line list.

◆ operator<<()

CStringList& mrpt::utils::CStringList::operator<< ( const std::string &  s)
inlineinherited

An alternative way of adding strings to the list.

Definition at line 66 of file CStringList.h.

◆ popMessages() [1/2]

void mrpt::utils::CLog::popMessages ( mrpt::utils::CStringList messages)

pop all unpublished messages (clear the content of "messages")

◆ popMessages() [2/2]

void mrpt::utils::CLog::popMessages ( std::string &  message)

pop the current unpublished message (clear the content of "message")

◆ pushMessages() [1/2]

void mrpt::utils::CLog::pushMessages ( mrpt::utils::CStringList  messages)

push a list of messages

◆ pushMessages() [2/2]

void mrpt::utils::CLog::pushMessages ( std::string  message)

push a message

◆ readFromStream()

void mrpt::utils::CStringList::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protectedvirtualinherited

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.

◆ remove()

void mrpt::utils::CStringList::remove ( size_t  index)
inherited

Delete the element at a given position (0=first element)

◆ saveLog()

void mrpt::utils::CLog::saveLog ( std::string  name)

save the current log

◆ saveToFile()

void mrpt::utils::CStringList::saveToFile ( const std::string &  fileName) const
inherited

Save the string list to a file.

◆ set() [1/6]

void mrpt::utils::CStringList::set ( const std::string &  keyName,
const bool &  value 
)
inherited

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

◆ set() [2/6]

void mrpt::utils::CStringList::set ( const std::string &  keyName,
const double &  value 
)
inherited

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

◆ set() [3/6]

void mrpt::utils::CStringList::set ( const std::string &  keyName,
const float &  value 
)
inherited

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

◆ set() [4/6]

void mrpt::utils::CStringList::set ( const std::string &  keyName,
const int &  value 
)
inherited

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

◆ set() [5/6]

void mrpt::utils::CStringList::set ( const std::string &  keyName,
const std::string &  value 
)
inherited

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

◆ set() [6/6]

void mrpt::utils::CStringList::set ( size_t  index,
const std::string &  str 
)
inherited

Overwrites an existing position with a new value (0=first elements)

See also
insert

◆ setLastMessageIndex()

void mrpt::utils::CLog::setLastMessageIndex ( size_t  index)

change the last unpublished message.

IMPORTANT: this function should not be used directly.

◆ setText()

void mrpt::utils::CStringList::setText ( const std::string &  inText)
inherited

Fills the string list by parsing a single string with '\r', '
', or '\r
' characters indicatng newlines.

◆ size()

size_t mrpt::utils::CStringList::size ( ) const
inherited

Returns the number of text lines in the list.

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

Definition at line 79 of file CSerializable.h.

◆ writeToStream()

void mrpt::utils::CStringList::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
protectedvirtualinherited

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.

Member Data Documentation

◆ _init_CStringList

mrpt::utils::CLASSINIT mrpt::utils::CStringList::_init_CStringList
staticprotectedinherited

Definition at line 35 of file CStringList.h.

◆ classCObject

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

Definition at line 124 of file CObject.h.

◆ classCSerializable

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

Definition at line 42 of file CSerializable.h.

◆ classCStringList

mrpt::utils::TRuntimeClassId mrpt::utils::CStringList::classCStringList
staticinherited

Definition at line 35 of file CStringList.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::utils::CStringList::classinfo
staticinherited

Definition at line 35 of file CStringList.h.

◆ last

size_t mrpt::utils::CLog::last
protected

Definition at line 106 of file CLog.h.

◆ m_strings

std::deque<std::string> mrpt::utils::CStringList::m_strings
protectedinherited

The internal list of strings.

Definition at line 40 of file CStringList.h.

◆ semaphore

mrpt::synch::CCriticalSection mrpt::utils::CLog::semaphore
protected

Definition at line 104 of file CLog.h.




Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Tue Mar 3 09:15:16 UTC 2020