From 779f61c6a3ce02a119e28e802f229e61b69b9046 Mon Sep 17 00:00:00 2001 From: temporal Date: Wed, 13 Aug 2008 03:15:00 +0000 Subject: Integrate recent changes from google3. protoc - New flags --encode and --decode can be used to convert between protobuf text format and binary format from the command-line. - New flag --descriptor_set_out can be used to write FileDescriptorProtos for all parsed files directly into a single output file. This is particularly useful if you wish to parse .proto files from programs written in languages other than C++: just run protoc as a background process and have it output a FileDescriptorList, then parse that natively. C++ - Reflection objects are now per-class rather than per-instance. To make this possible, the Reflection interface had to be changed such that all methods take the Message instance as a parameter. This change improves performance significantly in memory-bandwidth-limited use cases, since it makes the message objects smaller. Note that source-incompatible interface changes like this will not be made again after the library leaves beta. Python - MergeFrom(message) and CopyFrom(message) are now implemented. - SerializeToString() raises an exception if the message is missing required fields. - Code organization improvements. - Fixed doc comments for RpcController and RpcChannel, which had somehow been swapped. --- .../protobuf/compiler/command_line_interface.h | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/google/protobuf/compiler/command_line_interface.h') diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index d3cae75e..9185e47a 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -35,6 +35,7 @@ namespace google { namespace protobuf { class FileDescriptor; // descriptor.h +class DescriptorPool; // descriptor.h namespace compiler { @@ -164,6 +165,12 @@ class LIBPROTOC_EXPORT CommandLineInterface { bool GenerateOutput(const FileDescriptor* proto_file, const OutputDirective& output_directive); + // Implements --encode and --decode. + bool EncodeOrDecode(const DescriptorPool* pool); + + // Implements the --descriptor_set_out option. + bool WriteDescriptorSet(const vector parsed_files); + // ----------------------------------------------------------------- // The name of the executable as invoked (i.e. argv[0]). @@ -181,6 +188,14 @@ class LIBPROTOC_EXPORT CommandLineInterface { GeneratorMap generators_; // Stuff parsed from command line. + enum Mode { + MODE_COMPILE, // Normal mode: parse .proto files and compile them. + MODE_ENCODE, // --encode: read text from stdin, write binary to stdout. + MODE_DECODE // --decode: read binary from stdin, write text to stdout. + }; + + Mode mode_; + vector > proto_path_; // Search path for proto files. vector input_files_; // Names of the input proto files. @@ -194,6 +209,19 @@ class LIBPROTOC_EXPORT CommandLineInterface { }; vector output_directives_; + // When using --encode or --decode, this names the type we are encoding or + // decoding. (Empty string indicates --decode_raw.) + string codec_type_; + + // If --descriptor_set_out was given, this is the filename to which the + // FileDescriptorSet should be written. Otherwise, empty. + string descriptor_set_name_; + + // True if --include_imports was given, meaning that we should + // write all transitive dependencies to the DescriptorSet. Otherwise, only + // the .proto files listed on the command-line are added. + bool imports_in_descriptor_set_; + // Was the --disallow_services flag used? bool disallow_services_; -- cgit v1.2.3