123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
- #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__
- #include <string>
- #include <vector>
- #include <google/protobuf/stubs/common.h>
- #include <google/protobuf/generated_enum_reflection.h>
- #include <google/protobuf/message.h>
- #include <google/protobuf/unknown_field_set.h>
- namespace google {
- namespace upb {
- namespace google_opensource {
- class GMR_Handlers;
- }
- }
- namespace protobuf {
- class DescriptorPool;
- }
- namespace protobuf {
- namespace internal {
- class DefaultEmptyOneof;
- class GeneratedMessageReflection;
- class ExtensionSet;
- class LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {
- public:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GeneratedMessageReflection(const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- const DescriptorPool* pool,
- MessageFactory* factory,
- int object_size);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GeneratedMessageReflection(const Descriptor* descriptor,
- const Message* default_instance,
- const int offsets[],
- int has_bits_offset,
- int unknown_fields_offset,
- int extensions_offset,
- const void* default_oneof_instance,
- int oneof_case_offset,
- const DescriptorPool* pool,
- MessageFactory* factory,
- int object_size);
- ~GeneratedMessageReflection();
-
- const UnknownFieldSet& GetUnknownFields(const Message& message) const;
- UnknownFieldSet* MutableUnknownFields(Message* message) const;
- int SpaceUsed(const Message& message) const;
- bool HasField(const Message& message, const FieldDescriptor* field) const;
- int FieldSize(const Message& message, const FieldDescriptor* field) const;
- void ClearField(Message* message, const FieldDescriptor* field) const;
- bool HasOneof(const Message& message,
- const OneofDescriptor* oneof_descriptor) const;
- void ClearOneof(Message* message, const OneofDescriptor* field) const;
- void RemoveLast(Message* message, const FieldDescriptor* field) const;
- Message* ReleaseLast(Message* message, const FieldDescriptor* field) const;
- void Swap(Message* message1, Message* message2) const;
- void SwapFields(Message* message1, Message* message2,
- const vector<const FieldDescriptor*>& fields) const;
- void SwapElements(Message* message, const FieldDescriptor* field,
- int index1, int index2) const;
- void ListFields(const Message& message,
- vector<const FieldDescriptor*>* output) const;
- int32 GetInt32 (const Message& message,
- const FieldDescriptor* field) const;
- int64 GetInt64 (const Message& message,
- const FieldDescriptor* field) const;
- uint32 GetUInt32(const Message& message,
- const FieldDescriptor* field) const;
- uint64 GetUInt64(const Message& message,
- const FieldDescriptor* field) const;
- float GetFloat (const Message& message,
- const FieldDescriptor* field) const;
- double GetDouble(const Message& message,
- const FieldDescriptor* field) const;
- bool GetBool (const Message& message,
- const FieldDescriptor* field) const;
- string GetString(const Message& message,
- const FieldDescriptor* field) const;
- const string& GetStringReference(const Message& message,
- const FieldDescriptor* field,
- string* scratch) const;
- const EnumValueDescriptor* GetEnum(const Message& message,
- const FieldDescriptor* field) const;
- const Message& GetMessage(const Message& message,
- const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
- const FieldDescriptor* GetOneofFieldDescriptor(
- const Message& message,
- const OneofDescriptor* oneof_descriptor) const;
- public:
- void SetInt32 (Message* message,
- const FieldDescriptor* field, int32 value) const;
- void SetInt64 (Message* message,
- const FieldDescriptor* field, int64 value) const;
- void SetUInt32(Message* message,
- const FieldDescriptor* field, uint32 value) const;
- void SetUInt64(Message* message,
- const FieldDescriptor* field, uint64 value) const;
- void SetFloat (Message* message,
- const FieldDescriptor* field, float value) const;
- void SetDouble(Message* message,
- const FieldDescriptor* field, double value) const;
- void SetBool (Message* message,
- const FieldDescriptor* field, bool value) const;
- void SetString(Message* message,
- const FieldDescriptor* field,
- const string& value) const;
- void SetEnum (Message* message, const FieldDescriptor* field,
- const EnumValueDescriptor* value) const;
- Message* MutableMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
- void SetAllocatedMessage(Message* message,
- Message* sub_message,
- const FieldDescriptor* field) const;
- Message* ReleaseMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
- int32 GetRepeatedInt32 (const Message& message,
- const FieldDescriptor* field, int index) const;
- int64 GetRepeatedInt64 (const Message& message,
- const FieldDescriptor* field, int index) const;
- uint32 GetRepeatedUInt32(const Message& message,
- const FieldDescriptor* field, int index) const;
- uint64 GetRepeatedUInt64(const Message& message,
- const FieldDescriptor* field, int index) const;
- float GetRepeatedFloat (const Message& message,
- const FieldDescriptor* field, int index) const;
- double GetRepeatedDouble(const Message& message,
- const FieldDescriptor* field, int index) const;
- bool GetRepeatedBool (const Message& message,
- const FieldDescriptor* field, int index) const;
- string GetRepeatedString(const Message& message,
- const FieldDescriptor* field, int index) const;
- const string& GetRepeatedStringReference(const Message& message,
- const FieldDescriptor* field,
- int index, string* scratch) const;
- const EnumValueDescriptor* GetRepeatedEnum(const Message& message,
- const FieldDescriptor* field,
- int index) const;
- const Message& GetRepeatedMessage(const Message& message,
- const FieldDescriptor* field,
- int index) const;
-
- void SetRepeatedInt32 (Message* message,
- const FieldDescriptor* field, int index, int32 value) const;
- void SetRepeatedInt64 (Message* message,
- const FieldDescriptor* field, int index, int64 value) const;
- void SetRepeatedUInt32(Message* message,
- const FieldDescriptor* field, int index, uint32 value) const;
- void SetRepeatedUInt64(Message* message,
- const FieldDescriptor* field, int index, uint64 value) const;
- void SetRepeatedFloat (Message* message,
- const FieldDescriptor* field, int index, float value) const;
- void SetRepeatedDouble(Message* message,
- const FieldDescriptor* field, int index, double value) const;
- void SetRepeatedBool (Message* message,
- const FieldDescriptor* field, int index, bool value) const;
- void SetRepeatedString(Message* message,
- const FieldDescriptor* field, int index,
- const string& value) const;
- void SetRepeatedEnum(Message* message, const FieldDescriptor* field,
- int index, const EnumValueDescriptor* value) const;
-
- Message* MutableRepeatedMessage(Message* message,
- const FieldDescriptor* field,
- int index) const;
- void AddInt32 (Message* message,
- const FieldDescriptor* field, int32 value) const;
- void AddInt64 (Message* message,
- const FieldDescriptor* field, int64 value) const;
- void AddUInt32(Message* message,
- const FieldDescriptor* field, uint32 value) const;
- void AddUInt64(Message* message,
- const FieldDescriptor* field, uint64 value) const;
- void AddFloat (Message* message,
- const FieldDescriptor* field, float value) const;
- void AddDouble(Message* message,
- const FieldDescriptor* field, double value) const;
- void AddBool (Message* message,
- const FieldDescriptor* field, bool value) const;
- void AddString(Message* message,
- const FieldDescriptor* field, const string& value) const;
- void AddEnum(Message* message,
- const FieldDescriptor* field,
- const EnumValueDescriptor* value) const;
- Message* AddMessage(Message* message, const FieldDescriptor* field,
- MessageFactory* factory = NULL) const;
- const FieldDescriptor* FindKnownExtensionByName(const string& name) const;
- const FieldDescriptor* FindKnownExtensionByNumber(int number) const;
- protected:
- virtual void* MutableRawRepeatedField(
- Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,
- int ctype, const Descriptor* desc) const;
- private:
- friend class GeneratedMessage;
-
-
- friend class LIBPROTOBUF_EXPORT upb::google_opensource::GMR_Handlers;
- const Descriptor* descriptor_;
- const Message* default_instance_;
- const void* default_oneof_instance_;
- const int* offsets_;
- int has_bits_offset_;
- int oneof_case_offset_;
- int unknown_fields_offset_;
- int extensions_offset_;
- int object_size_;
- const DescriptorPool* descriptor_pool_;
- MessageFactory* message_factory_;
- template <typename Type>
- inline const Type& GetRaw(const Message& message,
- const FieldDescriptor* field) const;
- template <typename Type>
- inline Type* MutableRaw(Message* message,
- const FieldDescriptor* field) const;
- template <typename Type>
- inline const Type& DefaultRaw(const FieldDescriptor* field) const;
- template <typename Type>
- inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const;
- inline const uint32* GetHasBits(const Message& message) const;
- inline uint32* MutableHasBits(Message* message) const;
- inline uint32 GetOneofCase(
- const Message& message,
- const OneofDescriptor* oneof_descriptor) const;
- inline uint32* MutableOneofCase(
- Message* message,
- const OneofDescriptor* oneof_descriptor) const;
- inline const ExtensionSet& GetExtensionSet(const Message& message) const;
- inline ExtensionSet* MutableExtensionSet(Message* message) const;
- inline bool HasBit(const Message& message,
- const FieldDescriptor* field) const;
- inline void SetBit(Message* message,
- const FieldDescriptor* field) const;
- inline void ClearBit(Message* message,
- const FieldDescriptor* field) const;
- inline void SwapBit(Message* message1,
- Message* message2,
- const FieldDescriptor* field) const;
-
-
- void SwapField(Message* message1,
- Message* message2,
- const FieldDescriptor* field) const;
- void SwapOneofField(Message* message1,
- Message* message2,
- const OneofDescriptor* oneof_descriptor) const;
- inline bool HasOneofField(const Message& message,
- const FieldDescriptor* field) const;
- inline void SetOneofCase(Message* message,
- const FieldDescriptor* field) const;
- inline void ClearOneofField(Message* message,
- const FieldDescriptor* field) const;
- template <typename Type>
- inline const Type& GetField(const Message& message,
- const FieldDescriptor* field) const;
- template <typename Type>
- inline void SetField(Message* message,
- const FieldDescriptor* field, const Type& value) const;
- template <typename Type>
- inline Type* MutableField(Message* message,
- const FieldDescriptor* field) const;
- template <typename Type>
- inline const Type& GetRepeatedField(const Message& message,
- const FieldDescriptor* field,
- int index) const;
- template <typename Type>
- inline const Type& GetRepeatedPtrField(const Message& message,
- const FieldDescriptor* field,
- int index) const;
- template <typename Type>
- inline void SetRepeatedField(Message* message,
- const FieldDescriptor* field, int index,
- Type value) const;
- template <typename Type>
- inline Type* MutableRepeatedField(Message* message,
- const FieldDescriptor* field,
- int index) const;
- template <typename Type>
- inline void AddField(Message* message,
- const FieldDescriptor* field, const Type& value) const;
- template <typename Type>
- inline Type* AddField(Message* message,
- const FieldDescriptor* field) const;
- int GetExtensionNumberOrDie(const Descriptor* type) const;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);
- };
- #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD) \
- static_cast<int>( \
- reinterpret_cast<const char*>( \
- &reinterpret_cast<const TYPE*>(16)->FIELD) - \
- reinterpret_cast<const char*>(16))
- #define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD) \
- static_cast<int>( \
- reinterpret_cast<const char*>(&(ONEOF->FIELD)) \
- - reinterpret_cast<const char*>(ONEOF))
- template<typename To, typename From>
- inline To dynamic_cast_if_available(From from) {
- #if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
- return NULL;
- #else
- return dynamic_cast<To>(from);
- #endif
- }
- }
- }
- }
- #endif
|