16 #ifndef IOX_UTILS_CXX_SMART_C_HPP
17 #define IOX_UTILS_CXX_SMART_C_HPP
19 #include "iceoryx_utils/cxx/string.hpp"
20 #include "iceoryx_utils/platform/platform_correction.hpp"
23 #include <initializer_list>
54 #define makeSmartC(f_function, f_returnMode, f_returnValues, f_ignoredValues, ...) \
55 makeSmartCImpl(__FILE__, \
57 __PRETTY_FUNCTION__, \
71 static constexpr uint32_t ERRORSTRINGSIZE = 128u;
80 PRE_DEFINED_SUCCESS_CODE,
82 PRE_DEFINED_ERROR_CODE
109 template <
typename Function,
typename ReturnType,
typename... FunctionArguments>
122 operator ReturnType()
const noexcept;
139 template <
typename Function_F,
typename ReturnType_F,
typename... FunctionArguments_F>
140 friend SmartC<Function_F, ReturnType_F, FunctionArguments_F...>
141 makeSmartCImpl(
const char* file,
144 const Function_F& f_function,
145 const ReturnMode& f_mode,
146 const std::initializer_list<ReturnType_F>& f_returnValues,
147 const std::initializer_list<int>& f_ignoredValues,
148 FunctionArguments_F... f_args) noexcept;
156 const Function& f_function,
157 const ReturnMode& f_mode,
158 const std::initializer_list<ReturnType>& f_returnValues,
159 const std::initializer_list<int>& f_ignoredValues,
160 FunctionArguments... f_args) noexcept;
162 int resetErrnoAndInitErrnum() noexcept;
166 ReturnType m_returnValue;
168 bool m_hasErrors =
false;
180 #include "iceoryx_utils/internal/cxx/smart_c.inl"
C function call abstraction class which performs the error handling automatically.
Definition: smart_c.hpp:111
ReturnType getReturnValue() const noexcept
Returns the returnValue of the c function call. If an error has occurred the error code is returned....
Definition: smart_c.inl:170
int32_t getErrNum() const noexcept
Returns the errnum. 0 if no error has occurred, otherwise != 0.
Definition: smart_c.inl:194
bool hasErrors() const noexcept
If one of the given error codes was returned during the c function call and the c function failed.
Definition: smart_c.inl:182
const char * getErrorString() const noexcept
If no error occurred it returns a string like "no errors" (depending on the posix system) otherwise i...
Definition: smart_c.inl:188
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28