1#include <stdio.h> 2 3#include <string> 4#include <vector> 5 6namespace android { 7namespace javastream_proto { 8 9using namespace std; 10 11struct 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 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 47} // namespace javastream_proto 48} // namespace android 49