This namespace provides a OS-independent interface to many useful functions: filenames manipulation, time and date, string parsing, file I/O, threading, memory allocation, etc.
Namespaces | |
namespace | detail |
Auxiliary classes used internally to MRPT. | |
namespace | os |
This namespace provides a OS-independent interface to low-level functions. | |
Classes | |
class | CDirectoryExplorer |
This class allows the enumeration of the files/directories that exist into a given path. More... | |
class | CFileSystemWatcher |
This class subscribes to notifications of file system changes, thus it can be used to efficiently stay informed about changes in a directory tree. More... | |
struct | TTimeParts |
The parts of a date/time (it's like the standard 'tm' but with fractions of seconds). More... | |
struct | TThreadHandle |
This structure contains the information needed to interface the threads API on each platform: More... | |
Enumerations | |
enum | TConsoleColor { CONCOL_NORMAL = 0, CONCOL_BLUE = 1, CONCOL_GREEN = 2, CONCOL_RED = 4 } |
For use in setConsoleColor. More... | |
Functions | |
std::string BASE_IMPEXP | MRPT_getVersion () |
Returns a string describing the MRPT version including the SVN number. | |
unsigned long BASE_IMPEXP | getMemoryUsage () |
Returns the memory occupied by this process, in bytes. | |
void BASE_IMPEXP | pause (const std::string &msg=std::string("Press any key to continue...")) MRPT_NO_THROWS |
Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed. | |
void BASE_IMPEXP | clearConsole () |
Clears the console window. | |
bool BASE_IMPEXP | vectorToTextFile (const std::vector< float > &vec, const std::string &fileName, bool append=false, bool byRows=false) |
A useful function for debuging, which saves a std::vector into a text file (compat. | |
bool BASE_IMPEXP | vectorToTextFile (const std::vector< double > &vec, const std::string &fileName, bool append=false, bool byRows=false) |
bool BASE_IMPEXP | vectorToTextFile (const std::vector< int > &vec, const std::string &fileName, bool append=false, bool byRows=false) |
bool BASE_IMPEXP | vectorToTextFile (const std::vector< size_t > &vec, const std::string &fileName, bool append=false, bool byRows=false) |
template<class Derived > | |
bool | vectorToTextFile (const Eigen::MatrixBase< Derived > &vec, const std::string &fileName) |
bool BASE_IMPEXP | vectorFromTextFile (std::vector< double > &vec, const std::string &fileName, const bool byRows=false) |
Load a std::vector from a text file (compat. | |
bool BASE_IMPEXP | vectorToBinaryFile (const vector_byte &vec, const std::string &fileName) |
Saves a vector directly as a binary dump to a file: | |
bool BASE_IMPEXP | loadBinaryFile (vector_byte &out_data, const std::string &fileName) |
Loads a entire file as a vector of bytes. | |
std::string BASE_IMPEXP | MRPT_getCompilationDate () |
Returns the MRPT compilation date. | |
void BASE_IMPEXP | registerFatalExceptionHandlers () |
Call this to register handlers for fatal erros (memory access,etc) that show useful debug information (It is called automatically normally, no need for the user to explicitly call this method.). | |
std::string BASE_IMPEXP | stack_trace (bool calling_from_exception=false) |
Dumps the current program stack with detailed information of source files and lines. | |
void BASE_IMPEXP | setConsoleColor (TConsoleColor color, bool changeStdErr=false) |
Changes the text color in the console for the text written from now on. | |
Directories, files, and file names | |
std::string BASE_IMPEXP | getTempFileName () |
Returns the name of a proposed temporary file name. | |
std::string BASE_IMPEXP | getcwd () |
Returns the current working directory. | |
bool BASE_IMPEXP | createDirectory (const std::string &dirName) |
Creates a directory. | |
bool BASE_IMPEXP | deleteFile (const std::string &fileName) |
Deletes a single file. | |
void BASE_IMPEXP | deleteFiles (const std::string &s) |
Delete one or more files, especified by the (optional) path and the file name (including '?' or '*') - Use forward slash ('/') for directories for compatibility between Windows and Linux, since they will be internally traslated into backward slashes ('\') if MRPT is compiled under Windows. | |
bool BASE_IMPEXP | renameFile (const std::string &oldFileName, const std::string &newFileName, std::string *error_msg=NULL) |
Renames a file - If the target path is different and the filesystem allows it, it will be moved to the new location. | |
bool BASE_IMPEXP | deleteFilesInDirectory (const std::string &s, bool deleteDirectoryAsWell=false) |
Delete all the files in a given directory (nothing done if directory does not exists, or path is a file). | |
std::string BASE_IMPEXP | extractFileName (const std::string &filePath) |
Extract just the name (without extension) of a filename from a complete path plus name plus extension. | |
std::string BASE_IMPEXP | extractFileExtension (const std::string &filePath, bool ignore_gz=false) |
Extract the extension of a filename. | |
std::string BASE_IMPEXP | extractFileDirectory (const std::string &filePath) |
Extract the whole path (the directory) of a filename from a complete path plus name plus extension. | |
bool BASE_IMPEXP | fileExists (const std::string &fileName) |
Test if a given file (or directory) exists. | |
bool BASE_IMPEXP | directoryExists (const std::string &fileName) |
Test if a given directory exists (it fails if the given path refers to an existing file). | |
std::string BASE_IMPEXP | fileNameStripInvalidChars (const std::string &filename) |
Replace invalid filename chars by underscores ('_'). | |
std::string BASE_IMPEXP | fileNameChangeExtension (const std::string &filename, const std::string &newExtension) |
Replace the filename extension by another one. | |
uint64_t BASE_IMPEXP | getFileSize (const std::string &fileName) |
Return the size of the given file, or size_t(-1) if some error is found accessing that file. | |
String management and utilities | |
char BASE_IMPEXP * | strtok (char *str, const char *strDelimit, char **context) MRPT_NO_THROWS |
An OS-independent method for tokenizing a string. | |
void BASE_IMPEXP | tokenize (const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens) MRPT_NO_THROWS |
Tokenizes a string according to a set of delimiting characters. | |
void BASE_IMPEXP | tokenize (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens) MRPT_NO_THROWS |
Tokenizes a string according to a set of delimiting characters. | |
std::string BASE_IMPEXP | trim (const std::string &str) |
Removes leading and trailing spaces. | |
std::string BASE_IMPEXP | upperCase (const std::string &str) |
Returns a lower-case version of a string. | |
std::string BASE_IMPEXP | lowerCase (const std::string &str) |
Returns an upper-case version of a string. | |
void BASE_IMPEXP | decodeUTF8 (const std::string &strUTF8, vector_word &out_uniStr) |
Decodes a UTF-8 string into an UNICODE string. | |
void BASE_IMPEXP | encodeUTF8 (const vector_word &input, std::string &output) |
Encodes a 2-bytes UNICODE string into a UTF-8 string. | |
void BASE_IMPEXP | encodeBase64 (const vector_byte &inputData, std::string &outString) |
Encode a sequence of bytes as a string in base-64. | |
bool BASE_IMPEXP | decodeBase64 (const std::string &inString, vector_byte &outData) |
Decode a base-64 string into the original sequence of bytes. | |
std::string BASE_IMPEXP | unitsFormat (const double val, int nDecimalDigits=2, bool middle_space=true) |
This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'. | |
std::string BASE_IMPEXP | rightPad (const std::string &str, const size_t total_len, bool truncate_if_larger=false) |
Enlarge the string with spaces up to the given length. | |
bool BASE_IMPEXP | strCmp (const std::string &s1, const std::string &s2) |
Return true if the two strings are equal (case sensitive) | |
bool BASE_IMPEXP | strCmpI (const std::string &s1, const std::string &s2) |
Return true if the two strings are equal (case insensitive) | |
bool BASE_IMPEXP | strStarts (const std::string &str, const std::string &subStr) |
Return true if "str" starts with "subStr" (case sensitive) | |
bool BASE_IMPEXP | strStartsI (const std::string &str, const std::string &subStr) |
Return true if "str" starts with "subStr" (case insensitive) | |
Threads | |
enum | TProcessPriority { ppIdle = 0, ppNormal, ppHigh, ppVeryHigh } |
The type for cross-platform process (application) priorities. More... | |
enum | TThreadPriority { tpLowests = -15, tpLower = -2, tpLow = -1, tpNormal = 0, tpHigh = 1, tpHigher = 2, tpHighest = 15 } |
The type for cross-platform thread priorities. More... | |
template<typename T > | |
TThreadHandle | createThread (void(*func)(T), T param) |
Creates a new thread from a function (or static method) with one generic parameter. | |
template<typename T > | |
TThreadHandle | createThreadRef (void(*func)(T &), T ¶m) |
TThreadHandle | createThread (void(*func)(void)) |
template<typename CLASS , typename PARAM > | |
TThreadHandle | createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(PARAM), PARAM param) |
Creates a new thread running a non-static method (so it will have access to "this") from another method of the same class - with one generic parameter. | |
template<typename CLASS , typename PARAM > | |
TThreadHandle | createThreadFromObjectMethodRef (CLASS *obj, void(CLASS::*func)(PARAM), PARAM ¶m) |
template<typename CLASS > | |
TThreadHandle | createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(void)) |
void BASE_IMPEXP | joinThread (const TThreadHandle &threadHandle) |
Waits until the given thread ends. | |
unsigned long BASE_IMPEXP | getCurrentThreadId () MRPT_NO_THROWS |
Returns the ID of the current thread. | |
TThreadHandle BASE_IMPEXP | getCurrentThreadHandle () MRPT_NO_THROWS |
Returns a handle to the current thread. | |
void BASE_IMPEXP | exitThread () MRPT_NO_THROWS |
Explicit close of the current (running) thread. | |
void BASE_IMPEXP | getCurrentThreadTimes (time_t &creationTime, time_t &exitTime, double &cpuTime) |
Returns the creation and exit times of the current thread and its CPU time consumed. | |
void BASE_IMPEXP | changeThreadPriority (const TThreadHandle &threadHandle, TThreadPriority priority) |
Change the priority of the given thread. | |
void BASE_IMPEXP | terminateThread (TThreadHandle &threadHandle) MRPT_NO_THROWS |
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource) | |
void BASE_IMPEXP | changeCurrentProcessPriority (TProcessPriority priority) |
Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread). | |
unsigned int BASE_IMPEXP | getNumberOfProcessors () |
Return the number of processors ("cores"), or 1 if it cannot be determined. | |
void BASE_IMPEXP | sleep (int time_ms) MRPT_NO_THROWS |
An OS-independent method for sending the current thread to "sleep" for a given period of time. | |
bool BASE_IMPEXP | launchProcess (const std::string &command) |
Executes the given command (which may contain a program + arguments), and waits until it finishes. | |
Time and date functions | |
typedef uint64_t | TTimeStamp |
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1, 1601 (UTC). | |
mrpt::system::TTimeStamp BASE_IMPEXP | buildTimestampFromParts (const mrpt::system::TTimeParts &p) |
Builds a timestamp from the parts (Parts are in UTC) | |
mrpt::system::TTimeStamp BASE_IMPEXP | buildTimestampFromPartsLocalTime (const mrpt::system::TTimeParts &p) |
Builds a timestamp from the parts (Parts are in local time) | |
void BASE_IMPEXP | timestampToParts (TTimeStamp t, TTimeParts &p, bool localTime=false) |
Gets the individual parts of a date/time (days, hours, minutes, seconds) - UTC time or local time. | |
mrpt::system::TTimeStamp BASE_IMPEXP | getCurrentTime () |
Returns the current (UTC) system time. | |
mrpt::system::TTimeStamp | now () |
A shortcut for system::getCurrentTime. | |
mrpt::system::TTimeStamp BASE_IMPEXP | getCurrentLocalTime () |
Returns the current (local) time. | |
mrpt::system::TTimeStamp BASE_IMPEXP | time_tToTimestamp (const double &t) |
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to TTimeStamp. | |
mrpt::system::TTimeStamp BASE_IMPEXP | time_tToTimestamp (const time_t &t) |
Transform from standard "time_t" to TTimeStamp. | |
double BASE_IMPEXP | timestampTotime_t (const mrpt::system::TTimeStamp &t) |
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds). | |
double | timestampToDouble (const mrpt::system::TTimeStamp &t) |
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds). | |
double BASE_IMPEXP | timeDifference (const mrpt::system::TTimeStamp &t_first, const mrpt::system::TTimeStamp &t_later) |
Retuns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds. | |
mrpt::system::TTimeStamp BASE_IMPEXP | secondsToTimestamp (const double &nSeconds) |
Transform a time interval (in seconds) into TTimeStamp (e.g. | |
std::string BASE_IMPEXP | formatTimeInterval (const double &timeSeconds) |
Returns a formated string with the given time difference (passed as the number of seconds), as a string [H]H:MM:SS.MILISECS. | |
std::string BASE_IMPEXP | dateTimeToString (const mrpt::system::TTimeStamp &t) |
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM. | |
std::string BASE_IMPEXP | dateTimeLocalToString (const mrpt::system::TTimeStamp &t) |
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM. | |
std::string BASE_IMPEXP | dateToString (const mrpt::system::TTimeStamp &t) |
Convert a timestamp into this textual form: YEAR/MONTH/DAY. | |
double BASE_IMPEXP | extractDayTimeFromTimestamp (const mrpt::system::TTimeStamp &t) |
Returns the number of seconds ellapsed from midnight in the given timestamp. | |
std::string BASE_IMPEXP | timeToString (const mrpt::system::TTimeStamp &t) |
Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM. | |
std::string BASE_IMPEXP | timeLocalToString (const mrpt::system::TTimeStamp &t, unsigned int secondFractionDigits=6) |
Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM. | |
std::string BASE_IMPEXP | intervalFormat (const double seconds) |
This function implements time interval formatting: Given a time in seconds, it will return a string describing the interval with the most appropriate unit. |
typedef uint64_t mrpt::system::TTimeStamp |
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1, 1601 (UTC).
Definition at line 46 of file datetime.h.
The type for cross-platform process (application) priorities.
The type for cross-platform thread priorities.
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::buildTimestampFromParts | ( | const mrpt::system::TTimeParts & | p ) |
Builds a timestamp from the parts (Parts are in UTC)
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::buildTimestampFromPartsLocalTime | ( | const mrpt::system::TTimeParts & | p ) |
Builds a timestamp from the parts (Parts are in local time)
void BASE_IMPEXP mrpt::system::changeCurrentProcessPriority | ( | TProcessPriority | priority ) |
Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread).
void BASE_IMPEXP mrpt::system::changeThreadPriority | ( | const TThreadHandle & | threadHandle, |
TThreadPriority | priority | ||
) |
Change the priority of the given thread.
void BASE_IMPEXP mrpt::system::clearConsole | ( | ) |
Clears the console window.
bool BASE_IMPEXP mrpt::system::createDirectory | ( | const std::string & | dirName ) |
Creates a directory.
TThreadHandle mrpt::system::createThread | ( | void(*)(void) | func ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 207 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctorNoParams::createThread().
TThreadHandle mrpt::system::createThread | ( | void(*)(T) | func, |
T | param | ||
) | [inline] |
Creates a new thread from a function (or static method) with one generic parameter.
This function creates, and start, a new thread running some code given by a function. The thread function should end by returning as normal.
func | The function with the code to run in the thread. |
param | The parameter to be passed to the new thread function. |
std::exception | If the operation fails |
Definition at line 199 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctor< T >::createThread().
TThreadHandle mrpt::system::createThreadFromObjectMethod | ( | CLASS * | obj, |
void(CLASS::*)(PARAM) | func, | ||
PARAM | param | ||
) | [inline] |
Creates a new thread running a non-static method (so it will have access to "this") from another method of the same class - with one generic parameter.
This function creates, and start, a new thread running some code given by a function. The thread function should end by returning as normal. Example of usage:
class MyClass { public: void myThread(int n); void someMethod() { createThreadFromObjectMethod(this, &MyClass::myThread, 123 ); .... } };
func | The function with the code to run in the thread. |
param | The parameter to be passed to the new thread function. |
std::exception | If the operation fails |
Definition at line 234 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctor< CLASS, PARAM >::createThread().
TThreadHandle mrpt::system::createThreadFromObjectMethod | ( | CLASS * | obj, |
void(CLASS::*)(void) | func | ||
) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 244 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctorNoParams< CLASS >::createThread().
TThreadHandle mrpt::system::createThreadFromObjectMethodRef | ( | CLASS * | obj, |
void(CLASS::*)(PARAM) | func, | ||
PARAM & | param | ||
) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 239 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctor< CLASS, PARAM >::createThread().
TThreadHandle mrpt::system::createThreadRef | ( | void(*)(T &) | func, |
T & | param | ||
) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 203 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctor< T >::createThread().
std::string BASE_IMPEXP mrpt::system::dateTimeLocalToString | ( | const mrpt::system::TTimeStamp & | t ) |
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
std::string BASE_IMPEXP mrpt::system::dateTimeToString | ( | const mrpt::system::TTimeStamp & | t ) |
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
std::string BASE_IMPEXP mrpt::system::dateToString | ( | const mrpt::system::TTimeStamp & | t ) |
Convert a timestamp into this textual form: YEAR/MONTH/DAY.
bool BASE_IMPEXP mrpt::system::decodeBase64 | ( | const std::string & | inString, |
vector_byte & | outData | ||
) |
Decode a base-64 string into the original sequence of bytes.
void BASE_IMPEXP mrpt::system::decodeUTF8 | ( | const std::string & | strUTF8, |
vector_word & | out_uniStr | ||
) |
Decodes a UTF-8 string into an UNICODE string.
See http://en.wikipedia.org/wiki/UTF-8 and http://www.codeguru.com/cpp/misc/misc/multi-lingualsupport/article.php/c10451/.
bool BASE_IMPEXP mrpt::system::deleteFile | ( | const std::string & | fileName ) |
Deletes a single file.
For multiple files see deleteFiles
void BASE_IMPEXP mrpt::system::deleteFiles | ( | const std::string & | s ) |
Delete one or more files, especified by the (optional) path and the file name (including '?' or '*') - Use forward slash ('/') for directories for compatibility between Windows and Linux, since they will be internally traslated into backward slashes ('\') if MRPT is compiled under Windows.
bool BASE_IMPEXP mrpt::system::deleteFilesInDirectory | ( | const std::string & | s, |
bool | deleteDirectoryAsWell = false |
||
) |
Delete all the files in a given directory (nothing done if directory does not exists, or path is a file).
bool BASE_IMPEXP mrpt::system::directoryExists | ( | const std::string & | fileName ) |
Test if a given directory exists (it fails if the given path refers to an existing file).
void BASE_IMPEXP mrpt::system::encodeBase64 | ( | const vector_byte & | inputData, |
std::string & | outString | ||
) |
Encode a sequence of bytes as a string in base-64.
void BASE_IMPEXP mrpt::system::encodeUTF8 | ( | const vector_word & | input, |
std::string & | output | ||
) |
Encodes a 2-bytes UNICODE string into a UTF-8 string.
See http://en.wikipedia.org/wiki/UTF-8 and http://www.codeguru.com/cpp/misc/misc/multi-lingualsupport/article.php/c10451/.
void BASE_IMPEXP mrpt::system::exitThread | ( | ) |
Explicit close of the current (running) thread.
Do not use normally, it's better just to return from the running thread function.
double BASE_IMPEXP mrpt::system::extractDayTimeFromTimestamp | ( | const mrpt::system::TTimeStamp & | t ) |
Returns the number of seconds ellapsed from midnight in the given timestamp.
std::string BASE_IMPEXP mrpt::system::extractFileDirectory | ( | const std::string & | filePath ) |
Extract the whole path (the directory) of a filename from a complete path plus name plus extension.
This function works for either "/" or "\" directory separators.
std::string BASE_IMPEXP mrpt::system::extractFileExtension | ( | const std::string & | filePath, |
bool | ignore_gz = false |
||
) |
Extract the extension of a filename.
For example, for "dummy.cpp", it will return "cpp". If "ignore_gz" is true, the second extension will be returned if the file name ends in ".gz", for example, for "foo.map.gz", this will return "map".
std::string BASE_IMPEXP mrpt::system::extractFileName | ( | const std::string & | filePath ) |
Extract just the name (without extension) of a filename from a complete path plus name plus extension.
This function works for either "/" or "\" directory separators.
bool BASE_IMPEXP mrpt::system::fileExists | ( | const std::string & | fileName ) |
Test if a given file (or directory) exists.
std::string BASE_IMPEXP mrpt::system::fileNameChangeExtension | ( | const std::string & | filename, |
const std::string & | newExtension | ||
) |
Replace the filename extension by another one.
Example:
fileNameChangeExtension("cool.txt","bar") // -> "cool.bar"
std::string BASE_IMPEXP mrpt::system::fileNameStripInvalidChars | ( | const std::string & | filename ) |
Replace invalid filename chars by underscores ('_').
Invalid chars are identified by those not being alphanumeric or: ".-#%$&()+[]{}"
std::string BASE_IMPEXP mrpt::system::formatTimeInterval | ( | const double & | timeSeconds ) |
Returns a formated string with the given time difference (passed as the number of seconds), as a string [H]H:MM:SS.MILISECS.
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::getCurrentLocalTime | ( | ) |
Returns the current (local) time.
TThreadHandle BASE_IMPEXP mrpt::system::getCurrentThreadHandle | ( | ) |
Returns a handle to the current thread.
unsigned long BASE_IMPEXP mrpt::system::getCurrentThreadId | ( | ) |
Returns the ID of the current thread.
void BASE_IMPEXP mrpt::system::getCurrentThreadTimes | ( | time_t & | creationTime, |
time_t & | exitTime, | ||
double & | cpuTime | ||
) |
Returns the creation and exit times of the current thread and its CPU time consumed.
creationTime | The creation time of the thread. |
exitTime | The exit time of the thread, or undefined if it is still running. |
cpuTime | The CPU time consumed by the thread, in seconds. |
std::exception | If the operation fails |
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::getCurrentTime | ( | ) |
std::string BASE_IMPEXP mrpt::system::getcwd | ( | ) |
Returns the current working directory.
uint64_t BASE_IMPEXP mrpt::system::getFileSize | ( | const std::string & | fileName ) |
Return the size of the given file, or size_t(-1) if some error is found accessing that file.
unsigned long BASE_IMPEXP mrpt::system::getMemoryUsage | ( | ) |
Returns the memory occupied by this process, in bytes.
unsigned int BASE_IMPEXP mrpt::system::getNumberOfProcessors | ( | ) |
Return the number of processors ("cores"), or 1 if it cannot be determined.
std::string BASE_IMPEXP mrpt::system::getTempFileName | ( | ) |
Returns the name of a proposed temporary file name.
std::string BASE_IMPEXP mrpt::system::intervalFormat | ( | const double | seconds ) |
This function implements time interval formatting: Given a time in seconds, it will return a string describing the interval with the most appropriate unit.
E.g.: 1.23 year, 3.50 days, 9.3 hours, 5.3 minutes, 3.34 sec, 178.1 ms, 87.1 us.
void BASE_IMPEXP mrpt::system::joinThread | ( | const TThreadHandle & | threadHandle ) |
Waits until the given thread ends.
bool BASE_IMPEXP mrpt::system::launchProcess | ( | const std::string & | command ) |
Executes the given command (which may contain a program + arguments), and waits until it finishes.
bool BASE_IMPEXP mrpt::system::loadBinaryFile | ( | vector_byte & | out_data, |
const std::string & | fileName | ||
) |
Loads a entire file as a vector of bytes.
std::string BASE_IMPEXP mrpt::system::lowerCase | ( | const std::string & | str ) |
Returns an upper-case version of a string.
std::string BASE_IMPEXP mrpt::system::MRPT_getCompilationDate | ( | ) |
Returns the MRPT compilation date.
std::string BASE_IMPEXP mrpt::system::MRPT_getVersion | ( | ) |
Returns a string describing the MRPT version including the SVN number.
Referenced by MatrixBase< Derived >::saveToTextFile().
mrpt::system::TTimeStamp mrpt::system::now | ( | ) | [inline] |
A shortcut for system::getCurrentTime.
Definition at line 86 of file datetime.h.
References getCurrentTime().
void BASE_IMPEXP mrpt::system::pause | ( | const std::string & | msg = std::string("Press any key to continue...") ) |
Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed.
void BASE_IMPEXP mrpt::system::registerFatalExceptionHandlers | ( | ) |
Call this to register handlers for fatal erros (memory access,etc) that show useful debug information (It is called automatically normally, no need for the user to explicitly call this method.).
bool BASE_IMPEXP mrpt::system::renameFile | ( | const std::string & | oldFileName, |
const std::string & | newFileName, | ||
std::string * | error_msg = NULL |
||
) |
Renames a file - If the target path is different and the filesystem allows it, it will be moved to the new location.
std::string BASE_IMPEXP mrpt::system::rightPad | ( | const std::string & | str, |
const size_t | total_len, | ||
bool | truncate_if_larger = false |
||
) |
Enlarge the string with spaces up to the given length.
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::secondsToTimestamp | ( | const double & | nSeconds ) |
Transform a time interval (in seconds) into TTimeStamp (e.g.
which can be added to an existing valid timestamp)
void BASE_IMPEXP mrpt::system::setConsoleColor | ( | TConsoleColor | color, |
bool | changeStdErr = false |
||
) |
Changes the text color in the console for the text written from now on.
The parameter "color" can be any value in TConsoleColor.
By default the color of "cout" is changed, unless changeStdErr=true, in which case "cerr" is changed.
void BASE_IMPEXP mrpt::system::sleep | ( | int | time_ms ) |
An OS-independent method for sending the current thread to "sleep" for a given period of time.
time_ms | The sleep period, in miliseconds. |
std::string BASE_IMPEXP mrpt::system::stack_trace | ( | bool | calling_from_exception = false ) |
Dumps the current program stack with detailed information of source files and lines.
This function requires MRPT linked against wxWidgets. Otherwise, an empty string is returned. File names and lines won't be available in release builds.
bool BASE_IMPEXP mrpt::system::strCmp | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if the two strings are equal (case sensitive)
bool BASE_IMPEXP mrpt::system::strCmpI | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Return true if the two strings are equal (case insensitive)
bool BASE_IMPEXP mrpt::system::strStarts | ( | const std::string & | str, |
const std::string & | subStr | ||
) |
Return true if "str" starts with "subStr" (case sensitive)
Referenced by mrpt::utils::CTextFileLinesParser::getNextLine().
bool BASE_IMPEXP mrpt::system::strStartsI | ( | const std::string & | str, |
const std::string & | subStr | ||
) |
Return true if "str" starts with "subStr" (case insensitive)
char BASE_IMPEXP* mrpt::system::strtok | ( | char * | str, |
const char * | strDelimit, | ||
char ** | context | ||
) |
An OS-independent method for tokenizing a string.
The extra parameter "context" must be a pointer to a "char*" variable, which needs no initialization and is used to save information between calls to strtok.
void BASE_IMPEXP mrpt::system::terminateThread | ( | TThreadHandle & | threadHandle ) |
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource)
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::time_tToTimestamp | ( | const double & | t ) |
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to TTimeStamp.
mrpt::system::TTimeStamp BASE_IMPEXP mrpt::system::time_tToTimestamp | ( | const time_t & | t ) |
Transform from standard "time_t" to TTimeStamp.
double BASE_IMPEXP mrpt::system::timeDifference | ( | const mrpt::system::TTimeStamp & | t_first, |
const mrpt::system::TTimeStamp & | t_later | ||
) |
Retuns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds.
std::string BASE_IMPEXP mrpt::system::timeLocalToString | ( | const mrpt::system::TTimeStamp & | t, |
unsigned int | secondFractionDigits = 6 |
||
) |
Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM.
double mrpt::system::timestampToDouble | ( | const mrpt::system::TTimeStamp & | t ) | [inline] |
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds).
This function is just an (inline) alias of timestampTotime_t(), with a more significant name.
Definition at line 114 of file datetime.h.
References timestampTotime_t().
void BASE_IMPEXP mrpt::system::timestampToParts | ( | TTimeStamp | t, |
TTimeParts & | p, | ||
bool | localTime = false |
||
) |
Gets the individual parts of a date/time (days, hours, minutes, seconds) - UTC time or local time.
double BASE_IMPEXP mrpt::system::timestampTotime_t | ( | const mrpt::system::TTimeStamp & | t ) |
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds).
Referenced by timestampToDouble().
std::string BASE_IMPEXP mrpt::system::timeToString | ( | const mrpt::system::TTimeStamp & | t ) |
Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM.
void BASE_IMPEXP mrpt::system::tokenize | ( | const std::string & | inString, |
const std::string & | inDelimiters, | ||
std::vector< std::string > & | outTokens | ||
) |
Tokenizes a string according to a set of delimiting characters.
Example:
std::vector<std::string> tokens; tokenize( " - Pepe-Er Muo"," -",tokens);
Will generate 3 tokens:
void BASE_IMPEXP mrpt::system::tokenize | ( | const std::string & | inString, |
const std::string & | inDelimiters, | ||
std::deque< std::string > & | outTokens | ||
) |
Tokenizes a string according to a set of delimiting characters.
Example:
std::vector<std::string> tokens; tokenize( " - Pepe-Er Muo"," -",tokens);
Will generate 3 tokens:
Referenced by mrpt::utils::CConfigFileBase::read_vector().
std::string BASE_IMPEXP mrpt::system::trim | ( | const std::string & | str ) |
Removes leading and trailing spaces.
Referenced by mrpt::utils::CTextFileLinesParser::getNextLine().
std::string BASE_IMPEXP mrpt::system::unitsFormat | ( | const double | val, |
int | nDecimalDigits = 2 , |
||
bool | middle_space = true |
||
) |
This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'.
std::string BASE_IMPEXP mrpt::system::upperCase | ( | const std::string & | str ) |
Returns a lower-case version of a string.
bool BASE_IMPEXP mrpt::system::vectorFromTextFile | ( | std::vector< double > & | vec, |
const std::string & | fileName, | ||
const bool | byRows = false |
||
) |
Load a std::vector from a text file (compat.
with MATLAB)
bool BASE_IMPEXP mrpt::system::vectorToBinaryFile | ( | const vector_byte & | vec, |
const std::string & | fileName | ||
) |
Saves a vector directly as a binary dump to a file:
bool mrpt::system::vectorToTextFile | ( | const Eigen::MatrixBase< Derived > & | vec, |
const std::string & | fileName | ||
) |
bool BASE_IMPEXP mrpt::system::vectorToTextFile | ( | const std::vector< int > & | vec, |
const std::string & | fileName, | ||
bool | append = false , |
||
bool | byRows = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool BASE_IMPEXP mrpt::system::vectorToTextFile | ( | const std::vector< float > & | vec, |
const std::string & | fileName, | ||
bool | append = false , |
||
bool | byRows = false |
||
) |
A useful function for debuging, which saves a std::vector into a text file (compat.
with MATLAB)
Referenced by mrpt::bayes::CKalmanFilterCapable< 7, 3, 3, 7 >::runOneKalmanIteration().
bool BASE_IMPEXP mrpt::system::vectorToTextFile | ( | const std::vector< double > & | vec, |
const std::string & | fileName, | ||
bool | append = false , |
||
bool | byRows = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool BASE_IMPEXP mrpt::system::vectorToTextFile | ( | const std::vector< size_t > & | vec, |
const std::string & | fileName, | ||
bool | append = false , |
||
bool | byRows = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011 |