MRPT  1.9.9
[mrpt-core]

Detailed Description

Core functions for MRPT.

Back to list of all libraries | See all modules

Library `mrpt-core`

[New in MRPT 2.0.0]

This library is part of MRPT and can be installed in Debian-based systems with:

    sudo apt install libmrpt-core-dev

See: Using MRPT from your CMake project

Nested exceptions

See: core_exceptions_example/test.cpp

#include <iostream>
{
}
{
}
{
}
int main()
{
try
{
return 0;
}
catch (const std::exception& e)
{
std::cerr << mrpt::exception_to_str(e);
return -1;
}
}

Output:

==== MRPT exception ====
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:20: [void test_except_3rd_lvl()] Aw!
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:21: [void test_except_3rd_lvl()] Called from here.
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:28: [void test_except_2nd_lvl()] Called from here.
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:35: [void test_except_toplevel()] Called from here.
Collaboration diagram for [mrpt-core]:

Classes

class  mrpt::Clock
 Clock that is compatible with MRPT TTimeStamp representation. More...
 
struct  mrpt::safe_ptr_basic< T >
 A wrapper class for pointers that can be safely copied with "=" operator without problems. More...
 
struct  mrpt::safe_ptr< T >
 A wrapper class for pointers that can be safely copied with "=" operator without problems. More...
 
struct  mrpt::non_copiable_ptr_basic< T >
 A wrapper class for pointers that can NOT be copied with "=" operator, raising an exception at runtime if a copy is attempted. More...
 
struct  mrpt::non_copiable_ptr< T >
 A wrapper class for pointers that can NOT be copied with "=" operator, raising an exception at runtime if a copy is attempted. More...
 
struct  mrpt::ignored_copy_ptr< T >
 A wrapper class for pointers whose copy operations from other objects of the same type are ignored, that is, doing "a=b;" has no effect neiter on "a" or "b". More...
 
struct  mrpt::copiable_NULL_ptr_basic< T >
 A wrapper class for pointers that, if copied with the "=" operator, should be set to nullptr in the copy. More...
 
struct  mrpt::copiable_NULL_ptr< T >
 A wrapper class for pointers that, if copied with the "=" operator, should be set to nullptr in the new copy. More...
 

Modules

 Funtions in #include <mrpt/core/bits_math.h>
 
 Templates to declare integers by byte count (in
 #include <mrpt/core/integer_select.h>)
 
 Round functions (in #include <mrpt/core/round.h>)
 

Typedefs

template<class T >
using mrpt::optional_ref = std::optional< std::reference_wrapper< T > >
 Shorter name for std::optional<std::reference_wrapper<T>> More...
 

Functions

template<class VECTOR_T >
void mrpt::vector_strong_clear (VECTOR_T &v)
 Like calling a std::vector<>'s clear() method, but really forcing deallocating the memory. More...
 
std::string mrpt::exception_to_str (const std::exception &e)
 Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THROW_EXCEPTION,...) in between MRPT_START/MRPT_END macros, will contain function names and line numbers across the call stack at the original throw point. More...
 
std::string mrpt::format_impl (const char *fmt,...) MRPT_printf_format_check(1
 A std::string version of C sprintf. More...
 
template<typename T >
std::string mrpt::to_string (T v)
 Just like std::to_string(), but with an overloaded version for std::string arguments. More...
 
template<typename T >
mrpt::from_string (const std::string &s, const T &defValue=T{}, bool throw_on_error=true)
 Converts from string to any data type that supports reading (>>) from a text stream. More...
 
template<class T >
mrpt::get_env (const std::string &varname, const T &defValue=T())
 Reads an environment variable, with a default value if not present. More...
 
void mrpt::reverseBytesInPlace (bool &v_in_out)
 Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) More...
 
void mrpt::reverseBytesInPlace (uint8_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int8_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint16_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int16_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint32_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int32_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint64_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int64_t &v_in_out)
 
void mrpt::reverseBytesInPlace (float &v_in_out)
 
void mrpt::reverseBytesInPlace (double &v_in_out)
 
void mrpt::reverseBytesInPlace (long double &v_in_out)
 
void mrpt::reverseBytesInPlace (std::chrono::time_point< mrpt::Clock > &v_in_out)
 
template<class T >
void mrpt::reverseBytes (const T &v_in, T &v_out)
 Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) More...
 

Typedef Documentation

◆ optional_ref

template<class T >
using mrpt::optional_ref = typedef std::optional<std::reference_wrapper<T> >

Shorter name for std::optional<std::reference_wrapper<T>>

Definition at line 20 of file optional_ref.h.

Function Documentation

◆ exception_to_str()

std::string mrpt::exception_to_str ( const std::exception &  e)

Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THROW_EXCEPTION,...) in between MRPT_START/MRPT_END macros, will contain function names and line numbers across the call stack at the original throw point.

See example of use in [mrpt-core] Uses C++11 throw_with_nested(), rethrow_if_nested().

Examples:
comms_http_client/test.cpp, core_exceptions_example/test.cpp, rtti_example1/test.cpp, serialization_json_example/test.cpp, and serialization_stl/test.cpp.

Definition at line 59 of file exceptions.cpp.

References mrpt::internal::impl_excep_to_str().

