blob: bddd9819e8f59302fc98e37f713b7ee907566544 [file] [log] [blame]
Joe Onorato6c9547d2016-09-07 18:43:49 -07001#include <stdio.h>
2
3#include <string>
4#include <vector>
5
6namespace android {
Yi Jin0473f88b2017-10-09 11:21:40 -07007namespace stream_proto {
Joe Onorato6c9547d2016-09-07 18:43:49 -07008
9using namespace std;
10
11struct Error
12{
13 Error();
Chih-Hung Hsieh93561ab2018-12-20 13:54:17 -080014 Error(const Error& that);
Joe Onorato6c9547d2016-09-07 18:43:49 -070015 Error(const string& filename, int lineno, const char* message);
16
17 string filename;
18 int lineno;
19 string message;
20};
21
22class Errors
23{
24public:
25 Errors();
26 ~Errors();
27
28 // Add an error
29 void Add(const string& filename, int lineno, const char* format, ...);
30
31 // Print the errors to stderr if there are any.
32 void Print() const;
33
34 bool HasErrors() const;
35
36private:
37 // The errors that have been added
38 vector<Error> m_errors;
39 void AddImpl(const string& filename, int lineno, const char* format, va_list ap);
40};
41
42extern Errors ERRORS;
43extern const string UNKNOWN_FILE;
44extern const int UNKNOWN_LINE;
45
46
Yi Jin0473f88b2017-10-09 11:21:40 -070047} // namespace stream_proto
Joe Onorato6c9547d2016-09-07 18:43:49 -070048} // namespace android