ROSE  0.11.51.0
processSupport.h
1 #ifndef ROSE_PROCESSSUPPORT_H
2 #define ROSE_PROCESSSUPPORT_H
3 
4 #include <vector>
5 #include <string>
6 #include <cstdio>
7 #include <exception>
8 #include "rosedll.h"
9 #include <Sawyer/Assert.h>
10 
11 // The various definistions of ROSE_ASSERT have been moved in to the
12 // following file. JFR 2020-Jun-05
13 
14 #include <ROSE_ABORT.h>
15 #include <ROSE_ASSERT.h>
16 
17 ROSE_UTIL_API int systemFromVector(const std::vector<std::string>& argv);
18 FILE* popenReadFromVector(const std::vector<std::string>& argv);
19 // Assumes there is only one child process
20 int pcloseFromVector(FILE* f);
21 
23 // Assertion handling
25 namespace Rose {
26 
28 ROSE_UTIL_API void abortOnFailedAssertion(const char*, const char*, const std::string&, const char*, unsigned, const char*);
29 
31 ROSE_UTIL_API void exitOnFailedAssertion(const char*, const char*, const std::string&, const char*, unsigned, const char*);
32 
36 ROSE_UTIL_API void throwOnFailedAssertion(const char*, const char*, const std::string&, const char*, unsigned, const char*);
37 
54 struct FailedAssertion: std::runtime_error {
55  const char *mesg; // a short message, like "assertion failed", "not implemented" etc.
56  const char *expr; // C++ expression that caused the failure (optional)
57  std::string note; // second argument from ASSERT_*() macros, or empty
58  const char *fileName; // name of file where assertion failed
59  unsigned lineNumber; // line number where assertion failed (1-origin)
60  const char *functionName; // function name (perhaps with arg types) where assertion failed
61  FailedAssertion(const char *mesg, const char *expr, const std::string &note,
62  const char *fileName, unsigned lineNumber, const char *functionName)
63  : std::runtime_error(expr?expr:mesg), mesg(mesg), expr(expr), note(note), fileName(fileName),
64  lineNumber(lineNumber), functionName(functionName) {}
65  ~FailedAssertion() throw () {};
66 };
67 
68 } // namespace
69 
70 #endif // ROSE_PROCESSSUPPORT_H
ROSE_UTIL_API void exitOnFailedAssertion(const char *, const char *, const std::string &, const char *, unsigned, const char *)
Exits with non-zero status for a failed assertion.
Main namespace for the ROSE library.
void(* AssertFailureHandler)(const char *mesg, const char *expr, const std::string &note, const char *filename, unsigned linenum, const char *funcname)
Type for user-defined assertion failure handler.
Definition: Assert.h:98
Exception that can be thrown for a failed assertion.
ROSE_UTIL_API void abortOnFailedAssertion(const char *, const char *, const std::string &, const char *, unsigned, const char *)
Aborts for a failed assertion.
ROSE_UTIL_API void throwOnFailedAssertion(const char *, const char *, const std::string &, const char *, unsigned, const char *)
Throws an exception for a failed assertion.
ROSE_UTIL_API void failedAssertionBehavior(Sawyer::Assert::AssertFailureHandler handler)
Property: behavior of failed assertions.