-
Notifications
You must be signed in to change notification settings - Fork 1
/
errorstrings.h
50 lines (40 loc) · 1.26 KB
/
errorstrings.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef ERRORSTRINGS_H
#define ERRORSTRINGS_H
// {{SMILE_PUBLIC_HEADER}}
#ifndef INTARRAY_H
#include "intarray.h"
#endif
#ifndef STRINGARRAY_H
#include "stringarray.h"
#endif
class DSL_errorStringRedirect
{
public:
virtual ~DSL_errorStringRedirect() {}
virtual void LogError(int code, const char *message) = 0;
};
class DSL_errorStringHandler
{
public:
DSL_errorStringHandler() { redirection = NULL; ownedRedirection = false; }
~DSL_errorStringHandler() { if (ownedRedirection) delete redirection; }
int LogError(int theCode, const char *theMessage = NULL, const char *prefix = NULL);
int GetError(int thisOne);
int GetLastError();
const char* GetErrorMessage(int thisOne);
const char* GetLastErrorMessage();
int GetNumberOfErrors() { return errorCodes.NumItems(); }
void Flush();
// stdout/stderr can be passed as file arg
void RedirectToFile(FILE *file, const char *format = NULL);
void Redirect(DSL_errorStringRedirect *newRedirect);
private:
static const char * GetDefaultErrorString(int forThisCode);
DSL_stringArray errorStrings;
DSL_intArray errorCodes;
DSL_errorStringRedirect *redirection;
bool ownedRedirection;
};
// global error handler object
extern DSL_errorStringHandler ErrorH;
#endif