inlined_string_field.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <google/protobuf/inlined_string_field.h>
32 
33 #include <google/protobuf/parse_context.h>
34 #include <google/protobuf/arena.h>
35 #include <google/protobuf/arenastring.h>
36 #include <google/protobuf/generated_message_util.h>
37 #include <google/protobuf/message_lite.h>
38 
39 // clang-format off
40 #include <google/protobuf/port_def.inc>
41 // clang-format on
42 
43 namespace google {
44 namespace protobuf {
45 namespace internal {
46 
47 
49  Arena* arena, bool donated,
50  uint32_t* donating_states,
51  uint32_t mask) {
52  if (arena == nullptr || !donated) {
53  return UnsafeMutablePointer();
54  }
55  return MutableSlow(arena, donated, donating_states, mask);
56 }
57 
59  Arena* arena, bool donated,
60  uint32_t* donating_states,
61  uint32_t mask) {
62  if (arena == nullptr || !donated) {
63  return UnsafeMutablePointer();
64  }
65  return MutableSlow(arena, donated, donating_states, mask);
66 }
67 
69  bool donated,
70  uint32_t* donating_states,
71  uint32_t mask) {
72  return UnsafeMutablePointer();
73 }
74 
77  bool donated, uint32_t* donating_states,
78  uint32_t mask) {
79  SetAllocatedNoArena(default_value, value);
80 }
81 
82 void InlinedStringField::Set(const std::string* default_value,
83  std::string&& value, Arena* arena, bool donated,
84  uint32_t* donating_states, uint32_t mask) {
85  SetNoArena(default_value, std::move(value));
86 }
87 
89  Arena* arena, bool donated) {
90  if (arena == nullptr && !donated) {
91  return ReleaseNonDefaultNoArena(default_value);
92  }
93  return ReleaseNonDefault(default_value, arena);
94 }
95 
97  const std::string* default_value, Arena* arena) {
98  return ReleaseNonDefaultNoArena(default_value);
99 }
100 
102  Arena* arena, bool donated) {
103  (void)arena;
104  get_mutable()->assign(default_value.get());
105 }
106 
107 
108 } // namespace internal
109 } // namespace protobuf
110 } // namespace google
google::protobuf.internal::InlinedStringField::UnsafeMutablePointer
std::string * UnsafeMutablePointer()
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:231
Arena
struct Arena Arena
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/arena.h:189
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf.internal::InlinedStringField::Set
void Set(const std::string *default_value, StringPiece value, Arena *) PROTOBUF_ALWAYS_INLINE
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:118
google::protobuf.internal::InlinedStringField::Release
std::string * Release(const std::string *default_value, Arena *)
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:106
Arena
Definition: arena.c:39
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
google::protobuf.internal::LazyString
Definition: protobuf/src/google/protobuf/arenastring.h:61
google::protobuf.internal::InlinedStringField::Mutable
std::string * Mutable(const std::string *default_value, Arena *) PROTOBUF_ALWAYS_INLINE
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:99
google::protobuf.internal::InlinedStringField::SetNoArena
void SetNoArena(const std::string *default_value, StringPiece value) PROTOBUF_ALWAYS_INLINE
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:212
google::protobuf.internal::InlinedStringField::ClearToDefault
void ClearToDefault(const std::string *default_value, Arena *) PROTOBUF_ALWAYS_INLINE
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:83
google::protobuf.internal::InlinedStringField::MutableSlow
std::string * MutableSlow(::google::protobuf::Arena *arena, bool donated, uint32_t *donating_states, uint32_t mask)
Definition: inlined_string_field.cc:68
google::protobuf.internal::InlinedStringField::SetAllocated
void SetAllocated(const std::string *default_value, std::string *value, Arena *)
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:142
google::protobuf.internal::InlinedStringField::get_mutable
PROTOBUF_NDEBUG_INLINE std::string * get_mutable()
Definition: protobuf/src/google/protobuf/inlined_string_field.h:287
google::protobuf.internal::InlinedStringField::ReleaseNonDefault
std::string * ReleaseNonDefault(const std::string *default_value, Arena *)
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:109
google::protobuf.internal::InlinedStringField::SetAllocatedNoArena
void SetAllocatedNoArena(const std::string *default_value, std::string *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:180
google::protobuf.internal::ArenaStringPtr::EmptyDefault
Definition: protobuf/src/google/protobuf/arenastring.h:187
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::LazyString::get
const std::string & get() const
Definition: protobuf/src/google/protobuf/arenastring.h:79
google::protobuf.internal::InlinedStringField::ReleaseNonDefaultNoArena
std::string * ReleaseNonDefaultNoArena(const std::string *default_value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/inlined_string_field.h:205
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:03