Main MRPT website > C++ reference for MRPT 1.4.0
Namespaces | Macros | Functions
mrpt_macros.h File Reference
#include <mrpt/base/link_pragmas.h>
#include <sstream>
#include <stdexcept>

Go to the source code of this file.

Namespaces

namespace  mrpt
 This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
 

Macros

#define MRPT_HAS_CXX11   0
 Does the compiler support C++11?
 
#define MRPT_OVERRIDE
 C++11 "override" for virtuals:
 
#define MRPT_DEPRECATED_PRE(_MSG)
 
#define MRPT_DEPRECATED_POST(_MSG)
 
#define MRPT_DECLARE_DEPRECATED_FUNCTION(__MSG, __FUNC)   MRPT_DEPRECATED_PRE(__MSG) __FUNC MRPT_DEPRECATED_POST(__MSG)
 Usage: MRPT_DECLARE_DEPRECATED_FUNCTION("Use XX instead", void myFunc(double));.
 
#define MRPT_DO_PRAGMA(x)
 Declare MRPT_TODO(message)

 
#define MRPT_MSG_PRAGMA(_msg)
 
#define MRPT_WARNING(x)   MRPT_MSG_PRAGMA("Warning: " x)
 
#define MRPT_TODO(x)   MRPT_MSG_PRAGMA("TODO: " x)
 
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_scanf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_NO_THROWS   throw()
 Used after member declarations.
 
#define MRPT_ALIGN16
 
#define MRPT_ALIGN32
 
#define __CURRENT_FUNCTION_NAME__   __PRETTY_FUNCTION__
 A macro for obtaining the name of the current function:

 
#define THROW_EXCEPTION(msg)
 
#define THROW_EXCEPTION_CUSTOM_MSG1(msg, param1)
 
#define THROW_TYPED_EXCEPTION(msg, exceptionClass)
 Defines a unified way of reporting exceptions of type different from "std::exception".
 
#define THROW_TYPED_EXCEPTION_CUSTOM_MSG1(msg, param1, exceptionClass)
 
#define THROW_STACKED_EXCEPTION(e)
 
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG1(e, msg)
 
#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2(e, stuff, param1)
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)   THROW_EXCEPTION(mrpt::format("Cannot parse object: unknown serialization version number: '%i'",static_cast<int>(__V)))
 For use in CSerializable implementations.
 
#define ASSERTMSG_(f, __ERROR_MSG)   { }
 
#define ASSERT_(f)   { }
 
#define MRPT_CHECK_NORMAL_NUMBER(val)   { }
 
#define MRPT_COMPILE_TIME_ASSERT(f)   { }
 
#define ASSERT_EQUAL_(__A, __B)   { }
 
#define ASSERT_NOT_EQUAL_(__A, __B)   { }
 
#define ASSERT_BELOW_(__A, __B)   { }
 
#define ASSERT_ABOVE_(__A, __B)   { }
 
#define ASSERT_BELOWEQ_(__A, __B)   { }
 
#define ASSERT_ABOVEEQ_(__A, __B)   { }
 
#define ASSERT_FILE_EXISTS_(FIL)   { }
 
#define ASSERT_DIRECTORY_EXISTS_(DIR)   { }
 
#define ASSERTDEB_(f)   { }
 Defines an assertion mechanism - only when compiled in debug.
 
#define ASSERTDEBMSG_(f, __ERROR_MSG)   { }
 
#define MRPT_UNUSED_PARAM(a)   (void)(a)
 Can be used to avoid "not used parameters" warnings from the compiler.
 
#define MRPT_TRY_START
 
#define MRPT_TRY_END
 
#define MRPT_TRY_END_WITH_CLEAN_UP(stuff)
 
#define MRPT_PROFILE_FUNC_START
 
#define MRPT_START
 
#define MRPT_END    MRPT_TRY_END
 
#define MRPT_END_WITH_CLEAN_UP(stuff)    MRPT_TRY_END_WITH_CLEAN_UP(stuff)
 
