OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include <google/protobuf/util/type_resolver_util.h> | 48 #include <google/protobuf/util/type_resolver_util.h> |
49 | 49 |
50 namespace google { | 50 namespace google { |
51 namespace protobuf { | 51 namespace protobuf { |
52 namespace util { | 52 namespace util { |
53 namespace converter { | 53 namespace converter { |
54 namespace testing { | 54 namespace testing { |
55 | 55 |
56 | 56 |
57 void TypeInfoTestHelper::ResetTypeInfo( | 57 void TypeInfoTestHelper::ResetTypeInfo( |
58 const std::vector<const Descriptor*>& descriptors) { | 58 const vector<const Descriptor*>& descriptors) { |
59 switch (type_) { | 59 switch (type_) { |
60 case USE_TYPE_RESOLVER: { | 60 case USE_TYPE_RESOLVER: { |
61 const DescriptorPool* pool = descriptors[0]->file()->pool(); | 61 const DescriptorPool* pool = descriptors[0]->file()->pool(); |
62 for (int i = 1; i < descriptors.size(); ++i) { | 62 for (int i = 1; i < descriptors.size(); ++i) { |
63 GOOGLE_CHECK(pool == descriptors[i]->file()->pool()) | 63 GOOGLE_CHECK(pool == descriptors[i]->file()->pool()) |
64 << "Descriptors from different pools are not supported."; | 64 << "Descriptors from different pools are not supported."; |
65 } | 65 } |
66 type_resolver_.reset( | 66 type_resolver_.reset( |
67 NewTypeResolverForDescriptorPool(kTypeServiceBaseUrl, pool)); | 67 NewTypeResolverForDescriptorPool(kTypeServiceBaseUrl, pool)); |
68 typeinfo_.reset(TypeInfo::NewTypeInfo(type_resolver_.get())); | 68 typeinfo_.reset(TypeInfo::NewTypeInfo(type_resolver_.get())); |
69 return; | 69 return; |
70 } | 70 } |
71 } | 71 } |
72 GOOGLE_LOG(FATAL) << "Can not reach here."; | 72 GOOGLE_LOG(FATAL) << "Can not reach here."; |
73 } | 73 } |
74 | 74 |
75 void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) { | 75 void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) { |
76 std::vector<const Descriptor*> descriptors; | 76 vector<const Descriptor*> descriptors; |
77 descriptors.push_back(descriptor); | 77 descriptors.push_back(descriptor); |
78 ResetTypeInfo(descriptors); | 78 ResetTypeInfo(descriptors); |
79 } | 79 } |
80 | 80 |
81 void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1, | 81 void TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1, |
82 const Descriptor* descriptor2) { | 82 const Descriptor* descriptor2) { |
83 std::vector<const Descriptor*> descriptors; | 83 vector<const Descriptor*> descriptors; |
84 descriptors.push_back(descriptor1); | 84 descriptors.push_back(descriptor1); |
85 descriptors.push_back(descriptor2); | 85 descriptors.push_back(descriptor2); |
86 ResetTypeInfo(descriptors); | 86 ResetTypeInfo(descriptors); |
87 } | 87 } |
88 | 88 |
89 TypeInfo* TypeInfoTestHelper::GetTypeInfo() { return typeinfo_.get(); } | 89 TypeInfo* TypeInfoTestHelper::GetTypeInfo() { return typeinfo_.get(); } |
90 | 90 |
91 ProtoStreamObjectSource* TypeInfoTestHelper::NewProtoSource( | 91 ProtoStreamObjectSource* TypeInfoTestHelper::NewProtoSource( |
92 io::CodedInputStream* coded_input, const string& type_url) { | 92 io::CodedInputStream* coded_input, const string& type_url) { |
93 const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(type_url); | 93 const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(type_url); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 GOOGLE_LOG(FATAL) << "Can not reach here."; | 126 GOOGLE_LOG(FATAL) << "Can not reach here."; |
127 return NULL; | 127 return NULL; |
128 } | 128 } |
129 | 129 |
130 } // namespace testing | 130 } // namespace testing |
131 } // namespace converter | 131 } // namespace converter |
132 } // namespace util | 132 } // namespace util |
133 } // namespace protobuf | 133 } // namespace protobuf |
134 } // namespace google | 134 } // namespace google |
OLD | NEW |