diff options
Diffstat (limited to 'src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r-- | src/google/protobuf/compiler/command_line_interface.cc | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 79d2dd66..c1243272 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -173,7 +173,8 @@ bool VerifyDirectoryExists(const string& path) { // directories listed in |filename|. bool TryCreateParentDirectory(const string& prefix, const string& filename) { // Recursively create parent directories to the output file. - vector<string> parts = Split(filename, "/", true); + std::vector<string> parts = + Split(filename, "/", true); string path_so_far = prefix; for (int i = 0; i < parts.size() - 1; i++) { path_so_far += parts[i]; @@ -338,7 +339,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, // them all to disk on demand. class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { public: - GeneratorContextImpl(const vector<const FileDescriptor*>& parsed_files); + GeneratorContextImpl(const std::vector<const FileDescriptor*>& parsed_files); ~GeneratorContextImpl(); // Write all files in the directory to disk at the given output location, @@ -354,14 +355,14 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { void AddJarManifest(); // Get name of all output files. - void GetOutputFilenames(vector<string>* output_filenames); + void GetOutputFilenames(std::vector<string>* output_filenames); // implements GeneratorContext -------------------------------------- io::ZeroCopyOutputStream* Open(const string& filename); io::ZeroCopyOutputStream* OpenForAppend(const string& filename); io::ZeroCopyOutputStream* OpenForInsert( const string& filename, const string& insertion_point); - void ListParsedFiles(vector<const FileDescriptor*>* output) { + void ListParsedFiles(std::vector<const FileDescriptor*>* output) { *output = parsed_files_; } @@ -370,8 +371,8 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext { // map instead of hash_map so that files are written in order (good when // writing zips). - map<string, string*> files_; - const vector<const FileDescriptor*>& parsed_files_; + std::map<string, string*> files_; + const std::vector<const FileDescriptor*>& parsed_files_; bool had_error_; }; @@ -408,7 +409,7 @@ class CommandLineInterface::MemoryOutputStream // ------------------------------------------------------------------- CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl( - const vector<const FileDescriptor*>& parsed_files) + const std::vector<const FileDescriptor*>& parsed_files) : parsed_files_(parsed_files), had_error_(false) { } @@ -427,7 +428,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk( return false; } - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { const string& relative_filename = iter->first; const char* data = iter->second->data(); @@ -515,7 +516,7 @@ bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip( io::FileOutputStream stream(file_descriptor); ZipWriter zip_writer(&stream); - for (map<string, string*>::const_iterator iter = files_.begin(); + for (std::map<string, string*>::const_iterator iter = files_.begin(); iter != files_.end(); ++iter) { zip_writer.Write(iter->first, *iter->second); } @@ -544,8 +545,8 @@ void CommandLineInterface::GeneratorContextImpl::AddJarManifest() { } void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames( - vector<string>* output_filenames) { - for (map<string, string*>::iterator iter = files_.begin(); + std::vector<string>* output_filenames) { + for (std::map<string, string*>::iterator iter = files_.begin(); iter != files_.end(); ++iter) { output_filenames->push_back(iter->first); } @@ -768,7 +769,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { ErrorPrinter error_collector(error_format_, &source_tree); Importer importer(&source_tree, &error_collector); - vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; // Parse each file. for (int i = 0; i < input_files_.size(); i++) { @@ -978,7 +979,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { executable_name_ = argv[0]; - vector<string> arguments; + std::vector<string> arguments; for (int i = 1; i < argc; ++i) { arguments.push_back(argv[i]); } @@ -1012,7 +1013,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>("", ".")); + proto_path_.push_back(std::pair<string, string>("", ".")); } // Check some errror cases. @@ -1135,7 +1136,7 @@ CommandLineInterface::InterpretArgument(const string& name, // Java's -classpath (and some other languages) delimits path components // with colons. Let's accept that syntax too just to make things more // intuitive. - vector<string> parts = Split( + std::vector<string> parts = Split( value, kPathSeparator, true); for (int i = 0; i < parts.size(); i++) { @@ -1172,19 +1173,21 @@ CommandLineInterface::InterpretArgument(const string& name, // Don't use make_pair as the old/default standard library on Solaris // doesn't support it without explicit template parameters, which are // incompatible with C++0x's make_pair. - proto_path_.push_back(pair<string, string>(virtual_path, disk_path)); + proto_path_.push_back(std::pair<string, string>(virtual_path, disk_path)); } } else if (name == "--direct_dependencies") { if (direct_dependencies_explicitly_set_) { std::cerr << name << " may only be passed once. To specify multiple " "direct dependencies, pass them all as a single " - "parameter separated by ':'." << std::endl; + "parameter separated by ':'." + << std::endl; return PARSE_ARGUMENT_FAIL; } direct_dependencies_explicitly_set_ = true; - vector<string> direct = Split(value, ":", true); + std::vector<string> direct = Split( + value, ":", true); GOOGLE_DCHECK(direct_dependencies_.empty()); direct_dependencies_.insert(direct.begin(), direct.end()); @@ -1451,7 +1454,7 @@ void CommandLineInterface::PrintHelpText() { } bool CommandLineInterface::GenerateOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context) { // Call the generator. @@ -1493,12 +1496,12 @@ bool CommandLineInterface::GenerateOutput( } bool CommandLineInterface::GenerateDependencyManifestFile( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const GeneratorContextMap& output_directories, DiskSourceTree* source_tree) { FileDescriptorSet file_set; - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], false, @@ -1507,12 +1510,12 @@ bool CommandLineInterface::GenerateDependencyManifestFile( file_set.mutable_file()); } - vector<string> output_filenames; + std::vector<string> output_filenames; for (GeneratorContextMap::const_iterator iter = output_directories.begin(); iter != output_directories.end(); ++iter) { const string& location = iter->first; GeneratorContextImpl* directory = iter->second; - vector<string> relative_output_filenames; + std::vector<string> relative_output_filenames; directory->GetOutputFilenames(&relative_output_filenames); for (int i = 0; i < relative_output_filenames.size(); i++) { string output_filename = location + relative_output_filenames[i]; @@ -1565,7 +1568,7 @@ bool CommandLineInterface::GenerateDependencyManifestFile( } bool CommandLineInterface::GeneratePluginOutput( - const vector<const FileDescriptor*>& parsed_files, + const std::vector<const FileDescriptor*>& parsed_files, const string& plugin_name, const string& parameter, GeneratorContext* generator_context, @@ -1578,7 +1581,7 @@ bool CommandLineInterface::GeneratePluginOutput( request.set_parameter(parameter); } - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { request.add_file_to_generate(parsed_files[i]->name()); GetTransitiveDependencies(parsed_files[i], @@ -1708,11 +1711,11 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) { } bool CommandLineInterface::WriteDescriptorSet( - const vector<const FileDescriptor*> parsed_files) { + const std::vector<const FileDescriptor*> parsed_files) { FileDescriptorSet file_set; if (imports_in_descriptor_set_) { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { GetTransitiveDependencies(parsed_files[i], true, // Include json_name @@ -1720,7 +1723,7 @@ bool CommandLineInterface::WriteDescriptorSet( &already_seen, file_set.mutable_file()); } } else { - set<const FileDescriptor*> already_seen; + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { if (!already_seen.insert(parsed_files[i]).second) { continue; @@ -1765,7 +1768,7 @@ void CommandLineInterface::GetTransitiveDependencies( const FileDescriptor* file, bool include_json_name, bool include_source_code_info, - set<const FileDescriptor*>* already_seen, + std::set<const FileDescriptor*>* already_seen, RepeatedPtrField<FileDescriptorProto>* output) { if (!already_seen->insert(file).second) { // Already saw this file. Skip. @@ -1824,11 +1827,11 @@ namespace { // parameter will contain the direct children (when groups are ignored in the // tree) of the given descriptor for the caller to traverse. The declaration // order of the nested messages is also preserved. -typedef pair<int, int> FieldRange; -void GatherOccupiedFieldRanges(const Descriptor* descriptor, - set<FieldRange>* ranges, - vector<const Descriptor*>* nested_messages) { - set<const Descriptor*> groups; +typedef std::pair<int, int> FieldRange; +void GatherOccupiedFieldRanges( + const Descriptor* descriptor, std::set<FieldRange>* ranges, + std::vector<const Descriptor*>* nested_messages) { + std::set<const Descriptor*> groups; for (int i = 0; i < descriptor->field_count(); ++i) { const FieldDescriptor* fd = descriptor->field(i); ranges->insert(FieldRange(fd->number(), fd->number() + 1)); @@ -1860,11 +1863,11 @@ void GatherOccupiedFieldRanges(const Descriptor* descriptor, // Actually prints the formatted free field numbers for given message name and // occupied ranges. void FormatFreeFieldNumbers(const string& name, - const set<FieldRange>& ranges) { + const std::set<FieldRange>& ranges) { string output; StringAppendF(&output, "%-35s free:", name.c_str()); int next_free_number = 1; - for (set<FieldRange>::const_iterator i = ranges.begin(); + for (std::set<FieldRange>::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { // This happens when groups re-use parent field numbers, in which // case we skip the FieldRange entirely. @@ -1891,8 +1894,8 @@ void FormatFreeFieldNumbers(const string& name, void CommandLineInterface::PrintFreeFieldNumbers( const Descriptor* descriptor) { - set<FieldRange> ranges; - vector<const Descriptor*> nested_messages; + std::set<FieldRange> ranges; + std::vector<const Descriptor*> nested_messages; GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages); for (int i = 0; i < nested_messages.size(); ++i) { |