#include <mrpt/config.h>#include <mrpt/utils/types.h>#include <cstdarg>#include <cstdlib>#include <cstring>#include <deque>#include <vector>#include <mrpt/utils/utils_impexp.h>Go to the source code of this file.
Classes | |
| struct | mrpt::system::TThreadHandle |
| This structure contains the information needed to interface the threads API on each platform:. More... | |
| struct | mrpt::system::TTimeParts |
| The parts of a date/time (it's like the standard 'tm' but with fractions of seconds). More... | |
Namespaces | |
| namespace | mrpt |
| The main namespace for all the Mobile Robot Programming Toolkit (MRPT) C++ libraries. | |
| namespace | mrpt::utils |
| Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. | |
| namespace | mrpt::system |
| 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. | |
| namespace | mrpt::system::os |
| This namespace provides a OS-independent interface to low-level functions. | |
Defines | |
| #define | _IAMINUTILSDEFS_H |
| #define | MRPT_printf_format_check(_FMT_, _VARARGS_) |
| #define | MRPT_scanf_format_check(_FMT_, _VARARGS_) |
| #define | MRPT_NO_THROWS throw() |
| Used after member declarations. | |
| #define | INVALID_TIMESTAMP (0) |
| Represents an invalid timestamp, where applicable. | |
| #define | mrpt_alloca(nBytes) ::malloc( nBytes ); |
| In platforms and compilers with support to "alloca", allocate a memory block on the stack; if alloca is not supported, it is emulated as a normal "malloc" - NOTICE: Since in some platforms alloca will be emulated with malloc, alloca_free MUST BE ALWAYS CALLED to avoid memory leaks. | |
| #define | mrpt_alloca_free(mem_block) free(mem_block) |
| This method must be called to "free" each memory block allocated with "system::alloca": If the block was really allocated in the stack, no operation is actually performed, otherwise it will be freed from the heap. | |
Functions | |
| int MRPTDLLIMPEXP | mrpt::system::os::sprintf (char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3 |
| An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compilers). | |
| int MRPTDLLIMPEXP int MRPTDLLIMPEXP | mrpt::system::os::vsprintf (char *buf, size_t bufSize, const char *format, va_list args) MRPT_NO_THROWS |
| An OS-independent version of vsprintf (Notice the bufSize param, which may be ignored in some compilers). | |
| int MRPTDLLIMPEXP | mrpt::system::os::vsnprintf (char *buf, size_t bufSize, const char *format, va_list args) MRPT_NO_THROWS |
| An OS-independent version of vsnprintf (Notice the bufSize param, which may be ignored in some compilers). | |
| FILE MRPTDLLIMPEXP * | mrpt::system::os::fopen (const char *fileName, const char *mode) MRPT_NO_THROWS |
| An OS-independent version of fopen. | |
| FILE MRPTDLLIMPEXP * | mrpt::system::os::fopen (const std::string &fileName, const char *mode) MRPT_NO_THROWS |
| An OS-independent version of fopen (std::string version). | |
| int MRPTDLLIMPEXP | mrpt::system::os::fprintf (FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2 |
| An OS-independent version of fprintf. | |
| int MRPTDLLIMPEXP int MRPTDLLIMPEXP | mrpt::system::os::fscanf (FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_scanf_format_check(2 |
| An OS-independent version of fscanf. | |
| int MRPTDLLIMPEXP int MRPTDLLIMPEXP void MRPTDLLIMPEXP | mrpt::system::os::fclose (FILE *f) MRPT_NO_THROWS |
| An OS-independent version of fclose. | |
| char MRPTDLLIMPEXP * | mrpt::system::os::strcat (char *dest, size_t destSize, const char *source) MRPT_NO_THROWS |
| An OS-independent version of strcat. | |
| char MRPTDLLIMPEXP * | mrpt::system::os::strcpy (char *dest, size_t destSize, const char *source) MRPT_NO_THROWS |
| An OS-independent version of strcpy. | |
| int MRPTDLLIMPEXP | mrpt::system::os::_strcmp (const char *str1, const char *str2) MRPT_NO_THROWS |
| An OS-independent version of strcmp. | |
| int MRPTDLLIMPEXP | mrpt::system::os::_strcmpi (const char *str1, const char *str2) MRPT_NO_THROWS |
| An OS-independent version of strcmpi. | |
| int64_t MRPTDLLIMPEXP | mrpt::system::os::_strtoll (const char *nptr, char **endptr, int base) |
| An OS-independent version of strtoll. | |
| uint64_t MRPTDLLIMPEXP | mrpt::system::os::_strtoull (const char *nptr, char **endptr, int base) |
| An OS-independent version of strtoull. | |
| void MRPTDLLIMPEXP | mrpt::system::os::memcpy (void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS |
| An OS and compiler independent version of "memcpy". | |
| int MRPTDLLIMPEXP | mrpt::system::os::getch () MRPT_NO_THROWS |
| An OS-independent version of getch, which waits until a key is pushed. | |
| bool MRPTDLLIMPEXP | mrpt::system::os::kbhit () MRPT_NO_THROWS |
| An OS-independent version of kbhit, which returns true if a key has been pushed. | |
| void MRPTDLLIMPEXP | mrpt::system::sleep (int time_ms) MRPT_NO_THROWS |
| An OS-independent method for sending the current thread to "sleep" for a given period of time. | |
| char MRPTDLLIMPEXP * | mrpt::system::strtok (char *str, const char *strDelimit, char **context) MRPT_NO_THROWS |
| An OS-independent method for tokenizing a string. | |
| void MRPTDLLIMPEXP | mrpt::system::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 MRPTDLLIMPEXP | mrpt::system::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 MRPTDLLIMPEXP | mrpt::system::trim (const std::string &str) |
| Removes leading and trailing spaces:. | |
| bool MRPTDLLIMPEXP | mrpt::system::isNaN (float f) MRPT_NO_THROWS |
| Returns true if the number is NaN. | |
| bool MRPTDLLIMPEXP | mrpt::system::isNaN (double f) MRPT_NO_THROWS |
| Returns true if the number is NaN. | |
| bool MRPTDLLIMPEXP | mrpt::system::isFinite (float f) MRPT_NO_THROWS |
| Returns true if the number is non infinity. | |
| bool MRPTDLLIMPEXP | mrpt::system::isFinite (double f) MRPT_NO_THROWS |
| Returns true if the number is non infinity. | |
| void MRPTDLLIMPEXP | mrpt::system::pause () MRPT_NO_THROWS |
| Shows the message "Press any key to continue" to the current standard output and returns when a key is pressed. | |
| void MRPTDLLIMPEXP | mrpt::system::clearConsole () |
| Clears the console window. | |
| bool MRPTDLLIMPEXP | 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. | |
| bool MRPTDLLIMPEXP | mrpt::system::vectorToTextFile (const std::vector< double > &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 MRPTDLLIMPEXP | mrpt::system::vectorToTextFile (const std::vector< int > &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 MRPTDLLIMPEXP | mrpt::system::vectorToTextFile (const std::vector< size_t > &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 MRPTDLLIMPEXP | mrpt::system::vectorToBinaryFile (const vector_byte &vec, const std::string &fileName) |
| Saves a vector directly as a binary dump to a file:. | |
| bool MRPTDLLIMPEXP | mrpt::system::loadBinaryFile (vector_byte &out_data, const std::string &fileName) |
| Loads a entire file as a vector of bytes. | |
| unsigned long MRPTDLLIMPEXP | mrpt::system::getMemoryUsage () |
| Returns the memory occupied by this process, in bytes. | |
| std::string MRPTDLLIMPEXP | mrpt::system::toUpperCase (const std::string &str) |
| Returns a lower-case version of a string. | |
| std::string MRPTDLLIMPEXP | mrpt::system::toLowerCase (const std::string &str) |
| Returns an upper-case version of a string. | |
| std::string MRPTDLLIMPEXP | mrpt::system::upperCase (const std::string &str) |
| Returns a lower-case version of a string. | |
| std::string MRPTDLLIMPEXP | mrpt::system::lowerCase (const std::string &str) |
| Returns an upper-case version of a string. | |
| std::string MRPTDLLIMPEXP | mrpt::system::MRPT_getCompilationDate () |
| Returns the MRPT compilation date. | |
| std::string MRPTDLLIMPEXP | mrpt::system::MRPT_getVersion () |
| Returns a string describing the MRPT version including the SVN number. | |
| void MRPTDLLIMPEXP | 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. | |
| void MRPTDLLIMPEXP | mrpt::system::decodeUTF8 (const std::string &strUTF8, vector_word &out_uniStr) |
| Decodes a UTF-8 string into an UNICODE string. | |
| void MRPTDLLIMPEXP | mrpt::system::encodeUTF8 (const vector_word &input, std::string &output) |
| Encodes a 2-bytes UNICODE string into a UTF-8 string. | |
Directories, files, and file names | |
| std::string MRPTDLLIMPEXP | mrpt::system::getTempFileName () |
| Returns the name of a proposed temporary file name. | |
| std::string MRPTDLLIMPEXP | mrpt::system::getcwd () |
| Returns the current working directory. | |
| bool MRPTDLLIMPEXP | mrpt::system::createDirectory (const std::string &dirName) |
| Creates a directory. | |
| bool MRPTDLLIMPEXP | mrpt::system::deleteFile (const std::string &fileName) |
| Deletes a single file. | |
| void MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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. | |
| void MRPTDLLIMPEXP | mrpt::system::deleteFilesInDirectory (const std::string &s) |
| Delete all the files in a given directory. | |
| std::string MRPTDLLIMPEXP | mrpt::system::extractFileName (const std::string &filePath) |
| Extract just the name (without extension) of a filename from a complete path plus name plus extension. | |
| std::string MRPTDLLIMPEXP | mrpt::system::extractFileExtension (const std::string &filePath, bool ignore_gz=false) |
| Extract the extension of a filename. | |
| std::string MRPTDLLIMPEXP | mrpt::system::extractFileDirectory (const std::string &filePath) |
| Extract the whole path (the directory) of a filename from a complete path plus name plus extension. | |
| bool MRPTDLLIMPEXP | mrpt::system::fileExists (const std::string &fileName) |
| Test if a given file (or directory) exists. | |
| std::string MRPTDLLIMPEXP | mrpt::system::fileNameStripInvalidChars (const std::string &filename) |
| Replace invalid filename chars by underscores ('_'). | |
Threads | |
| enum | mrpt::system::TProcessPriority { mrpt::system::ppIdle = 0, mrpt::system::ppNormal, mrpt::system::ppHigh, mrpt::system::ppVeryHigh } |
| The type for cross-platform process (application) priorities. More... | |
| enum | mrpt::system::TThreadPriority { mrpt::system::tpLow = 0, mrpt::system::tpNormal, mrpt::system::tpHigh } |
| The type for cross-platform thread priorities. More... | |
| TThreadHandle MRPTDLLIMPEXP | mrpt::system::createThread (void(*func)(void *), void *param) |
| Creates a new thread. | |
| void MRPTDLLIMPEXP | mrpt::system::joinThread (const TThreadHandle &threadHandle) |
| Waits until the given thread ends. | |
| unsigned long MRPTDLLIMPEXP | mrpt::system::getCurrentThreadId () MRPT_NO_THROWS |
| Returns the ID of the current thread. | |
| void MRPTDLLIMPEXP | 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. | |
| void MRPTDLLIMPEXP | mrpt::system::changeThreadPriority (const TThreadHandle &threadHandle, TThreadPriority priority) |
| Change the priority of the given thread. | |
| void MRPTDLLIMPEXP | mrpt::system::changeCurrentProcessPriority (TProcessPriority priority) |
| Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread). | |
Time and date functions | |
| 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). | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::buildTimestampFromParts (const mrpt::system::TTimeParts &p) |
| Builds a timestamp from the parts (Parts are in UTC). | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::buildTimestampFromPartsLocalTime (const mrpt::system::TTimeParts &p) |
| Builds a timestamp from the parts (Parts are in local time). | |
| void MRPTDLLIMPEXP | mrpt::system::timestampToParts (TTimeStamp t, TTimeParts &p) |
| Gets the individual parts of a date/time (days, hours, minutes, seconds). | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::getCurrentTime () |
| Returns the current (UTC) system time. | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::now () |
| A shortcut for system::getCurrentTime. | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::getCurrentLocalTime () |
| Returns the current (local) time. | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | mrpt::system::time_tToTimestamp (const time_t &t) |
| Transform from standard "time_t" to TTimeStamp. | |
| double MRPTDLLIMPEXP | 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). | |
| double MRPTDLLIMPEXP | 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. | |
| mrpt::system::TTimeStamp MRPTDLLIMPEXP | mrpt::system::secondsToTimestamp (const double &nSeconds) |
| Transform a time interval (in seconds) into TTimeStamp (e.g. | |
| std::string MRPTDLLIMPEXP | 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. | |
| std::string MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | 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 MRPTDLLIMPEXP | mrpt::system::dateToString (const mrpt::system::TTimeStamp &t) |
| Convert a timestamp into this textual form: YEAR/MONTH/DAY. | |
| double MRPTDLLIMPEXP | mrpt::system::extractDayTimeFromTimestamp (const mrpt::system::TTimeStamp &t) |
| Returns the number of seconds ellapsed from midnight in the given timestamp. | |
| std::string MRPTDLLIMPEXP | mrpt::system::timeToString (const mrpt::system::TTimeStamp &t) |
| Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM. | |
| std::string MRPTDLLIMPEXP | mrpt::system::timeLocalToString (const mrpt::system::TTimeStamp &t) |
| Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM. | |
| #define INVALID_TIMESTAMP (0) |
| #define mrpt_alloca | ( | nBytes | ) | ::malloc( nBytes ); |
In platforms and compilers with support to "alloca", allocate a memory block on the stack; if alloca is not supported, it is emulated as a normal "malloc" - NOTICE: Since in some platforms alloca will be emulated with malloc, alloca_free MUST BE ALWAYS CALLED to avoid memory leaks.
This method MUST BE a macro rather than a function in order to operate on the caller's stack.
| #define mrpt_alloca_free | ( | mem_block | ) | free(mem_block) |
This method must be called to "free" each memory block allocated with "system::alloca": If the block was really allocated in the stack, no operation is actually performed, otherwise it will be freed from the heap.
This method MUST BE a macro rather than a function in order to operate on the caller's stack.
| Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:07:47 EST 2009 |