// // Created by robin on 8/9/15. // #ifndef RESULT_H #define RESULT_H # include # include # include template class Result { public: static const Result ok(const T& data); static const Result strerror(); static const Result error(const std::string& error); template static const Result error(const Result& other); T& getData(); const bool isSuccess() const; const std::string& getError() const; bool operator !() const; operator bool() const; template friend std::ostream& operator<<(std::ostream& os, const Result& res); const Result& print() const; private: Result(); T _data; std::string _error; bool _success; }; typedef Result ResultBool; typedef Result ResultInt; typedef Result ResultLong; typedef Result ResultFloat; typedef Result ResultDouble; typedef Result ResultChar; typedef Result ResultString; # include "DBO/Result.hxx" #endif //RESULT_H