diff options
Diffstat (limited to 'src/google/protobuf/compiler/code_generator.cc')
-rw-r--r-- | src/google/protobuf/compiler/code_generator.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index 149d34af..0def84d8 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc @@ -34,6 +34,8 @@ #include <google/protobuf/compiler/code_generator.h> +#include <google/protobuf/stubs/strutil.h> + namespace google { namespace protobuf { namespace compiler { @@ -41,6 +43,26 @@ namespace compiler { CodeGenerator::~CodeGenerator() {} OutputDirectory::~OutputDirectory() {} +// Parses a set of comma-delimited name/value pairs. +void ParseGeneratorParameter(const string& text, + vector<pair<string, string> >* output) { + vector<string> parts; + SplitStringUsing(text, ",", &parts); + + for (int i = 0; i < parts.size(); i++) { + string::size_type equals_pos = parts[i].find_first_of('='); + pair<string, string> value; + if (equals_pos == string::npos) { + value.first = parts[i]; + value.second = ""; + } else { + value.first = parts[i].substr(0, equals_pos); + value.second = parts[i].substr(equals_pos + 1); + } + output->push_back(value); + } +} + } // namespace compiler } // namespace protobuf } // namespace google |