21 #include "SheafSystem/assert_contract.h" 22 #include "SheafSystem/std_stdexcept.h" 23 #include "SheafSystem/std_iostream.h" 24 #include "SheafSystem/std_sstream.h" 25 #include "SheafSystem/std_string.h" 32 using namespace sheaf;
42 print_output_message(
const string& xmsg_type,
const string& xmsg)
48 int ltype_len = xmsg_type.length();
49 int lmsg_len = xmsg.length();
50 int lline_len = lmsg_len - ltype_len - 4;
52 OutputDebugString(
"\n== ");
53 OutputDebugString(xmsg_type.c_str());
54 OutputDebugString(
" ");
55 for(
int i=0; i < lline_len; i++)
57 OutputDebugString(
"=");
62 OutputDebugString(
"\n\n");
63 OutputDebugString(xmsg.c_str());
64 OutputDebugString(
"\n\n");
68 for(
int i=0; i < lmsg_len; i++)
70 OutputDebugString(
"=");
73 OutputDebugString(
"\n\n");
78 std::cerr << xmsg << std::endl;
84 int ltype_len = xmsg_type.length();
85 int lmsg_len = xmsg.length();
86 int lline_len = lmsg_len - ltype_len - 4;
88 std::cerr << endl <<
"== " << xmsg_type <<
" ";
89 for(
int i=0; i < lline_len; i++)
97 std::cerr << endl << xmsg.c_str() << endl;
102 for(
int i=0; i < lmsg_len; i++)
106 std::cerr << endl << endl;
137 check_contract(
bool xcond,
const char* xmsg,
const char* xfunction_name,
const char* xfile,
int xline)
141 string lfilepath(xfile);
142 string::size_type lidx = lfilepath.find_last_of(
"/\\");
143 string lfilename = (lidx != string::npos) ? lfilepath.substr(lidx+1) : lfilepath;
146 lmsg <<
"'" << xmsg <<
"'" <<
" in function " << xfunction_name <<
" in file " << lfilename <<
" at line " << xline;
148 print_output_message(
"CONTRACT VIOLATION", lmsg.str());
149 throw std::logic_error(lmsg.str());
176 check_contract(
bool xcond,
const char* xcond_msg,
int xi,
const char* xi_msg,
const char* xfunction_name,
const char* xfile,
int xline)
180 string lfilepath(xfile);
181 string::size_type lidx = lfilepath.find_last_of(
"/\\");
182 string lfilename = (lidx != string::npos) ? lfilepath.substr(lidx+1) : lfilepath;
185 lmsg <<
"'" << xcond_msg <<
"'" 186 <<
" failed at " << xi_msg <<
" = " << xi
187 <<
" in function " << xfunction_name <<
" in file " << lfilename <<
" at line " << xline;
189 print_output_message(
"CONTRACT VIOLATION", lmsg.str());
190 throw std::logic_error(lmsg.str());
214 const char* xfunction_name,
const char* xfile,
int xline)
216 string lfilepath(xfile);
217 string::size_type lidx = lfilepath.find_last_of(
"/\\");
218 string lfilename = (lidx != string::npos) ? lfilepath.substr(lidx+1) : lfilepath;
221 lmsg <<
"'" << xcond_msg <<
"'" 222 <<
" not true for any " << xi_msg <<
" in [" << xmin <<
", " << xub <<
")" 223 <<
" in function " << xfunction_name <<
" in file " << lfilename <<
" at line " << xline;
225 print_output_message(
"CONTRACT VIOLATION", lmsg.str());
226 throw std::logic_error(lmsg.str());
248 string lfilepath(xfile);
249 string::size_type lidx = lfilepath.find_last_of(
"/\\");
250 string lfilename = (lidx != string::npos) ? lfilepath.substr(lidx+1) : lfilepath;
253 lmsg <<
"Function " << xfunction_name <<
" in file " << lfilename <<
" at line " << xline <<
" " << xcond_msg;
255 print_output_message(
"UNIMPLEMENTED", lmsg.str());
256 throw std::logic_error(lmsg.str());
SHEAF_DLL_SPEC void post_there_exists_failed(const char *xcond_msg, int xi, const char *xi_msg, int xmin, int xub, const char *xfunction_name, const char *xfile, int xline)
Throws exception for existential quantification failure.
Namespace for the sheaves component of the sheaf system.
SHEAF_DLL_SPEC void check_contract(bool xcond, const char *xmsg, const char *xfunction_name, const char *xfile, int xline)
Tests condition xcond and throws exception if false; exception message includes xmsg, file name xfile, and line number xline.
SHEAF_DLL_SPEC void post_unimplemented(const char *xcond_msg, const char *xfunction_name, const char *xfile, int xline)
Throws exception for attempt to invoke is_abstract or not implemented.