2 #ifndef __PROTO_ASSERT__ 3 #define __PROTO_ASSERT__ 14 inline std::vector<std::string>
split_string (
const std::string &s,
char delim) {
15 std::vector<std::string> result;
16 std::stringstream ss (s);
19 while (getline (ss, item, delim)) {
20 result.push_back (item);
29 #define PROTO_ASSERT(stmt,args...) 30 #define PR_DEBUG_MSG(N, stmt, args...) 31 #define PR_assert(stmt) 32 #define PR_error(stmt) 33 #define PR_warning(stmt) 37 #define PROTO_ASSERT(stmt,args...) 38 #define PR_DEBUG_MSG(N, stmt, args...) 39 #define PR_assert(stmt) 40 #define PR_error(stmt) 41 #define PR_warning(stmt) 48 #define PROTO_ASSERT(stmt,args...) \ 50 (fprintf(stderr,"%s:%d: error: ",__FILE__,__LINE__) && \ 51 fprintf(stderr,"Assertion `" #stmt "` failed.\n\t") && \ 52 fprintf(stderr,args) && \ 53 fprintf(stderr,"\n"))); \ 54 if (!(stmt)){std::abort();} 56 #define PR_DEBUG_MSG(N, args...) \ 57 if (N <= PR_VERBOSE) \ 59 auto words = ProtoUtils::split_string(__FILE__, '/'); \ 60 string filename = words[words.size()-1]; \ 63 (fprintf(stdout, "DEBUG | %s:%d: ", filename.c_str(), __LINE__) && \ 64 fprintf(stdout, args) && \ 65 fprintf(stdout, "\n")); \ 68 #define PR_assert(stmt) assert( (stmt) ); 71 #define PR_error(stmt) \ 72 fprintf(stderr,"error thrown = `" #stmt "`!!!\n\t"); \ 75 #define PR_warning(stmt) \ 76 fprintf(stderr,"warning thrown = `" #stmt "` !!!\n\t"); 79 #define PROTO_ASSERT(stmt,args...) 80 #define PR_DEBUG_MSG(N, stmt, args...) 81 #define PR_assert(stmt) 82 #define PR_error(stmt) 83 #define PR_warning(stmt) 87 #endif // end include guard std::vector< std::string > split_string(const std::string &s, char delim)
Definition: Proto_PAssert.H:14
Definition: Proto_PAssert.H:12