#include <google/protobuf/compiler/code_generator.h>
namespace google::protobuf::compiler
Defines the abstract interface implemented by each of the language-specific code generators.
Classes in this file | |
|---|---|
The abstract interface to a class which generates code implementing a particular proto file in a particular language. | |
CodeGenerators generate one or more files in a given directory. | |
File MembersThese definitions are not part of any class. | |
|---|---|
void | ParseGeneratorParameter(const string & , vector< pair< string, string > > * )Several code generators treat the parameter argument as holding a list of options separated by commas. more... |
void compiler::ParseGeneratorParameter(
const string & ,
vector< pair< string, string > > * )Several code generators treat the parameter argument as holding a list of options separated by commas.
This helper function parses a set of comma-delimited name/value pairs: e.g., "foo=bar,baz,qux=corge" parses to the pairs:
("foo", "bar"), ("baz", ""), ("qux", "corge")
#include <google/protobuf/compiler/code_generator.h>
namespace google::protobuf::compiler
The abstract interface to a class which generates code implementing a particular proto file in a particular language.
A number of these may be registered with CommandLineInterface to support various languages.
Known subclasses:
Members | |
|---|---|
| CodeGenerator() |
virtual | ~CodeGenerator() |
virtual bool | Generate(const FileDescriptor * file, const string & parameter, OutputDirectory * output_directory, string * error) const = 0Generates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool CodeGenerator::Generate(
const FileDescriptor * file,
const string & parameter,
OutputDirectory * output_directory,
string * error) const = 0Generates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used by Java and similar languages to specify which specific class from the proto file is to be generated, though it could have other uses as well. It is empty if no parameter was given.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
#include <google/protobuf/compiler/code_generator.h>
namespace google::protobuf::compiler
CodeGenerators generate one or more files in a given directory.
This abstract interface represents the directory to which the CodeGenerator is to write.
Members | |
|---|---|
| OutputDirectory() |
virtual | ~OutputDirectory() |
virtual io::ZeroCopyOutputStream * | Open(const string & filename) = 0Opens the given file, truncating it if it exists, and returns a ZeroCopyOutputStream that writes to the file. more... |
virtual io::ZeroCopyOutputStream *
OutputDirectory::Open(
const string & filename) = 0Opens the given file, truncating it if it exists, and returns a ZeroCopyOutputStream that writes to the file.
The caller takes ownership of the returned object. This method never fails (a dummy stream will be returned instead).
The filename given should be relative to the root of the source tree. E.g. the C++ generator, when generating code for "foo/bar.proto", will generate the files "foo/bar.pb2.h" and "foo/bar.pb2.cc"; note that "foo/" is included in these filenames. The filename is not allowed to contain "." or ".." components.