diff options
Diffstat (limited to 'src/google/protobuf/arenastring.h')
-rwxr-xr-x | src/google/protobuf/arenastring.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index c9d045a1..fb1b64a3 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -51,6 +51,18 @@ namespace google { namespace protobuf { namespace internal { +template <typename T> +class TaggedPtr { + public: + void Set(T* p) { ptr_ = reinterpret_cast<uintptr_t>(p); } + T* Get() const { return reinterpret_cast<T*>(ptr_); } + + bool IsNull() { return ptr_ == 0; } + + private: + uintptr_t ptr_; +}; + struct LIBPROTOBUF_EXPORT ArenaStringPtr { inline void Set(const ::std::string* default_value, const ::std::string& value, ::google::protobuf::Arena* arena) { @@ -294,6 +306,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { return ptr_ == default_value; } + // Internal accessors!!!! + void UnsafeSetTaggedPointer(TaggedPtr< ::std::string> value) { + ptr_ = value.Get(); + } + // Generated code only! An optimization, in certain cases the generated + // code is certain we can obtain a string with no default checks and + // tag tests. + ::std::string* UnsafeMutablePointer() { return ptr_; } + private: ::std::string* ptr_; |