https://github.com/protobuf-c/protobuf-c/pull/309 https://github.com/protobuf-c/protobuf-c/pull/328 --- /protoc-c/c_field.cc +++ /protoc-c/c_field.cc @@ -189,7 +189,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor) : descriptor_(descriptor), field_generators_( - new scoped_ptr[descriptor->field_count()]) { + new std::unique_ptr[descriptor->field_count()]) { // Construct all the FieldGenerators. for (int i = 0; i < descriptor->field_count(); i++) { field_generators_[i].reset(MakeGenerator(descriptor->field(i))); --- /protoc-c/c_field.h +++ /protoc-c/c_field.h @@ -117,7 +117,7 @@ private: const Descriptor* descriptor_; - scoped_array > field_generators_; + std::unique_ptr[] > field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field); --- /protoc-c/c_file.cc +++ /protoc-c/c_file.cc @@ -83,13 +83,13 @@ const string& dllexport_decl) : file_(file), message_generators_( - new scoped_ptr[file->message_type_count()]), + new std::unique_ptr[file->message_type_count()]), enum_generators_( - new scoped_ptr[file->enum_type_count()]), + new std::unique_ptr[file->enum_type_count()]), service_generators_( - new scoped_ptr[file->service_count()]), + new std::unique_ptr[file->service_count()]), extension_generators_( - new scoped_ptr[file->extension_count()]) { + new std::unique_ptr[file->extension_count()]) { for (int i = 0; i < file->message_type_count(); i++) { message_generators_[i].reset( --- /protoc-c/c_file.h +++ /protoc-c/c_file.h @@ -98,13 +98,13 @@ private: const FileDescriptor* file_; - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; + std::unique_ptr[] > message_generators_; + std::unique_ptr[] > enum_generators_; + std::unique_ptr[] > service_generators_; + std::unique_ptr[] > extension_generators_; // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; + std::vector package_parts_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; --- /protoc-c/c_generator.cc +++ /protoc-c/c_generator.cc @@ -80,13 +80,13 @@ // "foo=bar,baz,qux=corge" // parses to the pairs: // ("foo", "bar"), ("baz", ""), ("qux", "corge") -void ParseOptions(const string& text, vector >* output) { - vector parts; +void ParseOptions(const string& text, std::vector >* output) { + std::vector parts; SplitStringUsing(text, ",", &parts); for (unsigned i = 0; i < parts.size(); i++) { string::size_type equals_pos = parts[i].find_first_of('='); - pair value; + std::pair value; if (equals_pos == string::npos) { value.first = parts[i]; value.second = ""; @@ -105,7 +105,7 @@ const string& parameter, OutputDirectory* output_directory, string* error) const { - vector > options; + std::vector > options; ParseOptions(parameter, &options); // ----------------------------------------------------------------- @@ -149,7 +149,7 @@ // Generate header. { - scoped_ptr output( + std::unique_ptr output( output_directory->Open(basename + ".h")); io::Printer printer(output.get(), '$'); file_generator.GenerateHeader(&printer); @@ -157,7 +157,7 @@ // Generate cc file. { - scoped_ptr output( + std::unique_ptr output( output_directory->Open(basename + ".c")); io::Printer printer(output.get(), '$'); file_generator.GenerateSource(&printer); --- /protoc-c/c_helpers.cc +++ /protoc-c/c_helpers.cc @@ -177,7 +177,7 @@ } string FullNameToLower(const string &full_name) { - vector pieces; + std::vector pieces; SplitStringUsing(full_name, ".", &pieces); string rv = ""; for (unsigned i = 0; i < pieces.size(); i++) { @@ -188,7 +188,7 @@ return rv; } string FullNameToUpper(const string &full_name) { - vector pieces; + std::vector pieces; SplitStringUsing(full_name, ".", &pieces); string rv = ""; for (unsigned i = 0; i < pieces.size(); i++) { @@ -199,7 +199,7 @@ return rv; } string FullNameToC(const string &full_name) { - vector pieces; + std::vector pieces; SplitStringUsing(full_name, ".", &pieces); string rv = ""; for (unsigned i = 0; i < pieces.size(); i++) { @@ -214,7 +214,7 @@ { if (!comment.empty()) { - vector comment_lines; + std::vector comment_lines; SplitStringUsing (comment, "\r\n", &comment_lines); printer->Print ("/*\n"); for (int i = 0; i < comment_lines.size(); i++) @@ -503,8 +503,8 @@ void SplitStringUsing(const string& full, const char* delim, - vector* result) { - std::back_insert_iterator< vector > it(*result); + std::vector* result) { + std::back_insert_iterator< std::vector > it(*result); SplitStringToIteratorUsing(full, delim, it); } @@ -559,7 +559,7 @@ } string CEscape(const string& src) { const int dest_length = src.size() * 4 + 1; // Maximum possible expansion - scoped_array dest(new char[dest_length]); + std::unique_ptr dest(new char[dest_length]); const int len = CEscapeInternal(src.data(), src.size(), dest.get(), dest_length, false); GOOGLE_DCHECK_GE(len, 0); --- /protoc-c/c_message.cc +++ /protoc-c/c_message.cc @@ -83,11 +83,11 @@ : descriptor_(descriptor), dllexport_decl_(dllexport_decl), field_generators_(descriptor), - nested_generators_(new scoped_ptr[ + nested_generators_(new std::unique_ptr[ descriptor->nested_type_count()]), - enum_generators_(new scoped_ptr[ + enum_generators_(new std::unique_ptr[ descriptor->enum_type_count()]), - extension_generators_(new scoped_ptr[ + extension_generators_(new std::unique_ptr[ descriptor->extension_count()]) { for (int i = 0; i < descriptor->nested_type_count(); i++) { --- /protoc-c/c_message.h +++ /protoc-c/c_message.h @@ -126,9 +126,9 @@ const Descriptor* descriptor_; string dllexport_decl_; FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; + std::unique_ptr[] > nested_generators_; + std::unique_ptr[] > enum_generators_; + std::unique_ptr[] > extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); };