#define M_2PI   6.283185307179586476925286766559
 
#define M_PIf   3.14159265358979f
 
#define M_2PIf   6.28318530717959f
 
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_scanf_format_check(_FMT_, _VARARGS_)
 
#define MRPT_NO_THROWS   throw()
 Used after member declarations.
 
#define MRPT_FORCE_INLINE   inline
 Tells the compiler we really want to inline that function.
 

Functions

std::string BASE_IMPEXP mrpt::format (const char *fmt,...) MRPT_printf_format_check(1
 A std::string version of C sprintf.
 

Macro Definition Documentation

◆ __CURRENT_FUNCTION_NAME__

#define __CURRENT_FUNCTION_NAME__   __PRETTY_FUNCTION__

A macro for obtaining the name of the current function:

Definition at line 102 of file mrpt_macros.h.

◆ ASSERT_

#define ASSERT_ (   f)    { }

Definition at line 261 of file mrpt_macros.h.

◆ ASSERT_ABOVE_

#define ASSERT_ABOVE_ (   __A,
  __B 
)    { }

Definition at line 267 of file mrpt_macros.h.

◆ ASSERT_ABOVEEQ_

#define ASSERT_ABOVEEQ_ (   __A,
  __B 
)    { }

Definition at line 269 of file mrpt_macros.h.

◆ ASSERT_BELOW_

#define ASSERT_BELOW_ (   __A,
  __B 
)    { }

Definition at line 266 of file mrpt_macros.h.

◆ ASSERT_BELOWEQ_

#define ASSERT_BELOWEQ_ (   __A,
  __B 
)    { }

Definition at line 268 of file mrpt_macros.h.

◆ ASSERT_DIRECTORY_EXISTS_

#define ASSERT_DIRECTORY_EXISTS_ (   DIR)    { }

Definition at line 272 of file mrpt_macros.h.

◆ ASSERT_EQUAL_

#define ASSERT_EQUAL_ (   __A,
  __B 
)    { }

Definition at line 264 of file mrpt_macros.h.

◆ ASSERT_FILE_EXISTS_

#define ASSERT_FILE_EXISTS_ (   FIL)    { }

Definition at line 271 of file mrpt_macros.h.

◆ ASSERT_NOT_EQUAL_

#define ASSERT_NOT_EQUAL_ (   __A,
  __B 
)    { }

Definition at line 265 of file mrpt_macros.h.

◆ ASSERTDEB_

#define ASSERTDEB_ (   f)    { }

Defines an assertion mechanism - only when compiled in debug.

Note
Do NOT put code that must be always executed inside this statement, but just comparisons. This is because users might require ASSERT_'s to be ignored for optimized releases.
See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 283 of file mrpt_macros.h.

◆ ASSERTDEBMSG_

#define ASSERTDEBMSG_ (   f,
  __ERROR_MSG 
)    { }

Definition at line 284 of file mrpt_macros.h.

◆ ASSERTMSG_

#define ASSERTMSG_ (   f,
  __ERROR_MSG 
)    { }

Definition at line 260 of file mrpt_macros.h.

◆ M_2PI

#define M_2PI   6.283185307179586476925286766559

Definition at line 363 of file mrpt_macros.h.

◆ M_2PIf

#define M_2PIf   6.28318530717959f

Definition at line 367 of file mrpt_macros.h.

◆ M_PIf

#define M_PIf   3.14159265358979f

Definition at line 366 of file mrpt_macros.h.

◆ MRPT_ALIGN16

#define MRPT_ALIGN16

Definition at line 92 of file mrpt_macros.h.

◆ MRPT_ALIGN32

#define MRPT_ALIGN32

Definition at line 93 of file mrpt_macros.h.

◆ MRPT_CHECK_NORMAL_NUMBER

#define MRPT_CHECK_NORMAL_NUMBER (   val)    { }

Definition at line 262 of file mrpt_macros.h.