Referenced by catch(), generic_icp_slam_test(), generic_kf_slam_test(), mrpt::obs::CRawlog::getActionObservationPair(), mrpt::obs::CRawlog::getActionObservationPairOrObservation(), mrpt::obs::CRawlog::loadFromRawLogFile(), mrpt::obs::CRawlog::readActionObservationPair(), mrpt::obs::CRawlog::saveToRawLogFile(), mrpt::apps::RawlogGrabberApp::SensorThread(), TEST(), TestBayesianTracking(), mrpt::comms::CClientTCPSocket::~CClientTCPSocket(), mrpt::config::CConfigFile::~CConfigFile(), mrpt::hwdrivers::CHokuyoURG::~CHokuyoURG(), mrpt::system::CObservable::~CObservable(), mrpt::comms::CSerialPort::~CSerialPort(), mrpt::system::CTimeLoggerEntry::~CTimeLoggerEntry(), and mrpt::system::CTimeLoggerSaveAtDtor::~CTimeLoggerSaveAtDtor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_impl()

std::string mrpt::format_impl ( const char *  fmt,
  ... 
)

A std::string version of C sprintf.

You can call this to obtain a std::string using printf-like syntax.

Definition at line 16 of file format.cpp.

References vsnprintf.

Referenced by mrpt::format().

Here is the caller graph for this function:

◆ from_string()

template<typename T >
T mrpt::from_string ( const std::string s,
const T &  defValue = T{},
bool  throw_on_error = true 
)
inline

Converts from string to any data type that supports reading (>>) from a text stream.

In case of error, the given default value is returned, or an exception raised.

Definition at line 32 of file from_string.h.

◆ get_env()

template<class T >
T mrpt::get_env ( const std::string varname,
const T &  defValue = T() 
)
inline

Reads an environment variable, with a default value if not present.

Definition at line 21 of file get_env.h.

◆ reverseBytes()

template<class T >
void mrpt::reverseBytes ( const T &  v_in,
T &  v_out 
)
inline

Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)

Definition at line 38 of file reverse_bytes.h.

References mrpt::reverseBytesInPlace().

Referenced by get_binary_item(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverseBytesInPlace() [1/13]

void mrpt::reverseBytesInPlace ( bool &  v_in_out)

Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)

Definition at line 93 of file reverse_bytes.cpp.

Referenced by mrpt::serialization::CArchive::ReadBufferFixEndianness(), mrpt::hwdrivers::CVelodyneScanner::receivePackets(), mrpt::reverseBytes(), and TEST().

Here is the caller graph for this function:

◆ reverseBytesInPlace() [2/13]

void mrpt::reverseBytesInPlace ( uint8_t &  v_in_out)

Definition at line 98 of file reverse_bytes.cpp.

◆ reverseBytesInPlace() [3/13]

void mrpt::reverseBytesInPlace ( int8_t &  v_in_out)

Definition at line 102 of file reverse_bytes.cpp.

◆ reverseBytesInPlace() [4/13]

void mrpt::reverseBytesInPlace ( uint16_t &  v_in_out)

Definition at line 107 of file reverse_bytes.cpp.

References reverseBytesInPlace_2b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [5/13]

void mrpt::reverseBytesInPlace ( int16_t &  v_in_out)

Definition at line 112 of file reverse_bytes.cpp.

References reverseBytesInPlace_2b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [6/13]

void mrpt::reverseBytesInPlace ( uint32_t &  v_in_out)

Definition at line 117 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [7/13]

void mrpt::reverseBytesInPlace ( int32_t v_in_out)

Definition at line 122 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [8/13]

void mrpt::reverseBytesInPlace ( uint64_t v_in_out)

Definition at line 127 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [9/13]

void mrpt::reverseBytesInPlace ( int64_t v_in_out)

Definition at line 132 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [10/13]

void mrpt::reverseBytesInPlace ( float &  v_in_out)

Definition at line 137 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [11/13]

void mrpt::reverseBytesInPlace ( double &  v_in_out)

Definition at line 142 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [12/13]

void mrpt::reverseBytesInPlace ( long double &  v_in_out)

◆ reverseBytesInPlace() [13/13]

void mrpt::reverseBytesInPlace ( std::chrono::time_point< mrpt::Clock > &  v_in_out)

Definition at line 147 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b(), and val.

Here is the call graph for this function:

◆ to_string()

template<typename T >
std::string mrpt::to_string ( v)

Just like std::to_string(), but with an overloaded version for std::string arguments.

Definition at line 36 of file format.h.

References mrpt::to_string().

Referenced by mrpt::internal::asrt_fail(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::internal::exception_line_msg(), mrpt::vision::CFeatureLines::extractLines(), mrpt::internal::impl_excep_to_str(), mrpt::comms::net::Ping(), mrpt::graphs::CDirectedGraph< CPOSE, EDGE_ANNOTATIONS >::saveAsDot(), mrpt::system::CTimeLogger::saveToCSVFile(), mrpt::system::CTimeLogger::saveToMFile(), mrpt::io::CPipeBaseEndPoint::serialize(), TEST(), mrpt::typemeta::TEnumType< ENUMTYPE >::value2name(), and mrpt::config::CConfigFileBase::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_strong_clear()

template<class VECTOR_T >
void mrpt::vector_strong_clear ( VECTOR_T &  v)
inline

Like calling a std::vector<>'s clear() method, but really forcing deallocating the memory.

Definition at line 18 of file bits_mem.h.

Referenced by mrpt::maps::CSimplePointsMap::internal_clear(), mrpt::maps::CWeightedPointsMap::internal_clear(), mrpt::maps::CPointsMapXYZI::internal_clear(), mrpt::maps::CColouredPointsMap::internal_clear(), mrpt::obs::CObservation3DRangeScan::points3D_convertToExternalStorage(), mrpt::obs::CObservation3DRangeScan::resizePoints3DVectors(), and mrpt::obs::CObservation3DRangeScan::unload().

Here is the caller graph for this function:



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: e47402b84 Wed Oct 23 01:09:07 2019 +0200 at miƩ oct 23 01:10:13 CEST 2019