// // Created by robin on 8/9/15. // #include #include "Result.h" template Result::Result() { } template Result::Result(const T &data) : _data(data) { } template Result::~Result() { } template Result &Result::ok(const T &data) { _data = data; return *this; } template T &Result::getData() { return _data; } template bool Result::isSuccess() const { return _error.empty(); } template const std::vector& Result::getWarnings() const { return _warnings; } template Result& Result::addWarning(const std::string &warning) { _warnings.push_back(warning); return *this; } template bool Result::operator!() const { return !isSuccess(); } template Result::operator bool() const { return isSuccess(); } template Result &Result::error(const std::string &error) { _error = error; return *this; } template const std::string &Result::getError() const { return _error; } template const Result& Result::print() const { for (auto warning : _warnings) std::cerr << "WARNING: " << warning << std::endl; if (!isSuccess()) std::cerr << "ERROR: " << _error << std::endl; return *this; }