Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b5c5bbb219
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 29 lines (22 sloc) 0.707 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/* Return value class
* by Albert Zeyer, 2011
* code under LGPL
*/

#ifndef __AZ__RETURN_H__
#define __AZ__RETURN_H__

#include <string>

struct Return {
bool success;
std::string errmsg;

Return(bool s = true) : success(s) {}
Return(const char* errm) : success(false), errmsg(errm) {}
Return(const std::string& errm) : success(false), errmsg(errm) {}
Return(const Return& r, const std::string& extmsg) : success(false) {
if(r) errmsg = extmsg;
else errmsg = extmsg + ": " + r.errmsg;
}
operator bool() const { return success; }
};

#define ASSERT(x) { Return ___r = (x); if(!___r) return ___r; }
#define ASSERT_EXT(x, msg) { Return ___r = (x); if(!___r) return Return(___r, msg); }

#endif
Something went wrong with that request. Please try again.