19 #ifndef SERVUS_RESULT_H
20 #define SERVUS_RESULT_H
23 #include <servus/types.h>
33 typedef void (
Result::*bool_t)()
const;
34 void bool_true()
const {}
37 static const int32_t SUCCESS = 0;
40 explicit Result(
const int32_t code ) : code_( code ){}
46 operator bool_t()
const {
return code_ == SUCCESS ? &Result::bool_true : 0;}
52 bool operator == (
const int32_t code )
const {
return code_ == code; }
55 bool operator != (
const int32_t code )
const {
return code != code_; }
62 {
return code_ == SUCCESS ?
"success" :
"result"; }
68 inline std::ostream& operator << ( std::ostream& os,
const Result& result )
70 return os << result.getString() <<
" (" << result.getCode() <<
")";
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