You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Result.h 806B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Created by robin on 8/9/15.
  3. //
  4. #ifndef PDNS_SLAVE_RESULT_H
  5. #define PDNS_SLAVE_RESULT_H
  6. # include <string>
  7. # include <vector>
  8. template <class T> class Result
  9. {
  10. public:
  11. Result();
  12. Result(const T& data);
  13. virtual ~Result();
  14. Result<T>& ok(const T& data);
  15. T& getData();
  16. bool isSuccess() const;
  17. Result<T>& addWarning(const std::string& warning);
  18. const std::vector<std::string>& getWarnings() const;
  19. Result<T>& error(const std::string& error);
  20. const std::string& getError() const;
  21. bool operator !() const;
  22. operator bool() const;
  23. const Result<T>& print() const;
  24. private:
  25. T _data;
  26. std::vector<std::string> _warnings;
  27. std::string _error;
  28. };
  29. typedef Result<bool> BResult;
  30. # include "DBO/Result.hxx"
  31. #endif //PDNS_SLAVE_RESULT_H