Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include <string> |
| 4 | #include <vector> |
| 5 | |
| 6 | namespace android { |
Yi Jin | 0473f88b | 2017-10-09 11:21:40 -0700 | [diff] [blame] | 7 | namespace stream_proto { |
Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 8 | |
| 9 | using namespace std; |
| 10 | |
| 11 | struct Error |
| 12 | { |
| 13 | Error(); |
| 14 | explicit Error(const Error& that); |
| 15 | Error(const string& filename, int lineno, const char* message); |
| 16 | |
| 17 | string filename; |
| 18 | int lineno; |
| 19 | string message; |
| 20 | }; |
| 21 | |
| 22 | class Errors |
| 23 | { |
| 24 | public: |
| 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 | |
| 36 | private: |
| 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 | |
| 42 | extern Errors ERRORS; |
| 43 | extern const string UNKNOWN_FILE; |
| 44 | extern const int UNKNOWN_LINE; |
| 45 | |
| 46 | |
Yi Jin | 0473f88b | 2017-10-09 11:21:40 -0700 | [diff] [blame] | 47 | } // namespace stream_proto |
Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 48 | } // namespace android |