19 #ifndef SERVUS_RESULT_H 20 #define SERVUS_RESULT_H 23 #include <servus/types.h> 32 typedef void (
Result::*bool_t)()
const;
33 void bool_true()
const {}
35 static const int32_t SUCCESS = 0;
46 operator bool_t()
const 48 return code_ == SUCCESS ? &Result::bool_true : 0;
54 bool operator==(
const int32_t code)
const {
return code_ == code; }
56 bool operator!=(
const int32_t code)
const {
return code != code_; }
62 return code_ == SUCCESS ?
"success" :
"result";
69 inline std::ostream& operator<<(std::ostream& os,
const Result& result)
74 #endif // SERVUS_RESULT_H virtual ~Result()
Destruct the result.
Defines export visibility macros for library Servus.
A result returns an error code and behaves like a boolean.
bool operator==(const int32_t code) const
Result(const int32_t code)
Construct a new result.
virtual std::string getString() const
bool operator!=(const int32_t code) const