// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <google/protobuf/arenastring.h> #include <cstddef> #include <google/protobuf/stubs/logging.h> #include <google/protobuf/stubs/common.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/stubs/mutex.h> #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/message_lite.h> #include <google/protobuf/parse_context.h> #include <google/protobuf/stubs/stl_util.h> // clang-format off #include <google/protobuf/port_def.inc> // clang-format on namespace google { namespace protobuf { namespace internal { namespace { // TaggedStringPtr::Flags uses the lower 2 bits as tags. // Enforce that allocated data aligns to at least 4 bytes, and that // the alignment of the global const string value does as well. // The alignment guaranteed by `new std::string` depends on both: // - new align = __STDCPP_DEFAULT_NEW_ALIGNMENT__ / max_align_t // - alignof(std::string) #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ constexpr size_t kNewAlign = …; #elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 constexpr size_t kNewAlign = alignof(::max_align_t); #else constexpr size_t kNewAlign = alignof(std::max_align_t); #endif constexpr size_t kStringAlign = …; static_assert …; static_assert …; } // namespace const std::string& LazyString::Init() const { … } namespace { #if defined(NDEBUG) || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL class ScopedCheckPtrInvariants { … }; #endif // NDEBUG || !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL // Creates a heap allocated std::string value. inline TaggedStringPtr CreateString(ConstStringParam value) { … } #if !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL // Creates an arena allocated std::string value. TaggedStringPtr CreateArenaString(Arena& arena, ConstStringParam s) { … } #endif // !GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL } // namespace void ArenaStringPtr::Set(ConstStringParam value, Arena* arena) { … } void ArenaStringPtr::Set(std::string&& value, Arena* arena) { … } std::string* ArenaStringPtr::Mutable(Arena* arena) { … } std::string* ArenaStringPtr::Mutable(const LazyString& default_value, Arena* arena) { … } std::string* ArenaStringPtr::MutableNoCopy(Arena* arena) { … } template <typename... Lazy> std::string* ArenaStringPtr::MutableSlow(::google::protobuf::Arena* arena, const Lazy&... lazy_default) { … } std::string* ArenaStringPtr::Release() { … } void ArenaStringPtr::SetAllocated(std::string* value, Arena* arena) { … } void ArenaStringPtr::Destroy() { … } void ArenaStringPtr::ClearToEmpty() { … } void ArenaStringPtr::ClearToDefault(const LazyString& default_value, ::google::protobuf::Arena* arena) { … } const char* EpsCopyInputStream::ReadArenaString(const char* ptr, ArenaStringPtr* s, Arena* arena) { … } } // namespace internal } // namespace protobuf } // namespace google #include <google/protobuf/port_undef.inc>