16#ifndef IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP
17#define IOX_HOOFS_POSIX_WRAPPER_POSIX_CALL_HPP
19#include "iceoryx_hoofs/cxx/algorithm.hpp"
20#include "iceoryx_hoofs/cxx/attributes.hpp"
21#include "iceoryx_hoofs/cxx/expected.hpp"
22#include "iceoryx_hoofs/cxx/string.hpp"
31static constexpr uint32_t POSIX_CALL_ERROR_STRING_SIZE = 128U;
32static constexpr uint64_t POSIX_CALL_EINTR_REPETITIONS = 5U;
33static constexpr int32_t POSIX_CALL_INVALID_ERRNO = -1;
35template <
typename ReturnType,
typename... FunctionArguments>
36class PosixCallBuilder;
52 int32_t
errnum = POSIX_CALL_INVALID_ERRNO;
57template <
typename ReturnType,
typename... FunctionArguments>
58PosixCallBuilder<ReturnType, FunctionArguments...> createPosixCallBuilder(ReturnType (*posixCall)(FunctionArguments...),
59 const char* posixFunctionName,
62 const char* callingFunction)
noexcept;
64template <
typename ReturnType>
65struct PosixCallDetails
67 PosixCallDetails(
const char* posixFunctionName,
const char* file,
int line,
const char* callingFunction)
noexcept;
68 const char* posixFunctionName =
nullptr;
69 const char* file =
nullptr;
70 const char* callingFunction =
nullptr;
72 bool hasSuccess =
true;
73 bool hasIgnoredErrno =
false;
74 bool hasSilentErrno =
false;
105#define posixCall(f) internal::createPosixCallBuilder(f, #f, __FILE__, __LINE__, __PRETTY_FUNCTION__)
108template <
typename ReturnType>
116 template <
typename... IgnoredErrnos>
123 template <
typename... SilentErrnos>
135 explicit
PosixCallEvaluator(internal::PosixCallDetails<ReturnType>& details) noexcept;
138 internal::PosixCallDetails<ReturnType>& m_details;
142template <typename ReturnType>
149 template <
typename... SuccessReturnValues>
155 template <
typename... FailureReturnValues>
163 template <
typename,
typename...>
169 internal::PosixCallDetails<ReturnType>& m_details;
172template <
typename ReturnType,
typename... FunctionArguments>
186 template <
typename ReturnTypeFriend,
typename... FunctionArgumentsFriend>
188 internal::createPosixCallBuilder(ReturnTypeFriend (*posixCall)(FunctionArgumentsFriend...),
189 const char* posixFunctionName,
192 const char* callingFunction)
noexcept;
195 const char* posixFunctionName,
198 const char* callingFunction)
noexcept;
202 internal::PosixCallDetails<ReturnType> m_details;
207#include "iceoryx_hoofs/internal/posix_wrapper/posix_call.inl"
string implementation with some adjustments in the API, because we are not allowed to throw exception...
Definition: string.hpp:90
Definition: posix_call.hpp:174
PosixCallVerificator< ReturnType > operator()(FunctionArguments... arguments) &&noexcept
Call the underlying function with the provided arguments. If the underlying function fails and sets t...
ReturnType(*)(FunctionArguments...) FunctionType_t
input function type
Definition: posix_call.hpp:177
class which is created by the verificator to evaluate the result of a posix call
Definition: posix_call.hpp:110
PosixCallEvaluator< ReturnType > ignoreErrnos(const IgnoredErrnos... ignoredErrnos) const &&noexcept
ignore specified errnos from the evaluation
PosixCallEvaluator< ReturnType > suppressErrorMessagesForErrnos(const SilentErrnos... silentErrnos) const &&noexcept
silence specified errnos from printing error messages in the evaluation
cxx::expected< PosixCallResult< ReturnType >, PosixCallResult< ReturnType > > evaluate() const &&noexcept
evaluate the result of a posix call
class which verifies the return value of a posix function call
Definition: posix_call.hpp:144
PosixCallEvaluator< ReturnType > returnValueMatchesErrno() &&noexcept
the posix function call defines failure through return of the errno value instead of setting the errn...
PosixCallEvaluator< ReturnType > failureReturnValue(const FailureReturnValues... failureReturnValues) &&noexcept
the posix function call defines failure through a single value
PosixCallEvaluator< ReturnType > successReturnValue(const SuccessReturnValues... successReturnValues) &&noexcept
the posix function call defines success through a single value
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29
result of a posix call
Definition: posix_call.hpp:41
int32_t errnum
the errno value which was set by the posix function call
Definition: posix_call.hpp:52
cxx::string< POSIX_CALL_ERROR_STRING_SIZE > getHumanReadableErrnum() const noexcept
returns the result of std::strerror(errnum) which acquires a human readable error string
T value
the return value of the posix function call
Definition: posix_call.hpp:49