You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

inlined_string_field.h 26 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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. #ifndef GOOGLE_PROTOBUF_INLINED_STRING_FIELD_H__
  31. #define GOOGLE_PROTOBUF_INLINED_STRING_FIELD_H__
  32. #include <string>
  33. #include <utility>
  34. #include <google/protobuf/stubs/logging.h>
  35. #include <google/protobuf/stubs/common.h>
  36. #include <google/protobuf/port.h>
  37. #include <google/protobuf/stubs/strutil.h>
  38. #include <google/protobuf/arenastring.h>
  39. #include <google/protobuf/message_lite.h>
  40. // Must be included last.
  41. #include <google/protobuf/port_def.inc>
  42. #ifdef SWIG
  43. #error "You cannot SWIG proto headers"
  44. #endif
  45. namespace google
  46. {
  47. namespace protobuf
  48. {
  49. class Arena;
  50. namespace internal
  51. {
  52. // InlinedStringField wraps a std::string instance and exposes an API similar to
  53. // ArenaStringPtr's wrapping of a std::string* instance.
  54. //
  55. // default_value parameters are taken for consistency with ArenaStringPtr, but
  56. // are not used for most methods. With inlining, these should be removed from
  57. // the generated binary.
  58. //
  59. // InlinedStringField has a donating mechanism that allows string buffer
  60. // allocated on arena. A string is donated means both the string container and
  61. // the data buffer are on arena. The donating mechanism here is similar to the
  62. // one in ArenaStringPtr with some differences:
  63. //
  64. // When an InlinedStringField is constructed, the donating state is true. This
  65. // is because the string container is directly stored in the message on the
  66. // arena:
  67. //
  68. // Construction: donated=true
  69. // Arena:
  70. // +-----------------------+
  71. // |Message foo: |
  72. // | +-------------------+ |
  73. // | |InlinedStringField:| |
  74. // | | +-----+ | |
  75. // | | | | | | | |
  76. // | | +-----+ | |
  77. // | +-------------------+ |
  78. // +-----------------------+
  79. //
  80. // When lvalue Set is called, the donating state is still true. String data will
  81. // be allocated on the arena:
  82. //
  83. // Lvalue Set: donated=true
  84. // Arena:
  85. // +-----------------------+
  86. // |Message foo: |
  87. // | +-------------------+ |
  88. // | |InlinedStringField:| |
  89. // | | +-----+ | |
  90. // | | | | | | | |
  91. // | | +|----+ | |
  92. // | +--|----------------+ |
  93. // | V |
  94. // | +----------------+ |
  95. // | |'f','o','o',... | |
  96. // | +----------------+ |
  97. // +-----------------------+
  98. //
  99. // Some operations will undonate a donated string, including: Mutable,
  100. // SetAllocated, Rvalue Set, and Swap with a non-donated string.
  101. //
  102. // For more details of the donating states transitions, go/pd-inlined-string.
  103. class PROTOBUF_EXPORT InlinedStringField
  104. {
  105. public:
  106. InlinedStringField()
  107. {
  108. Init();
  109. }
  110. inline void Init()
  111. {
  112. new (get_mutable()) std::string();
  113. }
  114. // Add the dummy parameter just to make InlinedStringField(nullptr)
  115. // unambiguous.
  116. constexpr InlinedStringField(
  117. const ExplicitlyConstructed<std::string>* /*default_value*/,
  118. bool /*dummy*/
  119. ) :
  120. value_{}
  121. {
  122. }
  123. explicit InlinedStringField(const std::string& default_value);
  124. explicit InlinedStringField(Arena* arena);
  125. ~InlinedStringField()
  126. {
  127. Destruct();
  128. }
  129. // Lvalue Set. To save space, we pack the donating states of multiple
  130. // InlinedStringFields into an uint32_t `donating_states`. The `mask`
  131. // indicates the position of the bit for this InlinedStringField. `donated` is
  132. // whether this field is donated.
  133. //
  134. // The caller should guarantee that:
  135. //
  136. // `donated == ((donating_states & ~mask) != 0)`
  137. //
  138. // This method never changes the `donating_states`.
  139. void Set(ConstStringParam value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  140. // Rvalue Set. If this field is donated, this method will undonate this field
  141. // by mutating the `donating_states` according to `mask`.
  142. void Set(std::string&& value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  143. void Set(const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  144. void Set(const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  145. template<typename RefWrappedType>
  146. void Set(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  147. void SetBytes(ConstStringParam value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  148. void SetBytes(std::string&& value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  149. void SetBytes(const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  150. void SetBytes(const void* p, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  151. template<typename RefWrappedType>
  152. void SetBytes(std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  153. PROTOBUF_NDEBUG_INLINE void SetNoArena(StringPiece value);
  154. PROTOBUF_NDEBUG_INLINE void SetNoArena(std::string&& value);
  155. // Basic accessors.
  156. PROTOBUF_NDEBUG_INLINE const std::string& Get() const
  157. {
  158. return GetNoArena();
  159. }
  160. PROTOBUF_NDEBUG_INLINE const std::string& GetNoArena() const;
  161. // Mutable returns a std::string* instance that is heap-allocated. If this
  162. // field is donated, this method undonates this field by mutating the
  163. // `donating_states` according to `mask`, and copies the content of the
  164. // original string to the returning string.
  165. std::string* Mutable(Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  166. std::string* Mutable(const LazyString& default_value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  167. // Mutable(nullptr_t) is an overload to explicitly support Mutable(nullptr)
  168. // calls used by the internal parser logic. This provides API equivalence with
  169. // ArenaStringPtr, while still protecting against calls with arena pointers.
  170. std::string* Mutable(std::nullptr_t);
  171. std::string* MutableNoCopy(std::nullptr_t);
  172. // Takes a std::string that is heap-allocated, and takes ownership. The
  173. // std::string's destructor is registered with the arena. Used to implement
  174. // set_allocated_<field> in generated classes.
  175. //
  176. // If this field is donated, this method undonates this field by mutating the
  177. // `donating_states` according to `mask`.
  178. void SetAllocated(const std::string* default_value, std::string* value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  179. void SetAllocatedNoArena(const std::string* default_value, std::string* value);
  180. // Release returns a std::string* instance that is heap-allocated and is not
  181. // Own()'d by any arena. If the field is not set, this returns nullptr. The
  182. // caller retains ownership. Clears this field back to nullptr state. Used to
  183. // implement release_<field>() methods on generated classes.
  184. PROTOBUF_NODISCARD std::string* Release(Arena* arena, bool donated);
  185. PROTOBUF_NODISCARD std::string* Release();
  186. // --------------------------------------------------------
  187. // Below functions will be removed in subsequent code change
  188. // --------------------------------------------------------
  189. #ifdef DEPRECATED_METHODS_TO_BE_DELETED
  190. PROTOBUF_NODISCARD std::string* Release(const std::string*, Arena* arena, bool donated)
  191. {
  192. return Release(arena, donated);
  193. }
  194. PROTOBUF_NODISCARD std::string* ReleaseNonDefault(const std::string*, Arena* arena)
  195. {
  196. return Release();
  197. }
  198. std::string* ReleaseNonDefaultNoArena(const std::string* default_value)
  199. {
  200. return Release();
  201. }
  202. void Set(const std::string*, ConstStringParam value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  203. {
  204. Set(value, arena, donated, donating_states, mask, msg);
  205. }
  206. void Set(const std::string*, std::string&& value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  207. {
  208. Set(std::move(value), arena, donated, donating_states, mask, msg);
  209. }
  210. template<typename FirstParam>
  211. void Set(FirstParam, const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  212. {
  213. Set(str, arena, donated, donating_states, mask, msg);
  214. }
  215. template<typename FirstParam>
  216. void Set(FirstParam p1, const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  217. {
  218. Set(str, size, arena, donated, donating_states, mask, msg);
  219. }
  220. template<typename FirstParam, typename RefWrappedType>
  221. void Set(FirstParam p1, std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  222. {
  223. Set(const_string_ref, arena, donated, donating_states, mask, msg);
  224. }
  225. void SetBytes(const std::string*, ConstStringParam value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  226. {
  227. Set(value, arena, donated, donating_states, mask, msg);
  228. }
  229. void SetBytes(const std::string*, std::string&& value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  230. {
  231. Set(std::move(value), arena, donated, donating_states, mask, msg);
  232. }
  233. template<typename FirstParam>
  234. void SetBytes(FirstParam p1, const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  235. {
  236. SetBytes(str, arena, donated, donating_states, mask, msg);
  237. }
  238. template<typename FirstParam>
  239. void SetBytes(FirstParam p1, const void* p, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  240. {
  241. SetBytes(p, size, arena, donated, donating_states, mask, msg);
  242. }
  243. template<typename FirstParam, typename RefWrappedType>
  244. void SetBytes(FirstParam p1, std::reference_wrapper<RefWrappedType> const_string_ref, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  245. {
  246. SetBytes(const_string_ref.get(), arena, donated, donating_states, mask, msg);
  247. }
  248. void SetNoArena(const std::string*, StringPiece value)
  249. {
  250. SetNoArena(value);
  251. }
  252. void SetNoArena(const std::string*, std::string&& value)
  253. {
  254. SetNoArena(std::move(value));
  255. }
  256. std::string* Mutable(ArenaStringPtr::EmptyDefault, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  257. {
  258. return Mutable(arena, donated, donating_states, mask, msg);
  259. }
  260. PROTOBUF_NDEBUG_INLINE std::string* MutableNoArenaNoDefault(
  261. const std::string* /*default_value*/
  262. )
  263. {
  264. return MutableNoCopy(nullptr);
  265. }
  266. #endif // DEPRECATED_METHODS_TO_BE_DELETED
  267. // Arena-safety semantics: this is guarded by the logic in
  268. // Swap()/UnsafeArenaSwap() at the message level, so this method is
  269. // 'unsafe' if called directly.
  270. inline PROTOBUF_NDEBUG_INLINE static void InternalSwap(
  271. InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered,
  272. MessageLite* lhs_msg, //
  273. InlinedStringField* rhs,
  274. Arena* rhs_arena,
  275. bool rhs_arena_dtor_registered,
  276. MessageLite* rhs_msg
  277. );
  278. // Frees storage (if not on an arena).
  279. PROTOBUF_NDEBUG_INLINE void Destroy(const std::string* default_value, Arena* arena)
  280. {
  281. if (arena == nullptr)
  282. {
  283. DestroyNoArena(default_value);
  284. }
  285. }
  286. PROTOBUF_NDEBUG_INLINE void DestroyNoArena(const std::string* default_value);
  287. // Clears content, but keeps allocated std::string, to avoid the overhead of
  288. // heap operations. After this returns, the content (as seen by the user) will
  289. // always be the empty std::string.
  290. PROTOBUF_NDEBUG_INLINE void ClearToEmpty()
  291. {
  292. ClearNonDefaultToEmpty();
  293. }
  294. PROTOBUF_NDEBUG_INLINE void ClearNonDefaultToEmpty()
  295. {
  296. get_mutable()->clear();
  297. }
  298. // Clears content, but keeps allocated std::string if arena != nullptr, to
  299. // avoid the overhead of heap operations. After this returns, the content (as
  300. // seen by the user) will always be equal to |default_value|.
  301. void ClearToDefault(const LazyString& default_value, Arena* arena, bool donated);
  302. // Generated code / reflection only! Returns a mutable pointer to the string.
  303. PROTOBUF_NDEBUG_INLINE std::string* UnsafeMutablePointer();
  304. // InlinedStringField doesn't have things like the `default_value` pointer in
  305. // ArenaStringPtr.
  306. static constexpr bool IsDefault()
  307. {
  308. return false;
  309. }
  310. static constexpr bool IsDefault(const std::string*)
  311. {
  312. return false;
  313. }
  314. private:
  315. void Destruct()
  316. {
  317. get_mutable()->~basic_string();
  318. }
  319. PROTOBUF_NDEBUG_INLINE std::string* get_mutable();
  320. PROTOBUF_NDEBUG_INLINE const std::string* get_const() const;
  321. alignas(std::string) char value_[sizeof(std::string)];
  322. std::string* MutableSlow(::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg);
  323. // When constructed in an Arena, we want our destructor to be skipped.
  324. friend class ::google::protobuf::Arena;
  325. typedef void InternalArenaConstructable_;
  326. typedef void DestructorSkippable_;
  327. };
  328. inline std::string* InlinedStringField::get_mutable()
  329. {
  330. return reinterpret_cast<std::string*>(&value_);
  331. }
  332. inline const std::string* InlinedStringField::get_const() const
  333. {
  334. return reinterpret_cast<const std::string*>(&value_);
  335. }
  336. inline InlinedStringField::InlinedStringField(
  337. const std::string& default_value
  338. )
  339. {
  340. new (get_mutable()) std::string(default_value);
  341. }
  342. inline InlinedStringField::InlinedStringField(Arena* /*arena*/)
  343. {
  344. Init();
  345. }
  346. inline const std::string& InlinedStringField::GetNoArena() const
  347. {
  348. return *get_const();
  349. }
  350. inline void InlinedStringField::SetAllocatedNoArena(
  351. const std::string* /*default_value*/, std::string* value
  352. )
  353. {
  354. if (value == nullptr)
  355. {
  356. // Currently, inlined string field can't have non empty default.
  357. get_mutable()->clear();
  358. }
  359. else
  360. {
  361. get_mutable()->assign(std::move(*value));
  362. delete value;
  363. }
  364. }
  365. inline void InlinedStringField::DestroyNoArena(const std::string*)
  366. {
  367. // This is invoked from the generated message's ArenaDtor, which is used to
  368. // clean up objects not allocated on the Arena.
  369. this->~InlinedStringField();
  370. }
  371. inline void InlinedStringField::SetNoArena(StringPiece value)
  372. {
  373. get_mutable()->assign(value.data(), value.length());
  374. }
  375. inline void InlinedStringField::SetNoArena(std::string&& value)
  376. {
  377. get_mutable()->assign(std::move(value));
  378. }
  379. // Caller should make sure rhs_arena allocated rhs, and lhs_arena allocated lhs.
  380. inline PROTOBUF_NDEBUG_INLINE void InlinedStringField::InternalSwap(
  381. InlinedStringField* lhs, Arena* lhs_arena, bool lhs_arena_dtor_registered,
  382. MessageLite* lhs_msg, //
  383. InlinedStringField* rhs,
  384. Arena* rhs_arena,
  385. bool rhs_arena_dtor_registered,
  386. MessageLite* rhs_msg
  387. )
  388. {
  389. #if GOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE
  390. lhs->get_mutable()->swap(*rhs->get_mutable());
  391. if (!lhs_arena_dtor_registered && rhs_arena_dtor_registered)
  392. {
  393. lhs_msg->OnDemandRegisterArenaDtor(lhs_arena);
  394. }
  395. else if (lhs_arena_dtor_registered && !rhs_arena_dtor_registered)
  396. {
  397. rhs_msg->OnDemandRegisterArenaDtor(rhs_arena);
  398. }
  399. #else
  400. (void)lhs_arena;
  401. (void)rhs_arena;
  402. (void)lhs_arena_dtor_registered;
  403. (void)rhs_arena_dtor_registered;
  404. (void)lhs_msg;
  405. (void)rhs_msg;
  406. lhs->get_mutable()->swap(*rhs->get_mutable());
  407. #endif
  408. }
  409. inline void InlinedStringField::Set(ConstStringParam value, Arena* arena, bool donated, uint32_t* /*donating_states*/, uint32_t /*mask*/, MessageLite* /*msg*/)
  410. {
  411. (void)arena;
  412. (void)donated;
  413. SetNoArena(value);
  414. }
  415. inline void InlinedStringField::Set(const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  416. {
  417. Set(ConstStringParam(str), arena, donated, donating_states, mask, msg);
  418. }
  419. inline void InlinedStringField::Set(const char* str, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  420. {
  421. Set(ConstStringParam{str, size}, arena, donated, donating_states, mask, msg);
  422. }
  423. inline void InlinedStringField::SetBytes(ConstStringParam value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  424. {
  425. Set(value, arena, donated, donating_states, mask, msg);
  426. }
  427. inline void InlinedStringField::SetBytes(std::string&& value, Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  428. {
  429. Set(std::move(value), arena, donated, donating_states, mask, msg);
  430. }
  431. inline void InlinedStringField::SetBytes(const char* str, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  432. {
  433. Set(str, arena, donated, donating_states, mask, msg);
  434. }
  435. inline void InlinedStringField::SetBytes(const void* p, size_t size, ::google::protobuf::Arena* arena, bool donated, uint32_t* donating_states, uint32_t mask, MessageLite* msg)
  436. {
  437. Set(static_cast<const char*>(p), size, arena, donated, donating_states, mask, msg);
  438. }
  439. template<typename RefWrappedType>
  440. inline void InlinedStringField::Set(
  441. std::reference_wrapper<RefWrappedType> const_string_ref,
  442. ::google::protobuf::Arena* arena,
  443. bool donated,
  444. uint32_t* donating_states,
  445. uint32_t mask,
  446. MessageLite* msg
  447. )
  448. {
  449. Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
  450. }
  451. template<typename RefWrappedType>
  452. inline void InlinedStringField::SetBytes(
  453. std::reference_wrapper<RefWrappedType> const_string_ref,
  454. ::google::protobuf::Arena* arena,
  455. bool donated,
  456. uint32_t* donating_states,
  457. uint32_t mask,
  458. MessageLite* msg
  459. )
  460. {
  461. Set(const_string_ref.get(), arena, donated, donating_states, mask, msg);
  462. }
  463. inline std::string* InlinedStringField::UnsafeMutablePointer()
  464. {
  465. return get_mutable();
  466. }
  467. inline std::string* InlinedStringField::Mutable(std::nullptr_t)
  468. {
  469. return get_mutable();
  470. }
  471. inline std::string* InlinedStringField::MutableNoCopy(std::nullptr_t)
  472. {
  473. return get_mutable();
  474. }
  475. } // namespace internal
  476. } // namespace protobuf
  477. } // namespace google
  478. #include <google/protobuf/port_undef.inc>
  479. #endif // GOOGLE_PROTOBUF_INLINED_STRING_FIELD_H__