| 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 17 matching lines...) Expand all Loading... |
| 31 // Author: kenton@google.com (Kenton Varda) | 31 // Author: kenton@google.com (Kenton Varda) |
| 32 // Based on original Protocol Buffers design by | 32 // Based on original Protocol Buffers design by |
| 33 // Sanjay Ghemawat, Jeff Dean, and others. | 33 // Sanjay Ghemawat, Jeff Dean, and others. |
| 34 // | 34 // |
| 35 // Defines an implementation of Message which can emulate types which are not | 35 // Defines an implementation of Message which can emulate types which are not |
| 36 // known at compile-time. | 36 // known at compile-time. |
| 37 | 37 |
| 38 #ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ | 38 #ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ |
| 39 #define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ | 39 #define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ |
| 40 | 40 |
| 41 #include <memory> |
| 42 #ifndef _SHARED_PTR_H |
| 43 #include <google/protobuf/stubs/shared_ptr.h> |
| 44 #endif |
| 45 |
| 41 #include <google/protobuf/message.h> | 46 #include <google/protobuf/message.h> |
| 42 #include <google/protobuf/stubs/common.h> | 47 #include <google/protobuf/stubs/common.h> |
| 48 #include <google/protobuf/stubs/mutex.h> |
| 43 | 49 |
| 44 namespace google { | 50 namespace google { |
| 45 namespace protobuf { | 51 namespace protobuf { |
| 46 | 52 |
| 47 // Defined in other files. | 53 // Defined in other files. |
| 48 class Descriptor; // descriptor.h | 54 class Descriptor; // descriptor.h |
| 49 class DescriptorPool; // descriptor.h | 55 class DescriptorPool; // descriptor.h |
| 50 | 56 |
| 51 // Constructs implementations of Message which can emulate types which are not | 57 // Constructs implementations of Message which can emulate types which are not |
| 52 // known at compile-time. | 58 // known at compile-time. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 private: | 120 private: |
| 115 const DescriptorPool* pool_; | 121 const DescriptorPool* pool_; |
| 116 bool delegate_to_generated_factory_; | 122 bool delegate_to_generated_factory_; |
| 117 | 123 |
| 118 // This struct just contains a hash_map. We can't #include <google/protobuf/s
tubs/hash.h> from | 124 // This struct just contains a hash_map. We can't #include <google/protobuf/s
tubs/hash.h> from |
| 119 // this header due to hacks needed for hash_map portability in the open source | 125 // this header due to hacks needed for hash_map portability in the open source |
| 120 // release. Namely, stubs/hash.h, which defines hash_map portably, is not a | 126 // release. Namely, stubs/hash.h, which defines hash_map portably, is not a |
| 121 // public header (for good reason), but dynamic_message.h is, and public | 127 // public header (for good reason), but dynamic_message.h is, and public |
| 122 // headers may only #include other public headers. | 128 // headers may only #include other public headers. |
| 123 struct PrototypeMap; | 129 struct PrototypeMap; |
| 124 scoped_ptr<PrototypeMap> prototypes_; | 130 google::protobuf::scoped_ptr<PrototypeMap> prototypes_; |
| 125 mutable Mutex prototypes_mutex_; | 131 mutable Mutex prototypes_mutex_; |
| 126 | 132 |
| 127 friend class DynamicMessage; | 133 friend class DynamicMessage; |
| 128 const Message* GetPrototypeNoLock(const Descriptor* type); | 134 const Message* GetPrototypeNoLock(const Descriptor* type); |
| 129 | 135 |
| 136 // Construct default oneof instance for reflection usage if oneof |
| 137 // is defined. |
| 138 static void ConstructDefaultOneofInstance(const Descriptor* type, |
| 139 const int offsets[], |
| 140 void* default_oneof_instance); |
| 141 // Delete default oneof instance. Called by ~DynamicMessageFactory. |
| 142 static void DeleteDefaultOneofInstance(const Descriptor* type, |
| 143 const int offsets[], |
| 144 void* default_oneof_instance); |
| 145 |
| 130 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); | 146 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory); |
| 131 }; | 147 }; |
| 132 | 148 |
| 133 } // namespace protobuf | 149 } // namespace protobuf |
| 134 | 150 |
| 135 } // namespace google | 151 } // namespace google |
| 136 #endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ | 152 #endif // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__ |
| OLD | NEW |