|  | @@ -82,18 +82,20 @@ namespace php {
 | 
	
		
			
				|  |  |  std::string PhpName(const std::string& full_name, bool is_descriptor);
 | 
	
		
			
				|  |  |  std::string DefaultForField(FieldDescriptor* field);
 | 
	
		
			
				|  |  |  std::string IntToString(int32 value);
 | 
	
		
			
				|  |  | -std::string FilenameToClassname(const string& filename);
 | 
	
		
			
				|  |  | +std::string FilenameToClassname(const std::string& filename);
 | 
	
		
			
				|  |  |  std::string GeneratedMetadataFileName(const FileDescriptor* file,
 | 
	
		
			
				|  |  |                                        bool is_descriptor);
 | 
	
		
			
				|  |  |  std::string LabelForField(FieldDescriptor* field);
 | 
	
		
			
				|  |  |  std::string TypeName(FieldDescriptor* field);
 | 
	
		
			
				|  |  | -std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter);
 | 
	
		
			
				|  |  | -std::string BinaryToHex(const string& binary);
 | 
	
		
			
				|  |  | +std::string UnderscoresToCamelCase(const std::string& name,
 | 
	
		
			
				|  |  | +                                   bool cap_first_letter);
 | 
	
		
			
				|  |  | +std::string BinaryToHex(const std::string& binary);
 | 
	
		
			
				|  |  |  void Indent(io::Printer* printer);
 | 
	
		
			
				|  |  |  void Outdent(io::Printer* printer);
 | 
	
		
			
				|  |  | -void GenerateAddFilesToPool(const FileDescriptor* file,
 | 
	
		
			
				|  |  | -                            const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | -                            io::Printer* printer);
 | 
	
		
			
				|  |  | +void GenerateAddFilesToPool(
 | 
	
		
			
				|  |  | +    const FileDescriptor* file,
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +    io::Printer* printer);
 | 
	
		
			
				|  |  |  void GenerateMessageDocComment(io::Printer* printer, const Descriptor* message,
 | 
	
		
			
				|  |  |                                 int is_descriptor);
 | 
	
		
			
				|  |  |  void GenerateMessageConstructorDocComment(io::Printer* printer,
 | 
	
	
		
			
				|  | @@ -114,11 +116,11 @@ void GenerateServiceDocComment(io::Printer* printer,
 | 
	
		
			
				|  |  |  void GenerateServiceMethodDocComment(io::Printer* printer,
 | 
	
		
			
				|  |  |                                const MethodDescriptor* method);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -std::string ReservedNamePrefix(const string& classname,
 | 
	
		
			
				|  |  | +std::string ReservedNamePrefix(const std::string& classname,
 | 
	
		
			
				|  |  |                                  const FileDescriptor* file) {
 | 
	
		
			
				|  |  |    bool is_reserved = false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  string lower = classname;
 | 
	
		
			
				|  |  | +  std::string lower = classname;
 | 
	
		
			
				|  |  |    std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    for (int i = 0; i < kReservedNamesSize; i++) {
 | 
	
	
		
			
				|  | @@ -151,9 +153,9 @@ std::string DescriptorFullName(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  template <typename DescriptorType>
 | 
	
		
			
				|  |  | -std::string ClassNamePrefix(const string& classname,
 | 
	
		
			
				|  |  | +std::string ClassNamePrefix(const std::string& classname,
 | 
	
		
			
				|  |  |                              const DescriptorType* desc) {
 | 
	
		
			
				|  |  | -  const string& prefix = (desc->file()->options()).php_class_prefix();
 | 
	
		
			
				|  |  | +  const std::string& prefix = (desc->file()->options()).php_class_prefix();
 | 
	
		
			
				|  |  |    if (!prefix.empty()) {
 | 
	
		
			
				|  |  |      return prefix;
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -201,8 +203,8 @@ std::string LegacyGeneratedClassName(const DescriptorType* desc) {
 | 
	
		
			
				|  |  |    return ClassNamePrefix(classname, desc) + classname;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -std::string ClassNamePrefix(const string& classname) {
 | 
	
		
			
				|  |  | -  string lower = classname;
 | 
	
		
			
				|  |  | +std::string ClassNamePrefix(const std::string& classname) {
 | 
	
		
			
				|  |  | +  std::string lower = classname;
 | 
	
		
			
				|  |  |    std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    for (int i = 0; i < kReservedNamesSize; i++) {
 | 
	
	
		
			
				|  | @@ -214,10 +216,10 @@ std::string ClassNamePrefix(const string& classname) {
 | 
	
		
			
				|  |  |    return "";
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -std::string ConstantNamePrefix(const string& classname) {
 | 
	
		
			
				|  |  | +std::string ConstantNamePrefix(const std::string& classname) {
 | 
	
		
			
				|  |  |    bool is_reserved = false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  string lower = classname;
 | 
	
		
			
				|  |  | +  std::string lower = classname;
 | 
	
		
			
				|  |  |    std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    for (int i = 0; i < kReservedNamesSize; i++) {
 | 
	
	
		
			
				|  | @@ -244,7 +246,7 @@ std::string ConstantNamePrefix(const string& classname) {
 | 
	
		
			
				|  |  |  template <typename DescriptorType>
 | 
	
		
			
				|  |  |  std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  |    if (desc->file()->options().has_php_namespace()) {
 | 
	
		
			
				|  |  | -    const string& php_namespace = desc->file()->options().php_namespace();
 | 
	
		
			
				|  |  | +    const std::string& php_namespace = desc->file()->options().php_namespace();
 | 
	
		
			
				|  |  |      if (!php_namespace.empty()) {
 | 
	
		
			
				|  |  |        return php_namespace;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -259,8 +261,8 @@ std::string RootPhpNamespace(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  template <typename DescriptorType>
 | 
	
		
			
				|  |  |  std::string FullClassName(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  | -  string classname = GeneratedClassNameImpl(desc);
 | 
	
		
			
				|  |  | -  string php_namespace = RootPhpNamespace(desc, is_descriptor);
 | 
	
		
			
				|  |  | +  std::string classname = GeneratedClassNameImpl(desc);
 | 
	
		
			
				|  |  | +  std::string php_namespace = RootPhpNamespace(desc, is_descriptor);
 | 
	
		
			
				|  |  |    if (!php_namespace.empty()) {
 | 
	
		
			
				|  |  |      return php_namespace + "\\" + classname;
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -269,8 +271,8 @@ std::string FullClassName(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  template <typename DescriptorType>
 | 
	
		
			
				|  |  |  std::string LegacyFullClassName(const DescriptorType* desc, bool is_descriptor) {
 | 
	
		
			
				|  |  | -  string classname = LegacyGeneratedClassName(desc);
 | 
	
		
			
				|  |  | -  string php_namespace = RootPhpNamespace(desc, is_descriptor);
 | 
	
		
			
				|  |  | +  std::string classname = LegacyGeneratedClassName(desc);
 | 
	
		
			
				|  |  | +  std::string php_namespace = RootPhpNamespace(desc, is_descriptor);
 | 
	
		
			
				|  |  |    if (!php_namespace.empty()) {
 | 
	
		
			
				|  |  |      return php_namespace + "\\" + classname;
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -328,7 +330,7 @@ std::string DefaultForField(const FieldDescriptor* field) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  std::string GeneratedMetadataFileName(const FileDescriptor* file,
 | 
	
		
			
				|  |  |                                        bool is_descriptor) {
 | 
	
		
			
				|  |  | -  const string& proto_file = file->name();
 | 
	
		
			
				|  |  | +  const std::string& proto_file = file->name();
 | 
	
		
			
				|  |  |    int start_index = 0;
 | 
	
		
			
				|  |  |    int first_index = proto_file.find_first_of("/", start_index);
 | 
	
		
			
				|  |  |    std::string result = "";
 | 
	
	
		
			
				|  | @@ -351,7 +353,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    if (file->options().has_php_metadata_namespace()) {
 | 
	
		
			
				|  |  | -    const string& php_metadata_namespace =
 | 
	
		
			
				|  |  | +    const std::string& php_metadata_namespace =
 | 
	
		
			
				|  |  |          file->options().php_metadata_namespace();
 | 
	
		
			
				|  |  |      if (!php_metadata_namespace.empty() && php_metadata_namespace != "\\") {
 | 
	
		
			
				|  |  |        result += php_metadata_namespace;
 | 
	
	
		
			
				|  | @@ -362,7 +364,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  |      result += "GPBMetadata/";
 | 
	
		
			
				|  |  | -    while (first_index != string::npos) {
 | 
	
		
			
				|  |  | +    while (first_index != std::string::npos) {
 | 
	
		
			
				|  |  |        segment = UnderscoresToCamelCase(
 | 
	
		
			
				|  |  |            file_no_suffix.substr(start_index, first_index - start_index), true);
 | 
	
		
			
				|  |  |        result += ReservedNamePrefix(segment, file) + segment + "/";
 | 
	
	
		
			
				|  | @@ -373,7 +375,7 @@ std::string GeneratedMetadataFileName(const FileDescriptor* file,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // Append file name.
 | 
	
		
			
				|  |  |    int file_name_start = file_no_suffix.find_last_of("/");
 | 
	
		
			
				|  |  | -  if (file_name_start == string::npos) {
 | 
	
		
			
				|  |  | +  if (file_name_start == std::string::npos) {
 | 
	
		
			
				|  |  |      file_name_start = 0;
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  |      file_name_start += 1;
 | 
	
	
		
			
				|  | @@ -463,7 +465,7 @@ std::string PhpSetterTypeName(const FieldDescriptor* field, bool is_descriptor)
 | 
	
		
			
				|  |  |    if (field->is_map()) {
 | 
	
		
			
				|  |  |      return "array|\\Google\\Protobuf\\Internal\\MapField";
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  string type;
 | 
	
		
			
				|  |  | +  std::string type;
 | 
	
		
			
				|  |  |    switch (field->type()) {
 | 
	
		
			
				|  |  |      case FieldDescriptor::TYPE_INT32:
 | 
	
		
			
				|  |  |      case FieldDescriptor::TYPE_UINT32:
 | 
	
	
		
			
				|  | @@ -553,7 +555,8 @@ std::string EnumOrMessageSuffix(
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // Converts a name to camel-case. If cap_first_letter is true, capitalize the
 | 
	
		
			
				|  |  |  // first letter.
 | 
	
		
			
				|  |  | -std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter) {
 | 
	
		
			
				|  |  | +std::string UnderscoresToCamelCase(const std::string& name,
 | 
	
		
			
				|  |  | +                                   bool cap_first_letter) {
 | 
	
		
			
				|  |  |    std::string result;
 | 
	
		
			
				|  |  |    for (int i = 0; i < name.size(); i++) {
 | 
	
		
			
				|  |  |      if ('a' <= name[i] && name[i] <= 'z') {
 | 
	
	
		
			
				|  | @@ -587,8 +590,8 @@ std::string UnderscoresToCamelCase(const string& name, bool cap_first_letter) {
 | 
	
		
			
				|  |  |    return result;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -std::string BinaryToHex(const string& binary) {
 | 
	
		
			
				|  |  | -  string dest;
 | 
	
		
			
				|  |  | +std::string BinaryToHex(const std::string& binary) {
 | 
	
		
			
				|  |  | +  std::string dest;
 | 
	
		
			
				|  |  |    size_t i;
 | 
	
		
			
				|  |  |    unsigned char symbol[16] = {
 | 
	
		
			
				|  |  |      '0', '1', '2', '3',
 | 
	
	
		
			
				|  | @@ -844,15 +847,16 @@ void GenerateServiceMethod(const MethodDescriptor* method,
 | 
	
		
			
				|  |  |    );
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void GenerateMessageToPool(const string& name_prefix, const Descriptor* message,
 | 
	
		
			
				|  |  | -                           io::Printer* printer) {
 | 
	
		
			
				|  |  | +void GenerateMessageToPool(const std::string& name_prefix,
 | 
	
		
			
				|  |  | +                           const Descriptor* message, io::Printer* printer) {
 | 
	
		
			
				|  |  |    // Don't generate MapEntry messages -- we use the PHP extension's native
 | 
	
		
			
				|  |  |    // support for map fields instead.
 | 
	
		
			
				|  |  |    if (message->options().map_entry()) {
 | 
	
		
			
				|  |  |      return;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  string class_name = (name_prefix.empty() ? "" : name_prefix + "\\") +
 | 
	
		
			
				|  |  | -    ReservedNamePrefix(message->name(), message->file()) + message->name();
 | 
	
		
			
				|  |  | +  std::string class_name =
 | 
	
		
			
				|  |  | +      (name_prefix.empty() ? "" : name_prefix + "\\") +
 | 
	
		
			
				|  |  | +      ReservedNamePrefix(message->name(), message->file()) + message->name();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    printer->Print(
 | 
	
		
			
				|  |  |        "$pool->addMessage('^message^', "
 | 
	
	
		
			
				|  | @@ -926,10 +930,8 @@ void GenerateMessageToPool(const string& name_prefix, const Descriptor* message,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void GenerateAddFileToPool(
 | 
	
		
			
				|  |  | -    const FileDescriptor* file,
 | 
	
		
			
				|  |  | -    bool is_descriptor,
 | 
	
		
			
				|  |  | -    bool aggregate_metadata,
 | 
	
		
			
				|  |  | -    const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +    const FileDescriptor* file, bool is_descriptor, bool aggregate_metadata,
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  |      io::Printer* printer) {
 | 
	
		
			
				|  |  |    printer->Print(
 | 
	
		
			
				|  |  |        "public static $is_initialized = false;\n\n"
 | 
	
	
		
			
				|  | @@ -978,8 +980,9 @@ void GenerateAddFileToPool(
 | 
	
		
			
				|  |  |        file->CopyTo(file_proto);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        // Filter out descriptor.proto as it cannot be depended on for now.
 | 
	
		
			
				|  |  | -      RepeatedPtrField<string>* dependency = file_proto->mutable_dependency();
 | 
	
		
			
				|  |  | -      for (RepeatedPtrField<string>::iterator it = dependency->begin();
 | 
	
		
			
				|  |  | +      RepeatedPtrField<std::string>* dependency =
 | 
	
		
			
				|  |  | +          file_proto->mutable_dependency();
 | 
	
		
			
				|  |  | +      for (RepeatedPtrField<std::string>::iterator it = dependency->begin();
 | 
	
		
			
				|  |  |             it != dependency->end(); ++it) {
 | 
	
		
			
				|  |  |          if (*it != kDescriptorFile) {
 | 
	
		
			
				|  |  |            dependency->erase(it);
 | 
	
	
		
			
				|  | @@ -996,7 +999,7 @@ void GenerateAddFileToPool(
 | 
	
		
			
				|  |  |          it->clear_extension();
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      string files_data;
 | 
	
		
			
				|  |  | +      std::string files_data;
 | 
	
		
			
				|  |  |        files.SerializeToString(&files_data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        printer->Print("$pool->internalAddGeneratedFile(hex2bin(\n");
 | 
	
	
		
			
				|  | @@ -1053,7 +1056,7 @@ static void AnalyzeDependencyForFile(
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  static bool NeedsUnwrapping(
 | 
	
		
			
				|  |  |      const FileDescriptor* file,
 | 
	
		
			
				|  |  | -    const std::set<string>& aggregate_metadata_prefixes) {
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes) {
 | 
	
		
			
				|  |  |    bool has_aggregate_metadata_prefix = false;
 | 
	
		
			
				|  |  |    if (aggregate_metadata_prefixes.empty()) {
 | 
	
		
			
				|  |  |      has_aggregate_metadata_prefix = true;
 | 
	
	
		
			
				|  | @@ -1071,7 +1074,7 @@ static bool NeedsUnwrapping(
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void GenerateAddFilesToPool(
 | 
	
		
			
				|  |  |      const FileDescriptor* file,
 | 
	
		
			
				|  |  | -    const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  |      io::Printer* printer) {
 | 
	
		
			
				|  |  |    printer->Print(
 | 
	
		
			
				|  |  |        "$pool = \\Google\\Protobuf\\Internal\\"
 | 
	
	
		
			
				|  | @@ -1108,8 +1111,9 @@ void GenerateAddFilesToPool(
 | 
	
		
			
				|  |  |        file->CopyTo(file_proto);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        // Filter out descriptor.proto as it cannot be depended on for now.
 | 
	
		
			
				|  |  | -      RepeatedPtrField<string>* dependency = file_proto->mutable_dependency();
 | 
	
		
			
				|  |  | -      for (RepeatedPtrField<string>::iterator it = dependency->begin();
 | 
	
		
			
				|  |  | +      RepeatedPtrField<std::string>* dependency =
 | 
	
		
			
				|  |  | +          file_proto->mutable_dependency();
 | 
	
		
			
				|  |  | +      for (RepeatedPtrField<std::string>::iterator it = dependency->begin();
 | 
	
		
			
				|  |  |             it != dependency->end(); ++it) {
 | 
	
		
			
				|  |  |          if (*it != kDescriptorFile) {
 | 
	
		
			
				|  |  |            dependency->erase(it);
 | 
	
	
		
			
				|  | @@ -1134,7 +1138,7 @@ void GenerateAddFilesToPool(
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  string files_data;
 | 
	
		
			
				|  |  | +  std::string files_data;
 | 
	
		
			
				|  |  |    sorted_file_set.SerializeToString(&files_data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    printer->Print("$pool->internalAddGeneratedFile(hex2bin(\n");
 | 
	
	
		
			
				|  | @@ -1177,7 +1181,7 @@ void GenerateHead(const FileDescriptor* file, io::Printer* printer) {
 | 
	
		
			
				|  |  |      "filename", file->name());
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -std::string FilenameToClassname(const string& filename) {
 | 
	
		
			
				|  |  | +std::string FilenameToClassname(const std::string& filename) {
 | 
	
		
			
				|  |  |    int lastindex = filename.find_last_of(".");
 | 
	
		
			
				|  |  |    std::string result = filename.substr(0, lastindex);
 | 
	
		
			
				|  |  |    for (int i = 0; i < result.size(); i++) {
 | 
	
	
		
			
				|  | @@ -1188,11 +1192,10 @@ std::string FilenameToClassname(const string& filename) {
 | 
	
		
			
				|  |  |    return result;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void GenerateMetadataFile(const FileDescriptor* file,
 | 
	
		
			
				|  |  | -                          bool is_descriptor,
 | 
	
		
			
				|  |  | -                          bool aggregate_metadata,
 | 
	
		
			
				|  |  | -                          const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | -                          GeneratorContext* generator_context) {
 | 
	
		
			
				|  |  | +void GenerateMetadataFile(
 | 
	
		
			
				|  |  | +    const FileDescriptor* file, bool is_descriptor, bool aggregate_metadata,
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +    GeneratorContext* generator_context) {
 | 
	
		
			
				|  |  |    std::string filename = GeneratedMetadataFileName(file, is_descriptor);
 | 
	
		
			
				|  |  |    std::unique_ptr<io::ZeroCopyOutputStream> output(
 | 
	
		
			
				|  |  |        generator_context->Open(filename));
 | 
	
	
		
			
				|  | @@ -1203,7 +1206,7 @@ void GenerateMetadataFile(const FileDescriptor* file,
 | 
	
		
			
				|  |  |    std::string fullname = FilenameToClassname(filename);
 | 
	
		
			
				|  |  |    int lastindex = fullname.find_last_of("\\");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      printer.Print(
 | 
	
		
			
				|  |  |          "namespace ^name^;\n\n",
 | 
	
		
			
				|  |  |          "name", fullname.substr(0, lastindex));
 | 
	
	
		
			
				|  | @@ -1277,7 +1280,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
 | 
	
		
			
				|  |  |    std::string fullname = FilenameToClassname(filename);
 | 
	
		
			
				|  |  |    int lastindex = fullname.find_last_of("\\");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      printer.Print(
 | 
	
		
			
				|  |  |          "namespace ^name^;\n\n",
 | 
	
		
			
				|  |  |          "name", fullname.substr(0, lastindex));
 | 
	
	
		
			
				|  | @@ -1289,7 +1292,7 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    GenerateEnumDocComment(&printer, en, is_descriptor);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      fullname = fullname.substr(lastindex + 1);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1389,7 +1392,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
 | 
	
		
			
				|  |  |    std::string fullname = FilenameToClassname(filename);
 | 
	
		
			
				|  |  |    int lastindex = fullname.find_last_of("\\");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      printer.Print(
 | 
	
		
			
				|  |  |          "namespace ^name^;\n\n",
 | 
	
		
			
				|  |  |          "name", fullname.substr(0, lastindex));
 | 
	
	
		
			
				|  | @@ -1398,7 +1401,7 @@ void GenerateMessageFile(const FileDescriptor* file, const Descriptor* message,
 | 
	
		
			
				|  |  |    GenerateUseDeclaration(is_descriptor, &printer);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    GenerateMessageDocComment(&printer, message, is_descriptor);
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      fullname = fullname.substr(lastindex + 1);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1497,7 +1500,7 @@ void GenerateServiceFile(const FileDescriptor* file,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    if (!file->options().php_namespace().empty() ||
 | 
	
		
			
				|  |  |        (!file->options().has_php_namespace() && !file->package().empty()) ||
 | 
	
		
			
				|  |  | -      lastindex != string::npos) {
 | 
	
		
			
				|  |  | +      lastindex != std::string::npos) {
 | 
	
		
			
				|  |  |      printer.Print(
 | 
	
		
			
				|  |  |          "namespace ^name^;\n\n",
 | 
	
		
			
				|  |  |          "name", fullname.substr(0, lastindex));
 | 
	
	
		
			
				|  | @@ -1505,13 +1508,13 @@ void GenerateServiceFile(const FileDescriptor* file,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    GenerateServiceDocComment(&printer, service);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  if (lastindex != string::npos) {
 | 
	
		
			
				|  |  | -      printer.Print(
 | 
	
		
			
				|  |  | +  if (lastindex != std::string::npos) {
 | 
	
		
			
				|  |  | +    printer.Print(
 | 
	
		
			
				|  |  |          "interface ^name^\n"
 | 
	
		
			
				|  |  |          "{\n",
 | 
	
		
			
				|  |  |          "name", fullname.substr(lastindex + 1));
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  | -      printer.Print(
 | 
	
		
			
				|  |  | +    printer.Print(
 | 
	
		
			
				|  |  |          "interface ^name^\n"
 | 
	
		
			
				|  |  |          "{\n",
 | 
	
		
			
				|  |  |          "name", fullname);
 | 
	
	
		
			
				|  | @@ -1531,7 +1534,7 @@ void GenerateServiceFile(const FileDescriptor* file,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void GenerateFile(const FileDescriptor* file, bool is_descriptor,
 | 
	
		
			
				|  |  |                    bool aggregate_metadata,
 | 
	
		
			
				|  |  | -                  const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +                  const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  |                    GeneratorContext* generator_context) {
 | 
	
		
			
				|  |  |    GenerateMetadataFile(file, is_descriptor, aggregate_metadata,
 | 
	
		
			
				|  |  |                         aggregate_metadata_prefixes, generator_context);
 | 
	
	
		
			
				|  | @@ -1553,13 +1556,13 @@ void GenerateFile(const FileDescriptor* file, bool is_descriptor,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -static string EscapePhpdoc(const string& input) {
 | 
	
		
			
				|  |  | -  string result;
 | 
	
		
			
				|  |  | +static std::string EscapePhpdoc(const std::string& input) {
 | 
	
		
			
				|  |  | +  std::string result;
 | 
	
		
			
				|  |  |    result.reserve(input.size() * 2);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    char prev = '*';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  for (string::size_type i = 0; i < input.size(); i++) {
 | 
	
		
			
				|  |  | +  for (std::string::size_type i = 0; i < input.size(); i++) {
 | 
	
		
			
				|  |  |      char c = input[i];
 | 
	
		
			
				|  |  |      switch (c) {
 | 
	
		
			
				|  |  |        case '*':
 | 
	
	
		
			
				|  | @@ -1598,8 +1601,9 @@ static string EscapePhpdoc(const string& input) {
 | 
	
		
			
				|  |  |  static void GenerateDocCommentBodyForLocation(
 | 
	
		
			
				|  |  |      io::Printer* printer, const SourceLocation& location, bool trailingNewline,
 | 
	
		
			
				|  |  |      int indentCount) {
 | 
	
		
			
				|  |  | -  string comments = location.leading_comments.empty() ?
 | 
	
		
			
				|  |  | -      location.trailing_comments : location.leading_comments;
 | 
	
		
			
				|  |  | +  std::string comments = location.leading_comments.empty()
 | 
	
		
			
				|  |  | +                             ? location.trailing_comments
 | 
	
		
			
				|  |  | +                             : location.leading_comments;
 | 
	
		
			
				|  |  |    if (!comments.empty()) {
 | 
	
		
			
				|  |  |      // TODO(teboring):  Ideally we should parse the comment text as Markdown and
 | 
	
		
			
				|  |  |      //   write it back as HTML, but this requires a Markdown parser.  For now
 | 
	
	
		
			
				|  | @@ -1609,7 +1613,7 @@ static void GenerateDocCommentBodyForLocation(
 | 
	
		
			
				|  |  |      // HTML-escape them so that they don't accidentally close the doc comment.
 | 
	
		
			
				|  |  |      comments = EscapePhpdoc(comments);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    std::vector<string> lines = Split(comments, "\n", true);
 | 
	
		
			
				|  |  | +    std::vector<std::string> lines = Split(comments, "\n", true);
 | 
	
		
			
				|  |  |      while (!lines.empty() && lines.back().empty()) {
 | 
	
		
			
				|  |  |        lines.pop_back();
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1640,11 +1644,11 @@ static void GenerateDocCommentBody(
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -static string FirstLineOf(const string& value) {
 | 
	
		
			
				|  |  | -  string result = value;
 | 
	
		
			
				|  |  | +static std::string FirstLineOf(const std::string& value) {
 | 
	
		
			
				|  |  | +  std::string result = value;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  string::size_type pos = result.find_first_of('\n');
 | 
	
		
			
				|  |  | -  if (pos != string::npos) {
 | 
	
		
			
				|  |  | +  std::string::size_type pos = result.find_first_of('\n');
 | 
	
		
			
				|  |  | +  if (pos != std::string::npos) {
 | 
	
		
			
				|  |  |      result.erase(pos);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1801,20 +1805,18 @@ void GenerateServiceMethodDocComment(io::Printer* printer,
 | 
	
		
			
				|  |  |      "return_type", EscapePhpdoc(FullClassName(method->output_type(), false)));
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool Generator::Generate(const FileDescriptor* file, const string& parameter,
 | 
	
		
			
				|  |  | +bool Generator::Generate(const FileDescriptor* file,
 | 
	
		
			
				|  |  | +                         const std::string& parameter,
 | 
	
		
			
				|  |  |                           GeneratorContext* generator_context,
 | 
	
		
			
				|  |  | -                         string* error) const {
 | 
	
		
			
				|  |  | -  return Generate(file, false, false, std::set<string>(),
 | 
	
		
			
				|  |  | +                         std::string* error) const {
 | 
	
		
			
				|  |  | +  return Generate(file, false, false, std::set<std::string>(),
 | 
	
		
			
				|  |  |                    generator_context, error);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  bool Generator::Generate(
 | 
	
		
			
				|  |  | -    const FileDescriptor* file,
 | 
	
		
			
				|  |  | -    bool is_descriptor,
 | 
	
		
			
				|  |  | -    bool aggregate_metadata,
 | 
	
		
			
				|  |  | -    const std::set<string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | -    GeneratorContext* generator_context,
 | 
	
		
			
				|  |  | -    string* error) const {
 | 
	
		
			
				|  |  | +    const FileDescriptor* file, bool is_descriptor, bool aggregate_metadata,
 | 
	
		
			
				|  |  | +    const std::set<std::string>& aggregate_metadata_prefixes,
 | 
	
		
			
				|  |  | +    GeneratorContext* generator_context, std::string* error) const {
 | 
	
		
			
				|  |  |    if (is_descriptor && file->name() != kDescriptorFile) {
 | 
	
		
			
				|  |  |      *error =
 | 
	
		
			
				|  |  |          "Can only generate PHP code for google/protobuf/descriptor.proto.\n";
 | 
	
	
		
			
				|  | @@ -1840,12 +1842,12 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
 | 
	
		
			
				|  |  |                              std::string* error) const {
 | 
	
		
			
				|  |  |    bool is_descriptor = false;
 | 
	
		
			
				|  |  |    bool aggregate_metadata = false;
 | 
	
		
			
				|  |  | -  std::set<string> aggregate_metadata_prefixes;
 | 
	
		
			
				|  |  | +  std::set<std::string> aggregate_metadata_prefixes;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    for (const auto& option : Split(parameter, ",", true)) {
 | 
	
		
			
				|  |  |      const std::vector<std::string> option_pair = Split(option, "=", true);
 | 
	
		
			
				|  |  |      if (HasPrefixString(option_pair[0], "aggregate_metadata")) {
 | 
	
		
			
				|  |  | -      string options_string = option_pair[1];
 | 
	
		
			
				|  |  | +      std::string options_string = option_pair[1];
 | 
	
		
			
				|  |  |        const std::vector<std::string> options =
 | 
	
		
			
				|  |  |            Split(options_string, "#", false);
 | 
	
		
			
				|  |  |        aggregate_metadata = true;
 |