unittest_optimize_for.pb.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: google/protobuf/unittest_optimize_for.proto
  3. #ifndef PROTOBUF_INCLUDED_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto
  4. #define PROTOBUF_INCLUDED_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto
  5. #include <string>
  6. #include <google/protobuf/stubs/common.h>
  7. #if GOOGLE_PROTOBUF_VERSION < 3006001
  8. #error This file was generated by a newer version of protoc which is
  9. #error incompatible with your Protocol Buffer headers. Please update
  10. #error your headers.
  11. #endif
  12. #if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
  13. #error This file was generated by an older version of protoc which is
  14. #error incompatible with your Protocol Buffer headers. Please
  15. #error regenerate this file with a newer version of protoc.
  16. #endif
  17. #include <google/protobuf/io/coded_stream.h>
  18. #include <google/protobuf/arena.h>
  19. #include <google/protobuf/arenastring.h>
  20. #include <google/protobuf/generated_message_table_driven.h>
  21. #include <google/protobuf/generated_message_util.h>
  22. #include <google/protobuf/inlined_string_field.h>
  23. #include <google/protobuf/metadata.h>
  24. #include <google/protobuf/message.h>
  25. #include <google/protobuf/repeated_field.h> // IWYU pragma: export
  26. #include <google/protobuf/extension_set.h> // IWYU pragma: export
  27. #include <google/protobuf/unknown_field_set.h>
  28. #include <google/protobuf/unittest.pb.h>
  29. // @@protoc_insertion_point(includes)
  30. #define PROTOBUF_INTERNAL_EXPORT_protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto
  31. namespace protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto {
  32. // Internal implementation detail -- do not use these members.
  33. struct TableStruct {
  34. static const ::google::protobuf::internal::ParseTableField entries[];
  35. static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
  36. static const ::google::protobuf::internal::ParseTable schema[3];
  37. static const ::google::protobuf::internal::FieldMetadata field_metadata[];
  38. static const ::google::protobuf::internal::SerializationTable serialization_table[];
  39. static const ::google::protobuf::uint32 offsets[];
  40. };
  41. void AddDescriptors();
  42. } // namespace protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto
  43. namespace protobuf_unittest {
  44. class TestOptimizedForSize;
  45. class TestOptimizedForSizeDefaultTypeInternal;
  46. extern TestOptimizedForSizeDefaultTypeInternal _TestOptimizedForSize_default_instance_;
  47. class TestOptionalOptimizedForSize;
  48. class TestOptionalOptimizedForSizeDefaultTypeInternal;
  49. extern TestOptionalOptimizedForSizeDefaultTypeInternal _TestOptionalOptimizedForSize_default_instance_;
  50. class TestRequiredOptimizedForSize;
  51. class TestRequiredOptimizedForSizeDefaultTypeInternal;
  52. extern TestRequiredOptimizedForSizeDefaultTypeInternal _TestRequiredOptimizedForSize_default_instance_;
  53. } // namespace protobuf_unittest
  54. namespace google {
  55. namespace protobuf {
  56. template<> ::protobuf_unittest::TestOptimizedForSize* Arena::CreateMaybeMessage<::protobuf_unittest::TestOptimizedForSize>(Arena*);
  57. template<> ::protobuf_unittest::TestOptionalOptimizedForSize* Arena::CreateMaybeMessage<::protobuf_unittest::TestOptionalOptimizedForSize>(Arena*);
  58. template<> ::protobuf_unittest::TestRequiredOptimizedForSize* Arena::CreateMaybeMessage<::protobuf_unittest::TestRequiredOptimizedForSize>(Arena*);
  59. } // namespace protobuf
  60. } // namespace google
  61. namespace protobuf_unittest {
  62. // ===================================================================
  63. class TestOptimizedForSize : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestOptimizedForSize) */ {
  64. public:
  65. TestOptimizedForSize();
  66. virtual ~TestOptimizedForSize();
  67. TestOptimizedForSize(const TestOptimizedForSize& from);
  68. inline TestOptimizedForSize& operator=(const TestOptimizedForSize& from) {
  69. CopyFrom(from);
  70. return *this;
  71. }
  72. #if LANG_CXX11
  73. TestOptimizedForSize(TestOptimizedForSize&& from) noexcept
  74. : TestOptimizedForSize() {
  75. *this = ::std::move(from);
  76. }
  77. inline TestOptimizedForSize& operator=(TestOptimizedForSize&& from) noexcept {
  78. if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
  79. if (this != &from) InternalSwap(&from);
  80. } else {
  81. CopyFrom(from);
  82. }
  83. return *this;
  84. }
  85. #endif
  86. inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
  87. return _internal_metadata_.unknown_fields();
  88. }
  89. inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
  90. return _internal_metadata_.mutable_unknown_fields();
  91. }
  92. static const ::google::protobuf::Descriptor* descriptor();
  93. static const TestOptimizedForSize& default_instance();
  94. enum FooCase {
  95. kIntegerField = 2,
  96. kStringField = 3,
  97. FOO_NOT_SET = 0,
  98. };
  99. static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
  100. static inline const TestOptimizedForSize* internal_default_instance() {
  101. return reinterpret_cast<const TestOptimizedForSize*>(
  102. &_TestOptimizedForSize_default_instance_);
  103. }
  104. static constexpr int kIndexInFileMessages =
  105. 0;
  106. void Swap(TestOptimizedForSize* other);
  107. friend void swap(TestOptimizedForSize& a, TestOptimizedForSize& b) {
  108. a.Swap(&b);
  109. }
  110. // implements Message ----------------------------------------------
  111. inline TestOptimizedForSize* New() const final {
  112. return CreateMaybeMessage<TestOptimizedForSize>(NULL);
  113. }
  114. TestOptimizedForSize* New(::google::protobuf::Arena* arena) const final {
  115. return CreateMaybeMessage<TestOptimizedForSize>(arena);
  116. }
  117. int GetCachedSize() const final { return _cached_size_.Get(); }
  118. private:
  119. void SharedCtor();
  120. void SharedDtor();
  121. void SetCachedSize(int size) const final;
  122. void InternalSwap(TestOptimizedForSize* other);
  123. private:
  124. inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
  125. return NULL;
  126. }
  127. inline void* MaybeArenaPtr() const {
  128. return NULL;
  129. }
  130. public:
  131. ::google::protobuf::Metadata GetMetadata() const final;
  132. // nested types ----------------------------------------------------
  133. // accessors -------------------------------------------------------
  134. // optional .protobuf_unittest.ForeignMessage msg = 19;
  135. bool has_msg() const;
  136. void clear_msg();
  137. static const int kMsgFieldNumber = 19;
  138. private:
  139. const ::protobuf_unittest::ForeignMessage& _internal_msg() const;
  140. public:
  141. const ::protobuf_unittest::ForeignMessage& msg() const;
  142. ::protobuf_unittest::ForeignMessage* release_msg();
  143. ::protobuf_unittest::ForeignMessage* mutable_msg();
  144. void set_allocated_msg(::protobuf_unittest::ForeignMessage* msg);
  145. // optional int32 i = 1;
  146. bool has_i() const;
  147. void clear_i();
  148. static const int kIFieldNumber = 1;
  149. ::google::protobuf::int32 i() const;
  150. void set_i(::google::protobuf::int32 value);
  151. // optional int32 integer_field = 2;
  152. bool has_integer_field() const;
  153. void clear_integer_field();
  154. static const int kIntegerFieldFieldNumber = 2;
  155. ::google::protobuf::int32 integer_field() const;
  156. void set_integer_field(::google::protobuf::int32 value);
  157. // optional string string_field = 3;
  158. bool has_string_field() const;
  159. void clear_string_field();
  160. static const int kStringFieldFieldNumber = 3;
  161. const ::std::string& string_field() const;
  162. void set_string_field(const ::std::string& value);
  163. #if LANG_CXX11
  164. void set_string_field(::std::string&& value);
  165. #endif
  166. void set_string_field(const char* value);
  167. void set_string_field(const char* value, size_t size);
  168. ::std::string* mutable_string_field();
  169. ::std::string* release_string_field();
  170. void set_allocated_string_field(::std::string* string_field);
  171. GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(TestOptimizedForSize)
  172. void clear_foo();
  173. FooCase foo_case() const;
  174. static const int kTestExtensionFieldNumber = 1234;
  175. static ::google::protobuf::internal::ExtensionIdentifier< ::protobuf_unittest::TestOptimizedForSize,
  176. ::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::int32 >, 5, false >
  177. test_extension;
  178. static const int kTestExtension2FieldNumber = 1235;
  179. static ::google::protobuf::internal::ExtensionIdentifier< ::protobuf_unittest::TestOptimizedForSize,
  180. ::google::protobuf::internal::MessageTypeTraits< ::protobuf_unittest::TestRequiredOptimizedForSize >, 11, false >
  181. test_extension2;
  182. // @@protoc_insertion_point(class_scope:protobuf_unittest.TestOptimizedForSize)
  183. private:
  184. void set_has_i();
  185. void clear_has_i();
  186. void set_has_msg();
  187. void clear_has_msg();
  188. void set_has_integer_field();
  189. void set_has_string_field();
  190. inline bool has_foo() const;
  191. inline void clear_has_foo();
  192. ::google::protobuf::internal::ExtensionSet _extensions_;
  193. ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  194. ::google::protobuf::internal::HasBits<1> _has_bits_;
  195. mutable ::google::protobuf::internal::CachedSize _cached_size_;
  196. ::protobuf_unittest::ForeignMessage* msg_;
  197. ::google::protobuf::int32 i_;
  198. union FooUnion {
  199. FooUnion() {}
  200. ::google::protobuf::int32 integer_field_;
  201. ::google::protobuf::internal::ArenaStringPtr string_field_;
  202. } foo_;
  203. ::google::protobuf::uint32 _oneof_case_[1];
  204. friend struct ::protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto::TableStruct;
  205. };
  206. // -------------------------------------------------------------------
  207. class TestRequiredOptimizedForSize : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestRequiredOptimizedForSize) */ {
  208. public:
  209. TestRequiredOptimizedForSize();
  210. virtual ~TestRequiredOptimizedForSize();
  211. TestRequiredOptimizedForSize(const TestRequiredOptimizedForSize& from);
  212. inline TestRequiredOptimizedForSize& operator=(const TestRequiredOptimizedForSize& from) {
  213. CopyFrom(from);
  214. return *this;
  215. }
  216. #if LANG_CXX11
  217. TestRequiredOptimizedForSize(TestRequiredOptimizedForSize&& from) noexcept
  218. : TestRequiredOptimizedForSize() {
  219. *this = ::std::move(from);
  220. }
  221. inline TestRequiredOptimizedForSize& operator=(TestRequiredOptimizedForSize&& from) noexcept {
  222. if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
  223. if (this != &from) InternalSwap(&from);
  224. } else {
  225. CopyFrom(from);
  226. }
  227. return *this;
  228. }
  229. #endif
  230. inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
  231. return _internal_metadata_.unknown_fields();
  232. }
  233. inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
  234. return _internal_metadata_.mutable_unknown_fields();
  235. }
  236. static const ::google::protobuf::Descriptor* descriptor();
  237. static const TestRequiredOptimizedForSize& default_instance();
  238. static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
  239. static inline const TestRequiredOptimizedForSize* internal_default_instance() {
  240. return reinterpret_cast<const TestRequiredOptimizedForSize*>(
  241. &_TestRequiredOptimizedForSize_default_instance_);
  242. }
  243. static constexpr int kIndexInFileMessages =
  244. 1;
  245. void Swap(TestRequiredOptimizedForSize* other);
  246. friend void swap(TestRequiredOptimizedForSize& a, TestRequiredOptimizedForSize& b) {
  247. a.Swap(&b);
  248. }
  249. // implements Message ----------------------------------------------
  250. inline TestRequiredOptimizedForSize* New() const final {
  251. return CreateMaybeMessage<TestRequiredOptimizedForSize>(NULL);
  252. }
  253. TestRequiredOptimizedForSize* New(::google::protobuf::Arena* arena) const final {
  254. return CreateMaybeMessage<TestRequiredOptimizedForSize>(arena);
  255. }
  256. int GetCachedSize() const final { return _cached_size_.Get(); }
  257. private:
  258. void SharedCtor();
  259. void SharedDtor();
  260. void SetCachedSize(int size) const final;
  261. void InternalSwap(TestRequiredOptimizedForSize* other);
  262. private:
  263. inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
  264. return NULL;
  265. }
  266. inline void* MaybeArenaPtr() const {
  267. return NULL;
  268. }
  269. public:
  270. ::google::protobuf::Metadata GetMetadata() const final;
  271. // nested types ----------------------------------------------------
  272. // accessors -------------------------------------------------------
  273. // required int32 x = 1;
  274. bool has_x() const;
  275. void clear_x();
  276. static const int kXFieldNumber = 1;
  277. ::google::protobuf::int32 x() const;
  278. void set_x(::google::protobuf::int32 value);
  279. // @@protoc_insertion_point(class_scope:protobuf_unittest.TestRequiredOptimizedForSize)
  280. private:
  281. void set_has_x();
  282. void clear_has_x();
  283. ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  284. ::google::protobuf::internal::HasBits<1> _has_bits_;
  285. mutable ::google::protobuf::internal::CachedSize _cached_size_;
  286. ::google::protobuf::int32 x_;
  287. friend struct ::protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto::TableStruct;
  288. };
  289. // -------------------------------------------------------------------
  290. class TestOptionalOptimizedForSize : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestOptionalOptimizedForSize) */ {
  291. public:
  292. TestOptionalOptimizedForSize();
  293. virtual ~TestOptionalOptimizedForSize();
  294. TestOptionalOptimizedForSize(const TestOptionalOptimizedForSize& from);
  295. inline TestOptionalOptimizedForSize& operator=(const TestOptionalOptimizedForSize& from) {
  296. CopyFrom(from);
  297. return *this;
  298. }
  299. #if LANG_CXX11
  300. TestOptionalOptimizedForSize(TestOptionalOptimizedForSize&& from) noexcept
  301. : TestOptionalOptimizedForSize() {
  302. *this = ::std::move(from);
  303. }
  304. inline TestOptionalOptimizedForSize& operator=(TestOptionalOptimizedForSize&& from) noexcept {
  305. if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
  306. if (this != &from) InternalSwap(&from);
  307. } else {
  308. CopyFrom(from);
  309. }
  310. return *this;
  311. }
  312. #endif
  313. inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
  314. return _internal_metadata_.unknown_fields();
  315. }
  316. inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
  317. return _internal_metadata_.mutable_unknown_fields();
  318. }
  319. static const ::google::protobuf::Descriptor* descriptor();
  320. static const TestOptionalOptimizedForSize& default_instance();
  321. static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
  322. static inline const TestOptionalOptimizedForSize* internal_default_instance() {
  323. return reinterpret_cast<const TestOptionalOptimizedForSize*>(
  324. &_TestOptionalOptimizedForSize_default_instance_);
  325. }
  326. static constexpr int kIndexInFileMessages =
  327. 2;
  328. void Swap(TestOptionalOptimizedForSize* other);
  329. friend void swap(TestOptionalOptimizedForSize& a, TestOptionalOptimizedForSize& b) {
  330. a.Swap(&b);
  331. }
  332. // implements Message ----------------------------------------------
  333. inline TestOptionalOptimizedForSize* New() const final {
  334. return CreateMaybeMessage<TestOptionalOptimizedForSize>(NULL);
  335. }
  336. TestOptionalOptimizedForSize* New(::google::protobuf::Arena* arena) const final {
  337. return CreateMaybeMessage<TestOptionalOptimizedForSize>(arena);
  338. }
  339. int GetCachedSize() const final { return _cached_size_.Get(); }
  340. private:
  341. void SharedCtor();
  342. void SharedDtor();
  343. void SetCachedSize(int size) const final;
  344. void InternalSwap(TestOptionalOptimizedForSize* other);
  345. private:
  346. inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
  347. return NULL;
  348. }
  349. inline void* MaybeArenaPtr() const {
  350. return NULL;
  351. }
  352. public:
  353. ::google::protobuf::Metadata GetMetadata() const final;
  354. // nested types ----------------------------------------------------
  355. // accessors -------------------------------------------------------
  356. // optional .protobuf_unittest.TestRequiredOptimizedForSize o = 1;
  357. bool has_o() const;
  358. void clear_o();
  359. static const int kOFieldNumber = 1;
  360. private:
  361. const ::protobuf_unittest::TestRequiredOptimizedForSize& _internal_o() const;
  362. public:
  363. const ::protobuf_unittest::TestRequiredOptimizedForSize& o() const;
  364. ::protobuf_unittest::TestRequiredOptimizedForSize* release_o();
  365. ::protobuf_unittest::TestRequiredOptimizedForSize* mutable_o();
  366. void set_allocated_o(::protobuf_unittest::TestRequiredOptimizedForSize* o);
  367. // @@protoc_insertion_point(class_scope:protobuf_unittest.TestOptionalOptimizedForSize)
  368. private:
  369. void set_has_o();
  370. void clear_has_o();
  371. ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
  372. ::google::protobuf::internal::HasBits<1> _has_bits_;
  373. mutable ::google::protobuf::internal::CachedSize _cached_size_;
  374. ::protobuf_unittest::TestRequiredOptimizedForSize* o_;
  375. friend struct ::protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto::TableStruct;
  376. };
  377. // ===================================================================
  378. // ===================================================================
  379. #ifdef __GNUC__
  380. #pragma GCC diagnostic push
  381. #pragma GCC diagnostic ignored "-Wstrict-aliasing"
  382. #endif // __GNUC__
  383. // TestOptimizedForSize
  384. // optional int32 i = 1;
  385. inline bool TestOptimizedForSize::has_i() const {
  386. return (_has_bits_[0] & 0x00000002u) != 0;
  387. }
  388. inline void TestOptimizedForSize::set_has_i() {
  389. _has_bits_[0] |= 0x00000002u;
  390. }
  391. inline void TestOptimizedForSize::clear_has_i() {
  392. _has_bits_[0] &= ~0x00000002u;
  393. }
  394. inline void TestOptimizedForSize::clear_i() {
  395. i_ = 0;
  396. clear_has_i();
  397. }
  398. inline ::google::protobuf::int32 TestOptimizedForSize::i() const {
  399. // @@protoc_insertion_point(field_get:protobuf_unittest.TestOptimizedForSize.i)
  400. return i_;
  401. }
  402. inline void TestOptimizedForSize::set_i(::google::protobuf::int32 value) {
  403. set_has_i();
  404. i_ = value;
  405. // @@protoc_insertion_point(field_set:protobuf_unittest.TestOptimizedForSize.i)
  406. }
  407. // optional .protobuf_unittest.ForeignMessage msg = 19;
  408. inline bool TestOptimizedForSize::has_msg() const {
  409. return (_has_bits_[0] & 0x00000001u) != 0;
  410. }
  411. inline void TestOptimizedForSize::set_has_msg() {
  412. _has_bits_[0] |= 0x00000001u;
  413. }
  414. inline void TestOptimizedForSize::clear_has_msg() {
  415. _has_bits_[0] &= ~0x00000001u;
  416. }
  417. inline const ::protobuf_unittest::ForeignMessage& TestOptimizedForSize::_internal_msg() const {
  418. return *msg_;
  419. }
  420. inline const ::protobuf_unittest::ForeignMessage& TestOptimizedForSize::msg() const {
  421. const ::protobuf_unittest::ForeignMessage* p = msg_;
  422. // @@protoc_insertion_point(field_get:protobuf_unittest.TestOptimizedForSize.msg)
  423. return p != NULL ? *p : *reinterpret_cast<const ::protobuf_unittest::ForeignMessage*>(
  424. &::protobuf_unittest::_ForeignMessage_default_instance_);
  425. }
  426. inline ::protobuf_unittest::ForeignMessage* TestOptimizedForSize::release_msg() {
  427. // @@protoc_insertion_point(field_release:protobuf_unittest.TestOptimizedForSize.msg)
  428. clear_has_msg();
  429. ::protobuf_unittest::ForeignMessage* temp = msg_;
  430. msg_ = NULL;
  431. return temp;
  432. }
  433. inline ::protobuf_unittest::ForeignMessage* TestOptimizedForSize::mutable_msg() {
  434. set_has_msg();
  435. if (msg_ == NULL) {
  436. auto* p = CreateMaybeMessage<::protobuf_unittest::ForeignMessage>(GetArenaNoVirtual());
  437. msg_ = p;
  438. }
  439. // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestOptimizedForSize.msg)
  440. return msg_;
  441. }
  442. inline void TestOptimizedForSize::set_allocated_msg(::protobuf_unittest::ForeignMessage* msg) {
  443. ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  444. if (message_arena == NULL) {
  445. delete reinterpret_cast< ::google::protobuf::MessageLite*>(msg_);
  446. }
  447. if (msg) {
  448. ::google::protobuf::Arena* submessage_arena =
  449. reinterpret_cast<::google::protobuf::MessageLite*>(msg)->GetArena();
  450. if (message_arena != submessage_arena) {
  451. msg = ::google::protobuf::internal::GetOwnedMessage(
  452. message_arena, msg, submessage_arena);
  453. }
  454. set_has_msg();
  455. } else {
  456. clear_has_msg();
  457. }
  458. msg_ = msg;
  459. // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestOptimizedForSize.msg)
  460. }
  461. // optional int32 integer_field = 2;
  462. inline bool TestOptimizedForSize::has_integer_field() const {
  463. return foo_case() == kIntegerField;
  464. }
  465. inline void TestOptimizedForSize::set_has_integer_field() {
  466. _oneof_case_[0] = kIntegerField;
  467. }
  468. inline void TestOptimizedForSize::clear_integer_field() {
  469. if (has_integer_field()) {
  470. foo_.integer_field_ = 0;
  471. clear_has_foo();
  472. }
  473. }
  474. inline ::google::protobuf::int32 TestOptimizedForSize::integer_field() const {
  475. // @@protoc_insertion_point(field_get:protobuf_unittest.TestOptimizedForSize.integer_field)
  476. if (has_integer_field()) {
  477. return foo_.integer_field_;
  478. }
  479. return 0;
  480. }
  481. inline void TestOptimizedForSize::set_integer_field(::google::protobuf::int32 value) {
  482. if (!has_integer_field()) {
  483. clear_foo();
  484. set_has_integer_field();
  485. }
  486. foo_.integer_field_ = value;
  487. // @@protoc_insertion_point(field_set:protobuf_unittest.TestOptimizedForSize.integer_field)
  488. }
  489. // optional string string_field = 3;
  490. inline bool TestOptimizedForSize::has_string_field() const {
  491. return foo_case() == kStringField;
  492. }
  493. inline void TestOptimizedForSize::set_has_string_field() {
  494. _oneof_case_[0] = kStringField;
  495. }
  496. inline void TestOptimizedForSize::clear_string_field() {
  497. if (has_string_field()) {
  498. foo_.string_field_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  499. clear_has_foo();
  500. }
  501. }
  502. inline const ::std::string& TestOptimizedForSize::string_field() const {
  503. // @@protoc_insertion_point(field_get:protobuf_unittest.TestOptimizedForSize.string_field)
  504. if (has_string_field()) {
  505. return foo_.string_field_.GetNoArena();
  506. }
  507. return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();
  508. }
  509. inline void TestOptimizedForSize::set_string_field(const ::std::string& value) {
  510. // @@protoc_insertion_point(field_set:protobuf_unittest.TestOptimizedForSize.string_field)
  511. if (!has_string_field()) {
  512. clear_foo();
  513. set_has_string_field();
  514. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  515. }
  516. foo_.string_field_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
  517. // @@protoc_insertion_point(field_set:protobuf_unittest.TestOptimizedForSize.string_field)
  518. }
  519. #if LANG_CXX11
  520. inline void TestOptimizedForSize::set_string_field(::std::string&& value) {
  521. // @@protoc_insertion_point(field_set:protobuf_unittest.TestOptimizedForSize.string_field)
  522. if (!has_string_field()) {
  523. clear_foo();
  524. set_has_string_field();
  525. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  526. }
  527. foo_.string_field_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
  528. // @@protoc_insertion_point(field_set_rvalue:protobuf_unittest.TestOptimizedForSize.string_field)
  529. }
  530. #endif
  531. inline void TestOptimizedForSize::set_string_field(const char* value) {
  532. GOOGLE_DCHECK(value != NULL);
  533. if (!has_string_field()) {
  534. clear_foo();
  535. set_has_string_field();
  536. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  537. }
  538. foo_.string_field_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
  539. ::std::string(value));
  540. // @@protoc_insertion_point(field_set_char:protobuf_unittest.TestOptimizedForSize.string_field)
  541. }
  542. inline void TestOptimizedForSize::set_string_field(const char* value, size_t size) {
  543. if (!has_string_field()) {
  544. clear_foo();
  545. set_has_string_field();
  546. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  547. }
  548. foo_.string_field_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(
  549. reinterpret_cast<const char*>(value), size));
  550. // @@protoc_insertion_point(field_set_pointer:protobuf_unittest.TestOptimizedForSize.string_field)
  551. }
  552. inline ::std::string* TestOptimizedForSize::mutable_string_field() {
  553. if (!has_string_field()) {
  554. clear_foo();
  555. set_has_string_field();
  556. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  557. }
  558. // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestOptimizedForSize.string_field)
  559. return foo_.string_field_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  560. }
  561. inline ::std::string* TestOptimizedForSize::release_string_field() {
  562. // @@protoc_insertion_point(field_release:protobuf_unittest.TestOptimizedForSize.string_field)
  563. if (has_string_field()) {
  564. clear_has_foo();
  565. return foo_.string_field_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  566. } else {
  567. return NULL;
  568. }
  569. }
  570. inline void TestOptimizedForSize::set_allocated_string_field(::std::string* string_field) {
  571. if (!has_string_field()) {
  572. foo_.string_field_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  573. }
  574. clear_foo();
  575. if (string_field != NULL) {
  576. set_has_string_field();
  577. foo_.string_field_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_field);
  578. }
  579. // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestOptimizedForSize.string_field)
  580. }
  581. inline bool TestOptimizedForSize::has_foo() const {
  582. return foo_case() != FOO_NOT_SET;
  583. }
  584. inline void TestOptimizedForSize::clear_has_foo() {
  585. _oneof_case_[0] = FOO_NOT_SET;
  586. }
  587. inline TestOptimizedForSize::FooCase TestOptimizedForSize::foo_case() const {
  588. return TestOptimizedForSize::FooCase(_oneof_case_[0]);
  589. }
  590. // -------------------------------------------------------------------
  591. // TestRequiredOptimizedForSize
  592. // required int32 x = 1;
  593. inline bool TestRequiredOptimizedForSize::has_x() const {
  594. return (_has_bits_[0] & 0x00000001u) != 0;
  595. }
  596. inline void TestRequiredOptimizedForSize::set_has_x() {
  597. _has_bits_[0] |= 0x00000001u;
  598. }
  599. inline void TestRequiredOptimizedForSize::clear_has_x() {
  600. _has_bits_[0] &= ~0x00000001u;
  601. }
  602. inline void TestRequiredOptimizedForSize::clear_x() {
  603. x_ = 0;
  604. clear_has_x();
  605. }
  606. inline ::google::protobuf::int32 TestRequiredOptimizedForSize::x() const {
  607. // @@protoc_insertion_point(field_get:protobuf_unittest.TestRequiredOptimizedForSize.x)
  608. return x_;
  609. }
  610. inline void TestRequiredOptimizedForSize::set_x(::google::protobuf::int32 value) {
  611. set_has_x();
  612. x_ = value;
  613. // @@protoc_insertion_point(field_set:protobuf_unittest.TestRequiredOptimizedForSize.x)
  614. }
  615. // -------------------------------------------------------------------
  616. // TestOptionalOptimizedForSize
  617. // optional .protobuf_unittest.TestRequiredOptimizedForSize o = 1;
  618. inline bool TestOptionalOptimizedForSize::has_o() const {
  619. return (_has_bits_[0] & 0x00000001u) != 0;
  620. }
  621. inline void TestOptionalOptimizedForSize::set_has_o() {
  622. _has_bits_[0] |= 0x00000001u;
  623. }
  624. inline void TestOptionalOptimizedForSize::clear_has_o() {
  625. _has_bits_[0] &= ~0x00000001u;
  626. }
  627. inline void TestOptionalOptimizedForSize::clear_o() {
  628. if (o_ != NULL) o_->Clear();
  629. clear_has_o();
  630. }
  631. inline const ::protobuf_unittest::TestRequiredOptimizedForSize& TestOptionalOptimizedForSize::_internal_o() const {
  632. return *o_;
  633. }
  634. inline const ::protobuf_unittest::TestRequiredOptimizedForSize& TestOptionalOptimizedForSize::o() const {
  635. const ::protobuf_unittest::TestRequiredOptimizedForSize* p = o_;
  636. // @@protoc_insertion_point(field_get:protobuf_unittest.TestOptionalOptimizedForSize.o)
  637. return p != NULL ? *p : *reinterpret_cast<const ::protobuf_unittest::TestRequiredOptimizedForSize*>(
  638. &::protobuf_unittest::_TestRequiredOptimizedForSize_default_instance_);
  639. }
  640. inline ::protobuf_unittest::TestRequiredOptimizedForSize* TestOptionalOptimizedForSize::release_o() {
  641. // @@protoc_insertion_point(field_release:protobuf_unittest.TestOptionalOptimizedForSize.o)
  642. clear_has_o();
  643. ::protobuf_unittest::TestRequiredOptimizedForSize* temp = o_;
  644. o_ = NULL;
  645. return temp;
  646. }
  647. inline ::protobuf_unittest::TestRequiredOptimizedForSize* TestOptionalOptimizedForSize::mutable_o() {
  648. set_has_o();
  649. if (o_ == NULL) {
  650. auto* p = CreateMaybeMessage<::protobuf_unittest::TestRequiredOptimizedForSize>(GetArenaNoVirtual());
  651. o_ = p;
  652. }
  653. // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestOptionalOptimizedForSize.o)
  654. return o_;
  655. }
  656. inline void TestOptionalOptimizedForSize::set_allocated_o(::protobuf_unittest::TestRequiredOptimizedForSize* o) {
  657. ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  658. if (message_arena == NULL) {
  659. delete o_;
  660. }
  661. if (o) {
  662. ::google::protobuf::Arena* submessage_arena = NULL;
  663. if (message_arena != submessage_arena) {
  664. o = ::google::protobuf::internal::GetOwnedMessage(
  665. message_arena, o, submessage_arena);
  666. }
  667. set_has_o();
  668. } else {
  669. clear_has_o();
  670. }
  671. o_ = o;
  672. // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestOptionalOptimizedForSize.o)
  673. }
  674. #ifdef __GNUC__
  675. #pragma GCC diagnostic pop
  676. #endif // __GNUC__
  677. // -------------------------------------------------------------------
  678. // -------------------------------------------------------------------
  679. // @@protoc_insertion_point(namespace_scope)
  680. } // namespace protobuf_unittest
  681. // @@protoc_insertion_point(global_scope)
  682. #endif // PROTOBUF_INCLUDED_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto