0473f88b9f
It is very similiar to protoc-gen-javastream, which generates field Ids used by ProtoOutputStream.cpp to dump protobuf data. Bug: 65641021 Test: compile the streaming_proto: $ mmm -j frameworks/base/tools/streaming_proto/ and run: $ PATH=$PATH:out/host/linux-x86/bin/protoc-gen-cppstream aprotoc --cppstream_out=tmp/ frameworks/base/core/proto/android/service/procstats.proto frameworks/base/core/proto/android/util/common.proto Change-Id: I68becc80b5166455455c5df28cd698601b4a1c1d
49 lines
883 B
C++
49 lines
883 B
C++
#include <stdio.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace android {
|
|
namespace stream_proto {
|
|
|
|
using namespace std;
|
|
|
|
struct Error
|
|
{
|
|
Error();
|
|
explicit Error(const Error& that);
|
|
Error(const string& filename, int lineno, const char* message);
|
|
|
|
string filename;
|
|
int lineno;
|
|
string message;
|
|
};
|
|
|
|
class Errors
|
|
{
|
|
public:
|
|
Errors();
|
|
~Errors();
|
|
|
|
// Add an error
|
|
void Add(const string& filename, int lineno, const char* format, ...);
|
|
|
|
// Print the errors to stderr if there are any.
|
|
void Print() const;
|
|
|
|
bool HasErrors() const;
|
|
|
|
private:
|
|
// The errors that have been added
|
|
vector<Error> m_errors;
|
|
void AddImpl(const string& filename, int lineno, const char* format, va_list ap);
|
|
};
|
|
|
|
extern Errors ERRORS;
|
|
extern const string UNKNOWN_FILE;
|
|
extern const int UNKNOWN_LINE;
|
|
|
|
|
|
} // namespace stream_proto
|
|
} // namespace android
|