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 // http://code.google.com/p/protobuf/ | 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. |
11 // * Redistributions in binary form must reproduce the above | 11 // * Redistributions in binary form must reproduce the above |
12 // copyright notice, this list of conditions and the following disclaimer | 12 // copyright notice, this list of conditions and the following disclaimer |
13 // in the documentation and/or other materials provided with the | 13 // in the documentation and/or other materials provided with the |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Finds the tag numbers used by all known extensions of | 89 // Finds the tag numbers used by all known extensions of |
90 // extendee_type, and appends them to output in an undefined | 90 // extendee_type, and appends them to output in an undefined |
91 // order. This method is best-effort: it's not guaranteed that the | 91 // order. This method is best-effort: it's not guaranteed that the |
92 // database will find all extensions, and it's not guaranteed that | 92 // database will find all extensions, and it's not guaranteed that |
93 // FindFileContainingExtension will return true on all of the found | 93 // FindFileContainingExtension will return true on all of the found |
94 // numbers. Returns true if the search was successful, otherwise | 94 // numbers. Returns true if the search was successful, otherwise |
95 // returns false and leaves output unchanged. | 95 // returns false and leaves output unchanged. |
96 // | 96 // |
97 // This method has a default implementation that always returns | 97 // This method has a default implementation that always returns |
98 // false. | 98 // false. |
99 virtual bool FindAllExtensionNumbers(const string& extendee_type, | 99 virtual bool FindAllExtensionNumbers(const string& /* extendee_type */, |
100 vector<int>* output) { | 100 vector<int>* /* output */) { |
101 return false; | 101 return false; |
102 } | 102 } |
103 | 103 |
| 104 |
104 private: | 105 private: |
105 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase); | 106 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase); |
106 }; | 107 }; |
107 | 108 |
108 // A DescriptorDatabase into which you can insert files manually. | 109 // A DescriptorDatabase into which you can insert files manually. |
109 // | 110 // |
110 // FindFileContainingSymbol() is fully-implemented. When you add a file, its | 111 // FindFileContainingSymbol() is fully-implemented. When you add a file, its |
111 // symbols will be indexed for this purpose. Note that the implementation | 112 // symbols will be indexed for this purpose. Note that the implementation |
112 // may return false positives, but only if it isn't possible for the symbol | 113 // may return false positives, but only if it isn't possible for the symbol |
113 // to be defined in any other file. In particular, if a file defines a symbol | 114 // to be defined in any other file. In particular, if a file defines a symbol |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // true, otherwise return false. | 305 // true, otherwise return false. |
305 bool MaybeParse(pair<const void*, int> encoded_file, | 306 bool MaybeParse(pair<const void*, int> encoded_file, |
306 FileDescriptorProto* output); | 307 FileDescriptorProto* output); |
307 | 308 |
308 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase); | 309 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase); |
309 }; | 310 }; |
310 | 311 |
311 // A DescriptorDatabase that fetches files from a given pool. | 312 // A DescriptorDatabase that fetches files from a given pool. |
312 class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase { | 313 class LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase { |
313 public: | 314 public: |
314 DescriptorPoolDatabase(const DescriptorPool& pool); | 315 explicit DescriptorPoolDatabase(const DescriptorPool& pool); |
315 ~DescriptorPoolDatabase(); | 316 ~DescriptorPoolDatabase(); |
316 | 317 |
317 // implements DescriptorDatabase ----------------------------------- | 318 // implements DescriptorDatabase ----------------------------------- |
318 bool FindFileByName(const string& filename, | 319 bool FindFileByName(const string& filename, |
319 FileDescriptorProto* output); | 320 FileDescriptorProto* output); |
320 bool FindFileContainingSymbol(const string& symbol_name, | 321 bool FindFileContainingSymbol(const string& symbol_name, |
321 FileDescriptorProto* output); | 322 FileDescriptorProto* output); |
322 bool FindFileContainingExtension(const string& containing_type, | 323 bool FindFileContainingExtension(const string& containing_type, |
323 int field_number, | 324 int field_number, |
324 FileDescriptorProto* output); | 325 FileDescriptorProto* output); |
325 bool FindAllExtensionNumbers(const string& extendee_type, | 326 bool FindAllExtensionNumbers(const string& extendee_type, |
326 vector<int>* output); | 327 vector<int>* output); |
327 | 328 |
328 private: | 329 private: |
329 const DescriptorPool& pool_; | 330 const DescriptorPool& pool_; |
330 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase); | 331 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase); |
331 }; | 332 }; |
332 | 333 |
333 // A DescriptorDatabase that wraps two or more others. It first searches the | 334 // A DescriptorDatabase that wraps two or more others. It first searches the |
334 // first database and, if that fails, tries the second, and so on. | 335 // first database and, if that fails, tries the second, and so on. |
335 class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { | 336 class LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase { |
336 public: | 337 public: |
337 // Merge just two databases. The sources remain property of the caller. | 338 // Merge just two databases. The sources remain property of the caller. |
338 MergedDescriptorDatabase(DescriptorDatabase* source1, | 339 MergedDescriptorDatabase(DescriptorDatabase* source1, |
339 DescriptorDatabase* source2); | 340 DescriptorDatabase* source2); |
340 // Merge more than two databases. The sources remain property of the caller. | 341 // Merge more than two databases. The sources remain property of the caller. |
341 // The vector may be deleted after the constructor returns but the | 342 // The vector may be deleted after the constructor returns but the |
342 // DescriptorDatabases need to stick around. | 343 // DescriptorDatabases need to stick around. |
343 MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources); | 344 explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources); |
344 ~MergedDescriptorDatabase(); | 345 ~MergedDescriptorDatabase(); |
345 | 346 |
346 // implements DescriptorDatabase ----------------------------------- | 347 // implements DescriptorDatabase ----------------------------------- |
347 bool FindFileByName(const string& filename, | 348 bool FindFileByName(const string& filename, |
348 FileDescriptorProto* output); | 349 FileDescriptorProto* output); |
349 bool FindFileContainingSymbol(const string& symbol_name, | 350 bool FindFileContainingSymbol(const string& symbol_name, |
350 FileDescriptorProto* output); | 351 FileDescriptorProto* output); |
351 bool FindFileContainingExtension(const string& containing_type, | 352 bool FindFileContainingExtension(const string& containing_type, |
352 int field_number, | 353 int field_number, |
353 FileDescriptorProto* output); | 354 FileDescriptorProto* output); |
354 // Merges the results of calling all databases. Returns true iff any | 355 // Merges the results of calling all databases. Returns true iff any |
355 // of the databases returned true. | 356 // of the databases returned true. |
356 bool FindAllExtensionNumbers(const string& extendee_type, | 357 bool FindAllExtensionNumbers(const string& extendee_type, |
357 vector<int>* output); | 358 vector<int>* output); |
358 | 359 |
| 360 |
359 private: | 361 private: |
360 vector<DescriptorDatabase*> sources_; | 362 vector<DescriptorDatabase*> sources_; |
361 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); | 363 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase); |
362 }; | 364 }; |
363 | 365 |
364 } // namespace protobuf | 366 } // namespace protobuf |
365 | 367 |
366 } // namespace google | 368 } // namespace google |
367 #endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ | 369 #endif // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__ |
OLD | NEW |