summaryrefslogtreecommitdiff
path: root/tools/streaming_proto/stream_proto_utils.h
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-10-20 16:17:58 -0700
committerYi Jin <jinyithu@google.com>2017-11-01 17:49:42 +0000
commitf9ed04b3d938b06329fcd14d4f2b461000d028da (patch)
tree2a660ca1ce48c4e9deaea14524393a63ba98d1c1 /tools/streaming_proto/stream_proto_utils.h
parentf8a9169949c589755d300530f7b2390e687a9f8b (diff)
Remove the extra mapping of field types in ProtoOutputStream
It is very unlikely the protobuf changes the value in descriptor.h, and if defines an extra mapping, there are several places to maintain: 1. java-stream, 2. cpp-stream, 3. ProtoOutputStream.java 4. ProtoOutputStream.cpp 5. Privacy.h (GetFieldId) 6. StatsLog to generate field id (type << 32 + field number) Therefore use the current value in descriptor.h seems reasonable unless they change that, very very unlikely, they probably will just add new types, and deprect the existing ones like Group. Test: test output of dumpsys proto Change-Id: I6e150ab427851dd3b5dd55d3b273deeed7a0963c
Diffstat (limited to 'tools/streaming_proto/stream_proto_utils.h')
-rw-r--r--tools/streaming_proto/stream_proto_utils.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/streaming_proto/stream_proto_utils.h b/tools/streaming_proto/stream_proto_utils.h
new file mode 100644
index 000000000000..5297eccba849
--- /dev/null
+++ b/tools/streaming_proto/stream_proto_utils.h
@@ -0,0 +1,29 @@
+#include <stdint.h>
+
+#include "google/protobuf/compiler/plugin.pb.h"
+#include "google/protobuf/io/zero_copy_stream_impl.h"
+
+namespace android {
+namespace stream_proto {
+
+using namespace google::protobuf;
+using namespace google::protobuf::compiler;
+using namespace std;
+
+/**
+ * Get encoded field id from a field.
+ */
+uint64_t get_field_id(const FieldDescriptorProto& field);
+
+/**
+ * Get the string name for a field.
+ */
+string get_proto_type(const FieldDescriptorProto& field);
+
+/**
+ * See if this is the file for this request, and not one of the imported ones.
+ */
+bool should_generate_for_file(const CodeGeneratorRequest& request, const string& file);
+
+} // stream_proto
+} // android