◆ MRPT_COMPILE_TIME_ASSERT

#define MRPT_COMPILE_TIME_ASSERT (   f)    { }

Definition at line 263 of file mrpt_macros.h.

◆ MRPT_DECLARE_DEPRECATED_FUNCTION

#define MRPT_DECLARE_DEPRECATED_FUNCTION (   __MSG,
  __FUNC 
)    MRPT_DEPRECATED_PRE(__MSG) __FUNC MRPT_DEPRECATED_POST(__MSG)

Usage: MRPT_DECLARE_DEPRECATED_FUNCTION("Use XX instead", void myFunc(double));.

Definition at line 47 of file mrpt_macros.h.

◆ MRPT_DEPRECATED_POST

#define MRPT_DEPRECATED_POST (   _MSG)

Definition at line 43 of file mrpt_macros.h.

◆ MRPT_DEPRECATED_PRE

#define MRPT_DEPRECATED_PRE (   _MSG)

Definition at line 42 of file mrpt_macros.h.

◆ MRPT_DO_PRAGMA

#define MRPT_DO_PRAGMA (   x)

Declare MRPT_TODO(message)

Definition at line 60 of file mrpt_macros.h.

◆ MRPT_END

#define MRPT_END    MRPT_TRY_END

Definition at line 353 of file mrpt_macros.h.

◆ MRPT_END_WITH_CLEAN_UP

#define MRPT_END_WITH_CLEAN_UP (   stuff)     MRPT_TRY_END_WITH_CLEAN_UP(stuff)

Definition at line 356 of file mrpt_macros.h.

◆ MRPT_FORCE_INLINE

#define MRPT_FORCE_INLINE   inline

Tells the compiler we really want to inline that function.

Definition at line 397 of file mrpt_macros.h.

◆ MRPT_HAS_CXX11

#define MRPT_HAS_CXX11   0

Does the compiler support C++11?

Definition at line 21 of file mrpt_macros.h.

◆ MRPT_MSG_PRAGMA

#define MRPT_MSG_PRAGMA (   _msg)

Definition at line 61 of file mrpt_macros.h.

◆ MRPT_NO_THROWS [1/2]

#define MRPT_NO_THROWS   throw()

Used after member declarations.

Definition at line 81 of file mrpt_macros.h.

◆ MRPT_NO_THROWS [2/2]

#define MRPT_NO_THROWS   throw()

Used after member declarations.

Definition at line 81 of file mrpt_macros.h.

◆ MRPT_OVERRIDE

#define MRPT_OVERRIDE

C++11 "override" for virtuals:

Definition at line 28 of file mrpt_macros.h.

◆ MRPT_printf_format_check [1/2]

#define MRPT_printf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 71 of file mrpt_macros.h.

◆ MRPT_printf_format_check [2/2]

#define MRPT_printf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 71 of file mrpt_macros.h.

◆ MRPT_PROFILE_FUNC_START

#define MRPT_PROFILE_FUNC_START

Definition at line 342 of file mrpt_macros.h.

◆ MRPT_scanf_format_check [1/2]

#define MRPT_scanf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 77 of file mrpt_macros.h.

◆ MRPT_scanf_format_check [2/2]

#define MRPT_scanf_format_check (   _FMT_,
  _VARARGS_ 
)

Definition at line 77 of file mrpt_macros.h.

◆ MRPT_START

#define MRPT_START
Value:
MRPT_PROFILE_FUNC_START \
MRPT_TRY_START

Definition at line 349 of file mrpt_macros.h.

◆ MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION

#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION (   __V)    THROW_EXCEPTION(mrpt::format("Cannot parse object: unknown serialization version number: '%i'",static_cast<int>(__V)))

For use in CSerializable implementations.

Definition at line 200 of file mrpt_macros.h.

◆ MRPT_TODO

#define MRPT_TODO (   x)    MRPT_MSG_PRAGMA("TODO: " x)

