srecord 1.65.0
 
Loading...
Searching...
No Matches
quit.h
Go to the documentation of this file.
1//
2// srecord - manipulate eprom load files
3// Copyright (C) 2000, 2002, 2003, 2006-2008, 2010, 2011 Peter Miller
4//
5// This program is free software; you can redistribute it and/or modify it
6// under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation; either version 3 of the License, or (at
8// your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
13// General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef SRECORD_QUIT_H
20#define SRECORD_QUIT_H
21
22#include <stdarg.h>
24
25namespace srecord
26{
27
28/**
29 * The quit class is an abstract class for reporting error messages,
30 * both fatal and non-fatal.
31 */
32class quit
33{
34public:
35 /**
36 * The destructor.
37 */
38 virtual ~quit();
39
40 /**
41 * The default constructor.
42 */
44
45 /**
46 * The copy constructor.
47 */
48 quit(const quit &);
49
50 /**
51 * The assignment operator.
52 */
53 quit &operator=(const quit &);
54
55 /**
56 * The fatal_error method is used to report fatal errors.
57 * The `fmt' string is in the same style a standard C printf
58 * function. It calls the fatal_error_v method. This method
59 * does not return.
60 */
61 virtual void fatal_error(const char *fmt, ...)
62 FORMAT_PRINTF(2, 3);
63 /**
64 * The fatal_error_v method is used to report fatal errors.
65 * The `fmt' string is in the same style a standard C vprintf
66 * function. It calls the message_v and exit methods.
67 * This method does not return.
68 */
69 virtual void fatal_error_v(const char *, va_list);
70
71 /**
72 * The fatal_error_errno method is used to report fatal errors,
73 * and append the string equivalent of errno. The `fmt' string
74 * is in the same style a standard C printf function. It calls
75 * the fatal_error_errno_v method. This method does not return.
76 */
77 virtual void fatal_error_errno(const char *fmt, ...)
78 FORMAT_PRINTF(2, 3);
79 /**
80 * The fatal_error_errno_v method is used to report fatal
81 * errors. The `fmt' string is in the same style a standard C
82 * vprintf function. It calls the message_v and exit methods.
83 * This method does not return.
84 */
85 virtual void fatal_error_errno_v(const char *, va_list);
86
87 /**
88 * The warning method is used to likely but non-fatal errors.
89 * The `fmt' string is in the same style a standard C printf
90 * function. It calls the warning_v method.
91 */
92 virtual void warning(const char *fmt, ...)
93 FORMAT_PRINTF(2, 3);
94 /**
95 * The warning_v method is used to report likely but non-fatal
96 * errors. The `fmt' string is in the same style a standard
97 * C vprintf function. It calls the message_v method.
98 */
99 virtual void warning_v(const char *, va_list);
100
101 /**
102 * The message method is used to send an error message to a
103 * suitable destination. The `fmt' string is in the same style
104 * a standard C printf function. The message_v method is called.
105 */
106 virtual void message(const char *fmt, ...)
107 FORMAT_PRINTF(2, 3);
108 /**
109 * The message_v method is used to send an error message to
110 * a suitable destination. The `fmt' string is in the same
111 * style a standard C vprintf function. Derived classes are
112 * required to supply this method.
113 */
114 virtual void message_v(const char *, va_list) = 0;
115
116 /**
117 * The exit method is used to terminate execution. It could
118 * call the global exit function, or it could throw an exception, or
119 * some other action, but it shall NOT return. Derived classes
120 * are required to supply this method.
121 */
122 virtual void exit(int) = 0;
123};
124
125/**
126 * The quit_default variable is a reference to a quit implementation.
127 * It should be used unless there is a good reason not to.
128 */
129extern quit &quit_default;
130
131};
132
133#endif // SRECORD_QUIT_H
virtual void warning(const char *fmt,...) FORMAT_PRINTF(2
The warning method is used to likely but non-fatal errors.
virtual ~quit()
The destructor.
virtual void virtual void fatal_error_errno_v(const char *, va_list)
The fatal_error_errno_v method is used to report fatal errors.
virtual void exit(int)=0
The exit method is used to terminate execution.
quit(const quit &)
The copy constructor.
virtual void fatal_error(const char *fmt,...) FORMAT_PRINTF(2
The fatal_error method is used to report fatal errors.
virtual void virtual void message_v(const char *, va_list)=0
The message_v method is used to send an error message to a suitable destination.
quit()
The default constructor.
quit & operator=(const quit &)
The assignment operator.
virtual void virtual void warning_v(const char *, va_list)
The warning_v method is used to report likely but non-fatal errors.
virtual void message(const char *fmt,...) FORMAT_PRINTF(2
The message method is used to send an error message to a suitable destination.
virtual void virtual void fatal_error_v(const char *, va_list)
The fatal_error_v method is used to report fatal errors.
virtual void fatal_error_errno(const char *fmt,...) FORMAT_PRINTF(2
The fatal_error_errno method is used to report fatal errors, and append the string equivalent of errn...
#define FORMAT_PRINTF(x, y)
quit & quit_default
The quit_default variable is a reference to a quit implementation.