protobuf/src/google/protobuf/descriptor_database.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #include <google/protobuf/descriptor_database.h>
36 
37 #include <set>
38 
39 #include <google/protobuf/descriptor.pb.h>
40 #include <google/protobuf/stubs/map_util.h>
41 #include <google/protobuf/stubs/stl_util.h>
42 
43 
44 namespace google {
45 namespace protobuf {
46 
47 namespace {
48 void RecordMessageNames(const DescriptorProto& desc_proto,
49  const std::string& prefix,
50  std::set<std::string>* output) {
51  GOOGLE_CHECK(desc_proto.has_name());
52  std::string full_name = prefix.empty()
53  ? desc_proto.name()
54  : StrCat(prefix, ".", desc_proto.name());
55  output->insert(full_name);
56 
57  for (const auto& d : desc_proto.nested_type()) {
58  RecordMessageNames(d, full_name, output);
59  }
60 }
61 
62 void RecordMessageNames(const FileDescriptorProto& file_proto,
63  std::set<std::string>* output) {
64  for (const auto& d : file_proto.message_type()) {
65  RecordMessageNames(d, file_proto.package(), output);
66  }
67 }
68 
69 template <typename Fn>
70 bool ForAllFileProtos(DescriptorDatabase* db, Fn callback,
71  std::vector<std::string>* output) {
72  std::vector<std::string> file_names;
73  if (!db->FindAllFileNames(&file_names)) {
74  return false;
75  }
76  std::set<std::string> set;
77  FileDescriptorProto file_proto;
78  for (const auto& f : file_names) {
79  file_proto.Clear();
80  if (!db->FindFileByName(f, &file_proto)) {
81  GOOGLE_LOG(ERROR) << "File not found in database (unexpected): " << f;
82  return false;
83  }
84  callback(file_proto, &set);
85  }
86  output->insert(output->end(), set.begin(), set.end());
87  return true;
88 }
89 } // namespace
90 
92 
93 bool DescriptorDatabase::FindAllPackageNames(std::vector<std::string>* output) {
94  return ForAllFileProtos(
95  this,
96  [](const FileDescriptorProto& file_proto, std::set<std::string>* set) {
97  set->insert(file_proto.package());
98  },
99  output);
100 }
101 
102 bool DescriptorDatabase::FindAllMessageNames(std::vector<std::string>* output) {
103  return ForAllFileProtos(
104  this,
105  [](const FileDescriptorProto& file_proto, std::set<std::string>* set) {
106  RecordMessageNames(file_proto, set);
107  },
108  output);
109 }
110 
111 // ===================================================================
112 
115 
116 template <typename Value>
119  if (!InsertIfNotPresent(&by_name_, file.name(), value)) {
120  GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
121  return false;
122  }
123 
124  // We must be careful here -- calling file.package() if file.has_package() is
125  // false could access an uninitialized static-storage variable if we are being
126  // run at startup time.
127  std::string path = file.has_package() ? file.package() : std::string();
128  if (!path.empty()) path += '.';
129 
130  for (int i = 0; i < file.message_type_size(); i++) {
131  if (!AddSymbol(path + file.message_type(i).name(), value)) return false;
132  if (!AddNestedExtensions(file.name(), file.message_type(i), value))
133  return false;
134  }
135  for (int i = 0; i < file.enum_type_size(); i++) {
136  if (!AddSymbol(path + file.enum_type(i).name(), value)) return false;
137  }
138  for (int i = 0; i < file.extension_size(); i++) {
139  if (!AddSymbol(path + file.extension(i).name(), value)) return false;
140  if (!AddExtension(file.name(), file.extension(i), value)) return false;
141  }
142  for (int i = 0; i < file.service_size(); i++) {
143  if (!AddSymbol(path + file.service(i).name(), value)) return false;
144  }
145 
146  return true;
147 }
148 
149 namespace {
150 
151 // Returns true if and only if all characters in the name are alphanumerics,
152 // underscores, or periods.
153 bool ValidateSymbolName(StringPiece name) {
154  for (char c : name) {
155  // I don't trust ctype.h due to locales. :(
156  if (c != '.' && c != '_' && (c < '0' || c > '9') && (c < 'A' || c > 'Z') &&
157  (c < 'a' || c > 'z')) {
158  return false;
159  }
160  }
161  return true;
162 }
163 
164 // Find the last key in the container which sorts less than or equal to the
165 // symbol name. Since upper_bound() returns the *first* key that sorts
166 // *greater* than the input, we want the element immediately before that.
167 template <typename Container, typename Key>
168 typename Container::const_iterator FindLastLessOrEqual(
169  const Container* container, const Key& key) {
170  auto iter = container->upper_bound(key);
171  if (iter != container->begin()) --iter;
172  return iter;
173 }
174 
175 // As above, but using std::upper_bound instead.
176 template <typename Container, typename Key, typename Cmp>
177 typename Container::const_iterator FindLastLessOrEqual(
178  const Container* container, const Key& key, const Cmp& cmp) {
179  auto iter = std::upper_bound(container->begin(), container->end(), key, cmp);
180  if (iter != container->begin()) --iter;
181  return iter;
182 }
183 
184 // True if either the arguments are equal or super_symbol identifies a
185 // parent symbol of sub_symbol (e.g. "foo.bar" is a parent of
186 // "foo.bar.baz", but not a parent of "foo.barbaz").
187 bool IsSubSymbol(StringPiece sub_symbol, StringPiece super_symbol) {
188  return sub_symbol == super_symbol ||
189  (HasPrefixString(super_symbol, sub_symbol) &&
190  super_symbol[sub_symbol.size()] == '.');
191 }
192 
193 } // namespace
194 
195 template <typename Value>
197  const std::string& name, Value value) {
198  // We need to make sure not to violate our map invariant.
199 
200  // If the symbol name is invalid it could break our lookup algorithm (which
201  // relies on the fact that '.' sorts before all other characters that are
202  // valid in symbol names).
203  if (!ValidateSymbolName(name)) {
204  GOOGLE_LOG(ERROR) << "Invalid symbol name: " << name;
205  return false;
206  }
207 
208  // Try to look up the symbol to make sure a super-symbol doesn't already
209  // exist.
210  auto iter = FindLastLessOrEqual(&by_symbol_, name);
211 
212  if (iter == by_symbol_.end()) {
213  // Apparently the map is currently empty. Just insert and be done with it.
214  by_symbol_.insert(
216  return true;
217  }
218 
219  if (IsSubSymbol(iter->first, name)) {
220  GOOGLE_LOG(ERROR) << "Symbol name \"" << name
221  << "\" conflicts with the existing "
222  "symbol \""
223  << iter->first << "\".";
224  return false;
225  }
226 
227  // OK, that worked. Now we have to make sure that no symbol in the map is
228  // a sub-symbol of the one we are inserting. The only symbol which could
229  // be so is the first symbol that is greater than the new symbol. Since
230  // |iter| points at the last symbol that is less than or equal, we just have
231  // to increment it.
232  ++iter;
233 
234  if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) {
235  GOOGLE_LOG(ERROR) << "Symbol name \"" << name
236  << "\" conflicts with the existing "
237  "symbol \""
238  << iter->first << "\".";
239  return false;
240  }
241 
242  // OK, no conflicts.
243 
244  // Insert the new symbol using the iterator as a hint, the new entry will
245  // appear immediately before the one the iterator is pointing at.
246  by_symbol_.insert(
248 
249  return true;
250 }
251 
252 template <typename Value>
255  Value value) {
256  for (int i = 0; i < message_type.nested_type_size(); i++) {
257  if (!AddNestedExtensions(filename, message_type.nested_type(i), value))
258  return false;
259  }
260  for (int i = 0; i < message_type.extension_size(); i++) {
261  if (!AddExtension(filename, message_type.extension(i), value)) return false;
262  }
263  return true;
264 }
265 
266 template <typename Value>
269  Value value) {
270  if (!field.extendee().empty() && field.extendee()[0] == '.') {
271  // The extension is fully-qualified. We can use it as a lookup key in
272  // the by_symbol_ table.
273  if (!InsertIfNotPresent(
274  &by_extension_,
275  std::make_pair(field.extendee().substr(1), field.number()),
276  value)) {
277  GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
278  "extend "
279  << field.extendee() << " { " << field.name() << " = "
280  << field.number() << " } from:" << filename;
281  return false;
282  }
283  } else {
284  // Not fully-qualified. We can't really do anything here, unfortunately.
285  // We don't consider this an error, though, because the descriptor is
286  // valid.
287  }
288  return true;
289 }
290 
291 template <typename Value>
293  const std::string& filename) {
294  return FindWithDefault(by_name_, filename, Value());
295 }
296 
297 template <typename Value>
299  const std::string& name) {
300  auto iter = FindLastLessOrEqual(&by_symbol_, name);
301 
302  return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name))
303  ? iter->second
304  : Value();
305 }
306 
307 template <typename Value>
309  const std::string& containing_type, int field_number) {
310  return FindWithDefault(
311  by_extension_, std::make_pair(containing_type, field_number), Value());
312 }
313 
314 template <typename Value>
316  const std::string& containing_type, std::vector<int>* output) {
317  typename std::map<std::pair<std::string, int>, Value>::const_iterator it =
318  by_extension_.lower_bound(std::make_pair(containing_type, 0));
319  bool success = false;
320 
321  for (; it != by_extension_.end() && it->first.first == containing_type;
322  ++it) {
323  output->push_back(it->first.second);
324  success = true;
325  }
326 
327  return success;
328 }
329 
330 template <typename Value>
332  std::vector<std::string>* output) {
333  output->resize(by_name_.size());
334  int i = 0;
335  for (const auto& kv : by_name_) {
336  (*output)[i] = kv.first;
337  i++;
338  }
339 }
340 
341 // -------------------------------------------------------------------
342 
345  new_file->CopyFrom(file);
346  return AddAndOwn(new_file);
347 }
348 
350  files_to_delete_.emplace_back(file);
351  return index_.AddFile(*file, file);
352 }
353 
357 }
358 
360  const std::string& symbol_name, FileDescriptorProto* output) {
361  return MaybeCopy(index_.FindSymbol(symbol_name), output);
362 }
363 
365  const std::string& containing_type, int field_number,
367  return MaybeCopy(index_.FindExtension(containing_type, field_number), output);
368 }
369 
371  const std::string& extendee_type, std::vector<int>* output) {
372  return index_.FindAllExtensionNumbers(extendee_type, output);
373 }
374 
375 
377  std::vector<std::string>* output) {
379  return true;
380 }
381 
384  if (file == nullptr) return false;
385  output->CopyFrom(*file);
386  return true;
387 }
388 
389 // -------------------------------------------------------------------
390 
392  public:
393  using Value = std::pair<const void*, int>;
394  // Helpers to recursively add particular descriptors and all their contents
395  // to the index.
396  template <typename FileProto>
397  bool AddFile(const FileProto& file, Value value);
398 
402  Value FindExtension(StringPiece containing_type, int field_number);
404  std::vector<int>* output);
405  void FindAllFileNames(std::vector<std::string>* output) const;
406 
407  private:
409 
410  bool AddSymbol(StringPiece symbol);
411 
412  template <typename DescProto>
414  const DescProto& message_type);
415  template <typename FieldProto>
416  bool AddExtension(StringPiece filename, const FieldProto& field);
417 
418  // All the maps below have two representations:
419  // - a std::set<> where we insert initially.
420  // - a std::vector<> where we flatten the structure on demand.
421  // The initial tree helps avoid O(N) behavior of inserting into a sorted
422  // vector, while the vector reduces the heap requirements of the data
423  // structure.
424 
425  void EnsureFlat();
426 
428 
430  StringPiece DecodeString(const String& str, int) const { return str; }
431 
432  struct EncodedEntry {
433  // Do not use `Value` here to avoid the padding of that object.
434  const void* data;
435  int size;
436  // Keep the package here instead of each SymbolEntry to save space.
438 
439  Value value() const { return {data, size}; }
440  };
441  std::vector<EncodedEntry> all_values_;
442 
443  struct FileEntry {
446 
448  return index.DecodeString(encoded_name, data_offset);
449  }
450  };
451  struct FileCompare {
453 
454  bool operator()(const FileEntry& a, const FileEntry& b) const {
455  return a.name(index) < b.name(index);
456  }
457  bool operator()(const FileEntry& a, StringPiece b) const {
458  return a.name(index) < b;
459  }
460  bool operator()(StringPiece a, const FileEntry& b) const {
461  return a < b.name(index);
462  }
463  };
464  std::set<FileEntry, FileCompare> by_name_{FileCompare{*this}};
465  std::vector<FileEntry> by_name_flat_;
466 
467  struct SymbolEntry {
470 
472  return index.DecodeString(index.all_values_[data_offset].encoded_package,
473  data_offset);
474  }
476  return index.DecodeString(encoded_symbol, data_offset);
477  }
478 
480  auto p = package(index);
481  return StrCat(p, p.empty() ? "" : ".", symbol(index));
482  }
483  };
484 
485  struct SymbolCompare {
487 
488  std::string AsString(const SymbolEntry& entry) const {
489  return entry.AsString(index);
490  }
491  static StringPiece AsString(StringPiece str) { return str; }
492 
493  std::pair<StringPiece, StringPiece> GetParts(
494  const SymbolEntry& entry) const {
495  auto package = entry.package(index);
496  if (package.empty()) return {entry.symbol(index), StringPiece{}};
497  return {package, entry.symbol(index)};
498  }
499  std::pair<StringPiece, StringPiece> GetParts(
500  StringPiece str) const {
501  return {str, {}};
502  }
503 
504  template <typename T, typename U>
505  bool operator()(const T& lhs, const U& rhs) const {
506  auto lhs_parts = GetParts(lhs);
507  auto rhs_parts = GetParts(rhs);
508 
509  // Fast path to avoid making the whole string for common cases.
510  if (int res =
511  lhs_parts.first.substr(0, rhs_parts.first.size())
512  .compare(rhs_parts.first.substr(0, lhs_parts.first.size()))) {
513  // If the packages already differ, exit early.
514  return res < 0;
515  } else if (lhs_parts.first.size() == rhs_parts.first.size()) {
516  return lhs_parts.second < rhs_parts.second;
517  }
518  return AsString(lhs) < AsString(rhs);
519  }
520  };
521  std::set<SymbolEntry, SymbolCompare> by_symbol_{SymbolCompare{*this}};
522  std::vector<SymbolEntry> by_symbol_flat_;
523 
524  struct ExtensionEntry {
528  return index.DecodeString(encoded_extendee, data_offset).substr(1);
529  }
531  };
534 
535  bool operator()(const ExtensionEntry& a, const ExtensionEntry& b) const {
536  return std::make_tuple(a.extendee(index), a.extension_number) <
537  std::make_tuple(b.extendee(index), b.extension_number);
538  }
539  bool operator()(const ExtensionEntry& a,
540  std::tuple<StringPiece, int> b) const {
541  return std::make_tuple(a.extendee(index), a.extension_number) < b;
542  }
543  bool operator()(std::tuple<StringPiece, int> a,
544  const ExtensionEntry& b) const {
545  return a < std::make_tuple(b.extendee(index), b.extension_number);
546  }
547  };
548  std::set<ExtensionEntry, ExtensionCompare> by_extension_{
549  ExtensionCompare{*this}};
550  std::vector<ExtensionEntry> by_extension_flat_;
551 };
552 
553 bool EncodedDescriptorDatabase::Add(const void* encoded_file_descriptor,
554  int size) {
556  if (file.ParseFromArray(encoded_file_descriptor, size)) {
557  return index_->AddFile(file, std::make_pair(encoded_file_descriptor, size));
558  } else {
559  GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to "
560  "EncodedDescriptorDatabase::Add().";
561  return false;
562  }
563 }
564 
565 bool EncodedDescriptorDatabase::AddCopy(const void* encoded_file_descriptor,
566  int size) {
567  void* copy = operator new(size);
568  memcpy(copy, encoded_file_descriptor, size);
569  files_to_delete_.push_back(copy);
570  return Add(copy, size);
571 }
572 
576 }
577 
579  const std::string& symbol_name, FileDescriptorProto* output) {
580  return MaybeParse(index_->FindSymbol(symbol_name), output);
581 }
582 
584  const std::string& symbol_name, std::string* output) {
585  auto encoded_file = index_->FindSymbol(symbol_name);
586  if (encoded_file.first == nullptr) return false;
587 
588  // Optimization: The name should be the first field in the encoded message.
589  // Try to just read it directly.
590  io::CodedInputStream input(static_cast<const uint8_t*>(encoded_file.first),
591  encoded_file.second);
592 
596 
597  if (input.ReadTagNoLastTag() == kNameTag) {
598  // Success!
600  } else {
601  // Slow path. Parse whole message.
602  FileDescriptorProto file_proto;
603  if (!file_proto.ParseFromArray(encoded_file.first, encoded_file.second)) {
604  return false;
605  }
606  *output = file_proto.name();
607  return true;
608  }
609 }
610 
612  const std::string& containing_type, int field_number,
614  return MaybeParse(index_->FindExtension(containing_type, field_number),
615  output);
616 }
617 
619  const std::string& extendee_type, std::vector<int>* output) {
620  return index_->FindAllExtensionNumbers(extendee_type, output);
621 }
622 
623 template <typename FileProto>
625  Value value) {
626  // We push `value` into the array first. This is important because the AddXXX
627  // functions below will expect it to be there.
628  all_values_.push_back({value.first, value.second, {}});
629 
630  if (!ValidateSymbolName(file.package())) {
631  GOOGLE_LOG(ERROR) << "Invalid package name: " << file.package();
632  return false;
633  }
634  all_values_.back().encoded_package = EncodeString(file.package());
635 
636  if (!InsertIfNotPresent(
637  &by_name_, FileEntry{static_cast<int>(all_values_.size() - 1),
638  EncodeString(file.name())}) ||
639  std::binary_search(by_name_flat_.begin(), by_name_flat_.end(),
640  file.name(), by_name_.key_comp())) {
641  GOOGLE_LOG(ERROR) << "File already exists in database: " << file.name();
642  return false;
643  }
644 
645  for (const auto& message_type : file.message_type()) {
646  if (!AddSymbol(message_type.name())) return false;
647  if (!AddNestedExtensions(file.name(), message_type)) return false;
648  }
649  for (const auto& enum_type : file.enum_type()) {
650  if (!AddSymbol(enum_type.name())) return false;
651  }
652  for (const auto& extension : file.extension()) {
653  if (!AddSymbol(extension.name())) return false;
654  if (!AddExtension(file.name(), extension)) return false;
655  }
656  for (const auto& service : file.service()) {
657  if (!AddSymbol(service.name())) return false;
658  }
659 
660  return true;
661 }
662 
663 template <typename Iter, typename Iter2, typename Index>
664 static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter* iter,
665  Iter2 end, const Index& index) {
666  if (*iter != end) {
667  if (IsSubSymbol((*iter)->AsString(index), symbol_name)) {
668  GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
669  << "\" conflicts with the existing symbol \""
670  << (*iter)->AsString(index) << "\".";
671  return false;
672  }
673 
674  // OK, that worked. Now we have to make sure that no symbol in the map is
675  // a sub-symbol of the one we are inserting. The only symbol which could
676  // be so is the first symbol that is greater than the new symbol. Since
677  // |iter| points at the last symbol that is less than or equal, we just have
678  // to increment it.
679  ++*iter;
680 
681  if (*iter != end && IsSubSymbol(symbol_name, (*iter)->AsString(index))) {
682  GOOGLE_LOG(ERROR) << "Symbol name \"" << symbol_name
683  << "\" conflicts with the existing symbol \""
684  << (*iter)->AsString(index) << "\".";
685  return false;
686  }
687  }
688  return true;
689 }
690 
692  StringPiece symbol) {
693  SymbolEntry entry = {static_cast<int>(all_values_.size() - 1),
694  EncodeString(symbol)};
695  std::string entry_as_string = entry.AsString(*this);
696 
697  // We need to make sure not to violate our map invariant.
698 
699  // If the symbol name is invalid it could break our lookup algorithm (which
700  // relies on the fact that '.' sorts before all other characters that are
701  // valid in symbol names).
702  if (!ValidateSymbolName(symbol)) {
703  GOOGLE_LOG(ERROR) << "Invalid symbol name: " << entry_as_string;
704  return false;
705  }
706 
707  auto iter = FindLastLessOrEqual(&by_symbol_, entry);
708  if (!CheckForMutualSubsymbols(entry_as_string, &iter, by_symbol_.end(),
709  *this)) {
710  return false;
711  }
712 
713  // Same, but on by_symbol_flat_
714  auto flat_iter =
715  FindLastLessOrEqual(&by_symbol_flat_, entry, by_symbol_.key_comp());
716  if (!CheckForMutualSubsymbols(entry_as_string, &flat_iter,
717  by_symbol_flat_.end(), *this)) {
718  return false;
719  }
720 
721  // OK, no conflicts.
722 
723  // Insert the new symbol using the iterator as a hint, the new entry will
724  // appear immediately before the one the iterator is pointing at.
725  by_symbol_.insert(iter, entry);
726 
727  return true;
728 }
729 
730 template <typename DescProto>
732  StringPiece filename, const DescProto& message_type) {
733  for (const auto& nested_type : message_type.nested_type()) {
734  if (!AddNestedExtensions(filename, nested_type)) return false;
735  }
736  for (const auto& extension : message_type.extension()) {
737  if (!AddExtension(filename, extension)) return false;
738  }
739  return true;
740 }
741 
742 template <typename FieldProto>
744  StringPiece filename, const FieldProto& field) {
745  if (!field.extendee().empty() && field.extendee()[0] == '.') {
746  // The extension is fully-qualified. We can use it as a lookup key in
747  // the by_symbol_ table.
748  if (!InsertIfNotPresent(
749  &by_extension_,
750  ExtensionEntry{static_cast<int>(all_values_.size() - 1),
751  EncodeString(field.extendee()), field.number()}) ||
752  std::binary_search(
753  by_extension_flat_.begin(), by_extension_flat_.end(),
754  std::make_pair(field.extendee().substr(1), field.number()),
755  by_extension_.key_comp())) {
756  GOOGLE_LOG(ERROR) << "Extension conflicts with extension already in database: "
757  "extend "
758  << field.extendee() << " { " << field.name() << " = "
759  << field.number() << " } from:" << filename;
760  return false;
761  }
762  } else {
763  // Not fully-qualified. We can't really do anything here, unfortunately.
764  // We don't consider this an error, though, because the descriptor is
765  // valid.
766  }
767  return true;
768 }
769 
770 std::pair<const void*, int>
772  EnsureFlat();
773  return FindSymbolOnlyFlat(name);
774 }
775 
776 std::pair<const void*, int>
778  StringPiece name) const {
779  auto iter =
780  FindLastLessOrEqual(&by_symbol_flat_, name, by_symbol_.key_comp());
781 
782  return iter != by_symbol_flat_.end() &&
783  IsSubSymbol(iter->AsString(*this), name)
784  ? all_values_[iter->data_offset].value()
785  : Value();
786 }
787 
788 std::pair<const void*, int>
790  StringPiece containing_type, int field_number) {
791  EnsureFlat();
792 
793  auto it = std::lower_bound(
794  by_extension_flat_.begin(), by_extension_flat_.end(),
795  std::make_tuple(containing_type, field_number), by_extension_.key_comp());
796  return it == by_extension_flat_.end() ||
797  it->extendee(*this) != containing_type ||
798  it->extension_number != field_number
799  ? std::make_pair(nullptr, 0)
800  : all_values_[it->data_offset].value();
801 }
802 
803 template <typename T, typename Less>
804 static void MergeIntoFlat(std::set<T, Less>* s, std::vector<T>* flat) {
805  if (s->empty()) return;
806  std::vector<T> new_flat(s->size() + flat->size());
807  std::merge(s->begin(), s->end(), flat->begin(), flat->end(), &new_flat[0],
808  s->key_comp());
809  *flat = std::move(new_flat);
810  s->clear();
811 }
812 
814  all_values_.shrink_to_fit();
815  // Merge each of the sets into their flat counterpart.
819 }
820 
822  StringPiece containing_type, std::vector<int>* output) {
823  EnsureFlat();
824 
825  bool success = false;
826  auto it = std::lower_bound(
827  by_extension_flat_.begin(), by_extension_flat_.end(),
829  for (;
830  it != by_extension_flat_.end() && it->extendee(*this) == containing_type;
831  ++it) {
832  output->push_back(it->extension_number);
833  success = true;
834  }
835 
836  return success;
837 }
838 
840  std::vector<std::string>* output) const {
841  output->resize(by_name_.size() + by_name_flat_.size());
842  int i = 0;
843  for (const auto& entry : by_name_) {
844  (*output)[i] = std::string(entry.name(*this));
845  i++;
846  }
847  for (const auto& entry : by_name_flat_) {
848  (*output)[i] = std::string(entry.name(*this));
849  i++;
850  }
851 }
852 
853 std::pair<const void*, int>
856  EnsureFlat();
857 
858  auto it = std::lower_bound(by_name_flat_.begin(), by_name_flat_.end(),
859  filename, by_name_.key_comp());
860  return it == by_name_flat_.end() || it->name(*this) != filename
861  ? std::make_pair(nullptr, 0)
862  : all_values_[it->data_offset].value();
863 }
864 
865 
867  std::vector<std::string>* output) {
869  return true;
870 }
871 
873  std::pair<const void*, int> encoded_file, FileDescriptorProto* output) {
874  if (encoded_file.first == nullptr) return false;
875  return output->ParseFromArray(encoded_file.first, encoded_file.second);
876 }
877 
879  : index_(new DescriptorIndex()) {}
880 
882  for (void* p : files_to_delete_) {
883  operator delete(p);
884  }
885 }
886 
887 // ===================================================================
888 
890  : pool_(pool) {}
892 
895  const FileDescriptor* file = pool_.FindFileByName(filename);
896  if (file == nullptr) return false;
897  output->Clear();
898  file->CopyTo(output);
899  return true;
900 }
901 
903  const std::string& symbol_name, FileDescriptorProto* output) {
904  const FileDescriptor* file = pool_.FindFileContainingSymbol(symbol_name);
905  if (file == nullptr) return false;
906  output->Clear();
907  file->CopyTo(output);
908  return true;
909 }
910 
912  const std::string& containing_type, int field_number,
914  const Descriptor* extendee = pool_.FindMessageTypeByName(containing_type);
915  if (extendee == nullptr) return false;
916 
917  const FieldDescriptor* extension =
918  pool_.FindExtensionByNumber(extendee, field_number);
919  if (extension == nullptr) return false;
920 
921  output->Clear();
923  return true;
924 }
925 
927  const std::string& extendee_type, std::vector<int>* output) {
928  const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type);
929  if (extendee == nullptr) return false;
930 
931  std::vector<const FieldDescriptor*> extensions;
932  pool_.FindAllExtensions(extendee, &extensions);
933 
934  for (const FieldDescriptor* extension : extensions) {
935  output->push_back(extension->number());
936  }
937 
938  return true;
939 }
940 
941 // ===================================================================
942 
944  DescriptorDatabase* source1, DescriptorDatabase* source2) {
945  sources_.push_back(source1);
946  sources_.push_back(source2);
947 }
949  const std::vector<DescriptorDatabase*>& sources)
950  : sources_(sources) {}
952 
955  for (DescriptorDatabase* source : sources_) {
956  if (source->FindFileByName(filename, output)) {
957  return true;
958  }
959  }
960  return false;
961 }
962 
964  const std::string& symbol_name, FileDescriptorProto* output) {
965  for (size_t i = 0; i < sources_.size(); i++) {
966  if (sources_[i]->FindFileContainingSymbol(symbol_name, output)) {
967  // The symbol was found in source i. However, if one of the previous
968  // sources defines a file with the same name (which presumably doesn't
969  // contain the symbol, since it wasn't found in that source), then we
970  // must hide it from the caller.
972  for (size_t j = 0; j < i; j++) {
973  if (sources_[j]->FindFileByName(output->name(), &temp)) {
974  // Found conflicting file in a previous source.
975  return false;
976  }
977  }
978  return true;
979  }
980  }
981  return false;
982 }
983 
985  const std::string& containing_type, int field_number,
987  for (size_t i = 0; i < sources_.size(); i++) {
988  if (sources_[i]->FindFileContainingExtension(containing_type, field_number,
989  output)) {
990  // The symbol was found in source i. However, if one of the previous
991  // sources defines a file with the same name (which presumably doesn't
992  // contain the symbol, since it wasn't found in that source), then we
993  // must hide it from the caller.
995  for (size_t j = 0; j < i; j++) {
996  if (sources_[j]->FindFileByName(output->name(), &temp)) {
997  // Found conflicting file in a previous source.
998  return false;
999  }
1000  }
1001  return true;
1002  }
1003  }
1004  return false;
1005 }
1006 
1008  const std::string& extendee_type, std::vector<int>* output) {
1009  std::set<int> merged_results;
1010  std::vector<int> results;
1011  bool success = false;
1012 
1013  for (DescriptorDatabase* source : sources_) {
1014  if (source->FindAllExtensionNumbers(extendee_type, &results)) {
1015  std::copy(results.begin(), results.end(),
1016  std::insert_iterator<std::set<int> >(merged_results,
1017  merged_results.begin()));
1018  success = true;
1019  }
1020  results.clear();
1021  }
1022 
1023  std::copy(merged_results.begin(), merged_results.end(),
1024  std::insert_iterator<std::vector<int> >(*output, output->end()));
1025 
1026  return success;
1027 }
1028 
1029 
1030 } // namespace protobuf
1031 } // namespace google
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionCompare
Definition: protobuf/src/google/protobuf/descriptor_database.cc:532
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::AddFile
bool AddFile(const FileProto &file, Value value)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:624
FileDescriptorProto::name
const std::string & name() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:7321
xds_interop_client.str
str
Definition: xds_interop_client.py:487
google::protobuf::DescriptorPoolDatabase::DescriptorPoolDatabase
DescriptorPoolDatabase(const DescriptorPool &pool)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:472
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindExtension
Value FindExtension(StringPiece containing_type, int field_number)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:789
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare
Definition: protobuf/src/google/protobuf/descriptor_database.cc:485
fix_build_deps.temp
temp
Definition: fix_build_deps.py:488
regen-readme.it
it
Definition: regen-readme.py:15
google::protobuf::SimpleDescriptorDatabase::~SimpleDescriptorDatabase
~SimpleDescriptorDatabase() override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:114
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindAllFileNames
void FindAllFileNames(std::vector< std::string > *output) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:839
absl::str_format_internal::LengthMod::j
@ j
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodedEntry::value
Value value() const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:439
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers
bool FindAllExtensionNumbers(StringPiece containing_type, std::vector< int > *output)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:821
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::all_values_
std::vector< EncodedEntry > all_values_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:441
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_extension_flat_
std::vector< ExtensionEntry > by_extension_flat_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:550
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const std::string &containing_type, std::vector< int > *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:271
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::index
const DescriptorIndex & index
Definition: protobuf/src/google/protobuf/descriptor_database.cc:486
google::protobuf::extension
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2001
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EnsureFlat
void EnsureFlat()
Definition: protobuf/src/google/protobuf/descriptor_database.cc:813
google::protobuf::DescriptorPoolDatabase::FindFileContainingSymbol
bool FindFileContainingSymbol(const std::string &symbol_name, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:485
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionEntry
Definition: protobuf/src/google/protobuf/descriptor_database.cc:524
google::protobuf::EncodedDescriptorDatabase::MaybeParse
bool MaybeParse(std::pair< const void *, int > encoded_file, FileDescriptorProto *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:464
google::protobuf::DescriptorPoolDatabase::FindFileByName
bool FindFileByName(const std::string &filename, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:476
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileCompare
Definition: protobuf/src/google/protobuf/descriptor_database.cc:451
std::tr1::make_tuple
tuple make_tuple()
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:1619
google::protobuf::EncodedDescriptorDatabase::FindFileContainingSymbol
bool FindFileContainingSymbol(const std::string &symbol_name, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:413
google::protobuf::descriptor_unittest::AddExtension
FieldDescriptorProto * AddExtension(FileDescriptorProto *file, const std::string &extendee, const std::string &name, int number, FieldDescriptorProto::Label label, FieldDescriptorProto::Type type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_unittest.cc:119
phone_pb2.message_type
message_type
Definition: phone_pb2.py:200
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry::AsString
std::string AsString(const DescriptorIndex &index) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:479
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_symbol_
std::set< SymbolEntry, SymbolCompare > by_symbol_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:521
google::protobuf.internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED
@ WIRETYPE_LENGTH_DELIMITED
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:104
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileEntry::encoded_name
String encoded_name
Definition: protobuf/src/google/protobuf/descriptor_database.cc:445
FieldDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:1851
FileDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:128
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::SimpleDescriptorDatabase::FindFileContainingExtension
bool FindFileContainingExtension(const std::string &containing_type, int field_number, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:354
google::protobuf::EncodedDescriptorDatabase::FindFileContainingExtension
bool FindFileContainingExtension(const std::string &containing_type, int field_number, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:446
google::protobuf::EncodedDescriptorDatabase::~EncodedDescriptorDatabase
~EncodedDescriptorDatabase() override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:382
google::protobuf::SimpleDescriptorDatabase::MaybeCopy
bool MaybeCopy(const FileDescriptorProto *file, FileDescriptorProto *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:372
google::protobuf::EncodedDescriptorDatabase::EncodedDescriptorDatabase
EncodedDescriptorDatabase()
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:381
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
pool_
DescriptorPool pool_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:181
setup.name
name
Definition: setup.py:542
check_documentation.path
path
Definition: check_documentation.py:57
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
Value
Definition: bloaty/third_party/protobuf/src/google/protobuf/struct.pb.h:306
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionCompare::operator()
bool operator()(const ExtensionEntry &a, std::tuple< StringPiece, int > b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:539
google::protobuf::SimpleDescriptorDatabase::files_to_delete_
std::vector< std::unique_ptr< const FileDescriptorProto > > files_to_delete_
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:287
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileCompare::index
const DescriptorIndex & index
Definition: protobuf/src/google/protobuf/descriptor_database.cc:452
google::protobuf::StringPiece::substr
StringPiece substr(size_type pos, size_type n=npos) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc:261
env.new
def new
Definition: env.py:51
google::protobuf::EncodedDescriptorDatabase::Add
bool Add(const void *encoded_file_descriptor, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:388
FileDescriptorProto::kNameFieldNumber
@ kNameFieldNumber
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:641
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::DescriptorPoolDatabase::~DescriptorPoolDatabase
~DescriptorPoolDatabase() override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:474
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry::package
StringPiece package(const DescriptorIndex &index) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:471
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1482
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileEntry
Definition: protobuf/src/google/protobuf/descriptor_database.cc:443
google::protobuf::MergedDescriptorDatabase::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const std::string &extendee_type, std::vector< int > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:590
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::AsString
std::string AsString(const SymbolEntry &entry) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:488
google::protobuf::EncodedDescriptorDatabase::index_
SimpleDescriptorDatabase::DescriptorIndex< std::pair< const void *, int > > index_
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:336
google::protobuf.internal::WireFormatLite::MakeTag
constexpr static uint32 MakeTag(int field_number, WireType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:783
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::FindFile
Value FindFile(const std::string &filename)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:247
google::protobuf::EnumValueDescriptor::name
const std::string & name() const
gen_gtest_pred_impl.Iter
def Iter(n, format, sep='')
Definition: bloaty/third_party/googletest/googletest/scripts/gen_gtest_pred_impl.py:188
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::AddFile
bool AddFile(const FileDescriptorProto &file, Value value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:117
google::protobuf::EncodedDescriptorDatabase::FindNameOfFileContainingSymbol
bool FindNameOfFileContainingSymbol(const std::string &symbol_name, std::string *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:418
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::AddSymbol
bool AddSymbol(const std::string &name, Value value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:150
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
FileDescriptorProto::message_type
const PROTOBUF_NAMESPACE_ID::DescriptorProto & message_type(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:7685
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionEntry::extension_number
int extension_number
Definition: protobuf/src/google/protobuf/descriptor_database.cc:530
google::protobuf::EncodedDescriptorDatabase::FindFileByName
bool FindFileByName(const std::string &filename, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:408
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionCompare::operator()
bool operator()(std::tuple< StringPiece, int > a, const ExtensionEntry &b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:543
google::protobuf::MergedDescriptorDatabase::MergedDescriptorDatabase
MergedDescriptorDatabase(DescriptorDatabase *source1, DescriptorDatabase *source2)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:526
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry::data_offset
int data_offset
Definition: protobuf/src/google/protobuf/descriptor_database.cc:468
benchmarks.python.py_benchmark.results
list results
Definition: bloaty/third_party/protobuf/benchmarks/python/py_benchmark.py:145
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::String
std::string String
Definition: protobuf/src/google/protobuf/descriptor_database.cc:427
google::protobuf::StringPiece
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:180
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::FindExtension
Value FindExtension(const std::string &containing_type, int field_number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:264
google::protobuf.internal::WireFormatLite::ReadString
static bool ReadString(io::CodedInputStream *input, std::string *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:893
google::protobuf::EnumValueDescriptor::number
int number() const
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
google::protobuf::MergedDescriptorDatabase::FindFileByName
bool FindFileByName(const std::string &filename, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:536
google::protobuf::SimpleDescriptorDatabase::FindFileByName
bool FindFileByName(const std::string &filename, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:344
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionEntry::extendee
StringPiece extendee(const DescriptorIndex &index) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:527
absl::compare_internal::value_type
int8_t value_type
Definition: abseil-cpp/absl/types/compare.h:45
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodedEntry::encoded_package
String encoded_package
Definition: protobuf/src/google/protobuf/descriptor_database.cc:437
google::protobuf::FieldDescriptor::number
int number() const
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::FindAllFileNames
void FindAllFileNames(std::vector< std::string > *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:287
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::FindSymbol
Value FindSymbol(const std::string &name)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:253
grpc::protobuf::DescriptorDatabase
GRPC_CUSTOM_DESCRIPTORDATABASE DescriptorDatabase
Definition: include/grpcpp/impl/codegen/config_protobuf.h:83
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::GetParts
std::pair< StringPiece, StringPiece > GetParts(const SymbolEntry &entry) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:493
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileCompare::operator()
bool operator()(StringPiece a, const FileEntry &b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:460
conf.extensions
list extensions
Definition: doc/python/sphinx/conf.py:54
callback
static void callback(void *arg, int status, int timeouts, struct hostent *host)
Definition: acountry.c:224
phone_pb2.containing_type
containing_type
Definition: phone_pb2.py:199
tests.google.protobuf.internal.message_test.cmp
cmp
Definition: bloaty/third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py:61
FileDescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:501
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::AddExtension
bool AddExtension(const std::string &filename, const FieldDescriptorProto &field, Value value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:222
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
google::protobuf::DescriptorPoolDatabase::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const std::string &extendee_type, std::vector< int > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:509
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::operator()
bool operator()(const T &lhs, const U &rhs) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:505
FileDescriptorProto::Clear
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.cc:1753
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodeString
String EncodeString(StringPiece str) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:429
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindFile
Value FindFile(StringPiece filename)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:854
google::protobuf::HasPrefixString
bool HasPrefixString(const string &str, const string &prefix)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:115
google::protobuf::DescriptorDatabase::~DescriptorDatabase
virtual ~DescriptorDatabase()
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:91
google::protobuf::ERROR
static const LogLevel ERROR
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:70
google::protobuf::FileDescriptor::CopyTo
void CopyTo(FileDescriptorProto *proto) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:1990
google::protobuf::DescriptorDatabase::FindAllMessageNames
bool FindAllMessageNames(std::vector< std::string > *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:102
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::AddSymbol
bool AddSymbol(StringPiece symbol)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:691
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::Value
std::pair< const void *, int > Value
Definition: protobuf/src/google/protobuf/descriptor_database.cc:393
FileDescriptorProto::CopyFrom
void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message &from) final
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.cc:2218
gen_build_yaml.sources
sources
Definition: src/boringssl/gen_build_yaml.py:27
google::protobuf::DescriptorDatabase::FindAllPackageNames
bool FindAllPackageNames(std::vector< std::string > *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:93
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::AddExtension
bool AddExtension(StringPiece filename, const FieldProto &field)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:743
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_extension_
std::set< ExtensionEntry, ExtensionCompare > by_extension_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:548
key
const char * key
Definition: hpack_parser_table.cc:164
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::GetParts
std::pair< StringPiece, StringPiece > GetParts(StringPiece str) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:499
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_name_flat_
std::vector< FileEntry > by_name_flat_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:465
google::protobuf::SimpleDescriptorDatabase::FindFileContainingSymbol
bool FindFileContainingSymbol(const std::string &symbol_name, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:349
google::protobuf::FieldDescriptor::name
const std::string & name() const
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex
Definition: protobuf/src/google/protobuf/descriptor_database.cc:391
google::protobuf::SimpleDescriptorDatabase::AddAndOwn
bool AddAndOwn(const FileDescriptorProto *file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:339
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionCompare::index
const DescriptorIndex & index
Definition: protobuf/src/google/protobuf/descriptor_database.cc:533
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionEntry::data_offset
int data_offset
Definition: protobuf/src/google/protobuf/descriptor_database.cc:525
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
testing::Key
internal::KeyMatcher< M > Key(M inner_matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:9141
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindSymbolOnlyFlat
Value FindSymbolOnlyFlat(StringPiece name) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:777
google::protobuf::MergedDescriptorDatabase::FindFileContainingSymbol
bool FindFileContainingSymbol(const std::string &symbol_name, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:546
google::protobuf::SimpleDescriptorDatabase::FindAllFileNames
bool FindAllFileNames(std::vector< std::string > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:366
google::protobuf::EncodedDescriptorDatabase::AddCopy
bool AddCopy(const void *encoded_file_descriptor, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:400
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_symbol_flat_
std::vector< SymbolEntry > by_symbol_flat_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:522
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodedEntry
Definition: protobuf/src/google/protobuf/descriptor_database.cc:432
cpp.gmock_class.set
set
Definition: bloaty/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py:44
DescriptorProto
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:1312
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:153
google::protobuf::EncodedDescriptorDatabase::FindAllFileNames
bool FindAllFileNames(std::vector< std::string > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:458
google::protobuf::SimpleDescriptorDatabase::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const std::string &extendee_type, std::vector< int > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:360
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex::AddNestedExtensions
bool AddNestedExtensions(const std::string &filename, const DescriptorProto &message_type, Value value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:208
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileCompare::operator()
bool operator()(const FileEntry &a, StringPiece b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:457
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::by_name_
std::set< FileEntry, FileCompare > by_name_
Definition: protobuf/src/google/protobuf/descriptor_database.cc:464
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolCompare::AsString
static StringPiece AsString(StringPiece str)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:491
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodedEntry::data
const void * data
Definition: protobuf/src/google/protobuf/descriptor_database.cc:434
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::EncodedEntry::size
int size
Definition: protobuf/src/google/protobuf/descriptor_database.cc:435
pool
InternalDescriptorPool * pool
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionCompare::operator()
bool operator()(const ExtensionEntry &a, const ExtensionEntry &b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:535
grpc::protobuf::FileDescriptorProto
GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto
Definition: include/grpcpp/impl/codegen/config_protobuf.h:86
google::protobuf::DescriptorPoolDatabase::FindFileContainingExtension
bool FindFileContainingExtension(const std::string &containing_type, int field_number, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:494
google::protobuf::FindWithDefault
const Collection::value_type::second_type & FindWithDefault(const Collection &collection, const typename Collection::value_type::first_type &key, const typename Collection::value_type::second_type &value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/map_util.h:123
iter
Definition: test_winkernel.cpp:47
google::protobuf::CheckForMutualSubsymbols
static bool CheckForMutualSubsymbols(StringPiece symbol_name, Iter *iter, Iter2 end, const Index &index)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:664
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileEntry::data_offset
int data_offset
Definition: protobuf/src/google/protobuf/descriptor_database.cc:444
google::protobuf::MergeIntoFlat
static void MergeIntoFlat(std::set< T, Less > *s, std::vector< T > *flat)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:804
google::protobuf::DescriptorDatabase::DescriptorDatabase
DescriptorDatabase()
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:73
Value
struct Value Value
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:676
DescriptorProto::name
const std::string & name() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:8252
google::protobuf::SimpleDescriptorDatabase::index_
DescriptorIndex< const FileDescriptorProto * > index_
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:286
FileDescriptorProto::package
const std::string & package() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:7414
google::protobuf::python::descriptor::Index
static PyObject * Index(PyContainer *self, PyObject *item)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/descriptor_containers.cc:672
file::name
char * name
Definition: bloaty/third_party/zlib/examples/gzappend.c:176
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf::SimpleDescriptorDatabase::SimpleDescriptorDatabase
SimpleDescriptorDatabase()
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:113
generate-asm-lcov.merge
def merge(callgrind_files, srcs)
Definition: generate-asm-lcov.py:50
google::protobuf::EnumValueDescriptor::file
const FileDescriptor * file() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2115
DescriptorProto::has_name
bool has_name() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:8245
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileCompare::operator()
bool operator()(const FileEntry &a, const FileEntry &b) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:454
DescriptorPool
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:110
google::protobuf::EncodedDescriptorDatabase::files_to_delete_
std::vector< void * > files_to_delete_
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:337
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf::MergedDescriptorDatabase::FindFileContainingExtension
bool FindFileContainingExtension(const std::string &containing_type, int field_number, FileDescriptorProto *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:567
phone_pb2.enum_type
enum_type
Definition: phone_pb2.py:198
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry
Definition: protobuf/src/google/protobuf/descriptor_database.cc:467
Fn
void Fn()
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::AddNestedExtensions
bool AddNestedExtensions(StringPiece filename, const DescProto &message_type)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:731
google::protobuf::EncodedDescriptorDatabase
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.h:301
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry::encoded_symbol
String encoded_symbol
Definition: protobuf/src/google/protobuf/descriptor_database.cc:469
google::protobuf::InsertIfNotPresent
bool InsertIfNotPresent(Collection *const collection, const typename Collection::value_type &vt)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/map_util.h:321
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
DescriptorProto::nested_type
const PROTOBUF_NAMESPACE_ID::DescriptorProto & nested_type(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.pb.h:8433
container
static struct async_container * container
Definition: benchmark-million-async.c:33
google::protobuf::EncodedDescriptorDatabase::FindAllExtensionNumbers
bool FindAllExtensionNumbers(const std::string &extendee_type, std::vector< int > *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:453
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FindSymbol
Value FindSymbol(StringPiece name)
Definition: protobuf/src/google/protobuf/descriptor_database.cc:771
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::FileEntry::name
StringPiece name(const DescriptorIndex &index) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:447
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::SymbolEntry::symbol
StringPiece symbol(const DescriptorIndex &index) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:475
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::DecodeString
StringPiece DecodeString(const String &str, int) const
Definition: protobuf/src/google/protobuf/descriptor_database.cc:430
google::protobuf::EncodedDescriptorDatabase::DescriptorIndex::ExtensionEntry::encoded_extendee
String encoded_extendee
Definition: protobuf/src/google/protobuf/descriptor_database.cc:526
google::protobuf::MergedDescriptorDatabase::~MergedDescriptorDatabase
~MergedDescriptorDatabase() override
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:534
google::protobuf::SimpleDescriptorDatabase::Add
bool Add(const FileDescriptorProto &file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor_database.cc:333
google::protobuf::service
const Descriptor::ReservedRange const EnumDescriptor::ReservedRange service
Definition: protobuf/src/google/protobuf/descriptor.h:2177


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:14