Definition at line 65 of file mrpt_macros.h.

◆ MRPT_TRY_END

#define MRPT_TRY_END

Definition at line 335 of file mrpt_macros.h.

◆ MRPT_TRY_END_WITH_CLEAN_UP

#define MRPT_TRY_END_WITH_CLEAN_UP (   stuff)

Definition at line 336 of file mrpt_macros.h.

◆ MRPT_TRY_START

#define MRPT_TRY_START

Definition at line 334 of file mrpt_macros.h.

◆ MRPT_UNUSED_PARAM

#define MRPT_UNUSED_PARAM (   a)    (void)(a)

Can be used to avoid "not used parameters" warnings from the compiler.

Definition at line 290 of file mrpt_macros.h.

◆ MRPT_WARNING

#define MRPT_WARNING (   x)    MRPT_MSG_PRAGMA("Warning: " x)

Definition at line 64 of file mrpt_macros.h.

◆ THROW_EXCEPTION

#define THROW_EXCEPTION (   msg)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << msg << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\
#define __CURRENT_FUNCTION_NAME__
A macro for obtaining the name of the current function:
Parameters
msgThis can be a char*, a std::string, or a literal string. Defines a unified way of reporting exceptions
See also
MRPT_TRY_START, MRPT_TRY_END, THROW_EXCEPTION_CUSTOM_MSG1

Definition at line 110 of file mrpt_macros.h.

◆ THROW_EXCEPTION_CUSTOM_MSG1

#define THROW_EXCEPTION_CUSTOM_MSG1 (   msg,
  param1 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << mrpt::format(msg,param1)<< std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Parameters
eThe caught exception.
msgIs a char* or literal string.

Definition at line 123 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION

#define THROW_STACKED_EXCEPTION (   e)
Value:
{\
std::string str( e.what() );\
if (str.find("MRPT stack trace")==std::string::npos) \
{ \
str+= mrpt::format(", line %i:\n", __LINE__ );\
throw std::logic_error( str );\
} \
else throw std::logic_error( e.what() );\
}\
See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 163 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION_CUSTOM_MSG1

#define THROW_STACKED_EXCEPTION_CUSTOM_MSG1 (   e,
  msg 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << e.what() ; \
auxCompStr << msg << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\

Definition at line 179 of file mrpt_macros.h.

◆ THROW_STACKED_EXCEPTION_CUSTOM_MSG2

#define THROW_STACKED_EXCEPTION_CUSTOM_MSG2 (   e,
  stuff,
  param1 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << e.what() ; \
auxCompStr << mrpt::format( stuff, param1 ) << std::endl; \
throw std::logic_error( auxCompStr.str() );\
}\

Definition at line 191 of file mrpt_macros.h.

◆ THROW_TYPED_EXCEPTION

#define THROW_TYPED_EXCEPTION (   msg,
  exceptionClass 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << msg << std::endl; \
throw exceptionClass( auxCompStr.str() );\
}\

Defines a unified way of reporting exceptions of type different from "std::exception".

See also
MRPT_TRY_START, MRPT_TRY_END

Definition at line 137 of file mrpt_macros.h.

◆ THROW_TYPED_EXCEPTION_CUSTOM_MSG1

#define THROW_TYPED_EXCEPTION_CUSTOM_MSG1 (   msg,
  param1,
  exceptionClass 
)
Value:
{\
std::ostringstream auxCompStr;\
auxCompStr << "\n\n =============== MRPT EXCEPTION =============\n";\
auxCompStr << __CURRENT_FUNCTION_NAME__ << ", line " << __LINE__ << ":\n";\
auxCompStr << mrpt::format(msg,param1)<< std::endl; \
throw exceptionClass( auxCompStr.str() );\
}\

Definition at line 150 of file mrpt_macros.h.




Page generated by Doxygen 1.9.7 for MRPT 1.4.0 SVN: at Tue Jun 13 13:45:58 UTC 2023