14#ifndef IOX2_BB_POSIX_DESIGN_POSIX_CALL_HPP
15#define IOX2_BB_POSIX_DESIGN_POSIX_CALL_HPP
30template <
typename ReturnType,
typename... FunctionArguments>
46template <
typename ReturnType,
typename... FunctionArguments>
49 const char* posixFunctionName,
52 const char* callingFunction)
noexcept;
54template <
typename ReturnType>
58 const char*
file =
nullptr;
70template <
typename ReturnType>
77 template <
typename... IgnoredErrnos>
84 template <
typename... SilentErrnos>
101 detail::PosixCallDetails<ReturnType>& m_details;
105template <typename ReturnType>
111 template <
typename... SuccessReturnValues>
117 template <
typename... FailureReturnValues>
125 template <
typename,
typename...>
136template <
typename ReturnType,
typename... FunctionArguments>
149 template <
typename ReturnTypeFriend,
typename... FunctionArgumentsFriend>
151 detail::createPosixCallBuilder(ReturnTypeFriend (*
IOX2_POSIX_CALL)(FunctionArgumentsFriend...),
152 const char* posixFunctionName,
155 const char* callingFunction)
noexcept;
158 const char* posixFunctionName,
161 const char* callingFunction)
noexcept;
170#include "iox2/legacy/detail/posix_call.inl"
198#define IOX2_POSIX_CALL(f) \
199 iox2::legacy::detail::createPosixCallBuilder( \
#define IOX2_NO_DISCARD
IOX2_NO_DISCARD adds the [[nodiscard]] keyword if it is available for the current compiler.
ReturnType(*)(FunctionArguments...) FunctionType_t
input function type
PosixCallVerificator< ReturnType > operator()(FunctionArguments... arguments) &&noexcept
Call the underlying function with the provided arguments. If the underlying function fails and sets t...
class which is created by the verificator to evaluate the result of a posix call
PosixCallEvaluator< ReturnType > ignoreErrnos(const IgnoredErrnos... ignoredErrnos) const &&noexcept
ignore specified errnos from the evaluation
expected< PosixCallResult< ReturnType >, PosixCallResult< ReturnType > > evaluate() const &&noexcept
evaluate the result of a posix call
PosixCallEvaluator< ReturnType > suppressErrorMessagesForErrnos(const SilentErrnos... silentErrnos) const &&noexcept
silence specified errnos from printing error messages in the evaluation
class which verifies the return value of a posix function call
PosixCallEvaluator< ReturnType > failureReturnValue(const FailureReturnValues... failureReturnValues) &&noexcept
the posix function call defines failure through a single value
PosixCallEvaluator< ReturnType > returnValueMatchesErrno() &&noexcept
the posix function call defines failure through return of the errno value instead of setting the errn...
PosixCallEvaluator< ReturnType > successReturnValue(const SuccessReturnValues... successReturnValues) &&noexcept
the posix function call defines success through a single value
friend class PosixCallBuilder
Implementation of the C++23 expected class which can contain an error or a success value.
PosixCallBuilder< ReturnType, FunctionArguments... > createPosixCallBuilder(ReturnType(*IOX2_POSIX_CALL)(FunctionArguments...), const char *posixFunctionName, const char *file, const int32_t line, const char *callingFunction) noexcept
constexpr bool always_false_v
Helper value to bind a static_assert to a type.
static constexpr int32_t POSIX_CALL_INVALID_ERRNO
static constexpr uint32_t POSIX_CALL_ERROR_STRING_SIZE
static constexpr uint64_t POSIX_CALL_EINTR_REPETITIONS
#define IOX2_POSIX_CALL(f)
Calling a posix function with automated error handling. If the posix function returns void you do not...
PosixCallResult() noexcept=default
int32_t errnum
the errno value which was set by the posix function call
T value
the return value of the posix function call
const char * callingFunction
PosixCallDetails(const char *posixFunctionName, const char *file, int line, const char *callingFunction) noexcept
const char * posixFunctionName
PosixCallResult< ReturnType > result