1 /** 2 * Autogenerated by Thrift for src/module.thrift 3 * 4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 * @generated @nocommit 6 */ 7 #pragma once 8 9 #include <thrift/lib/cpp2/gen/module_types_h.h> 10 11 12 13 namespace apache { 14 namespace thrift { 15 namespace tag { 16 struct MyIntField; 17 struct MyStringField; 18 struct MyDataField; 19 struct myEnum; 20 struct oneway; 21 struct readonly; 22 struct idempotent; 23 struct myEnum; 24 struct myStruct; 25 struct myDataItem; 26 } // namespace tag 27 namespace detail { 28 #ifndef APACHE_THRIFT_ACCESSOR_MyIntField 29 #define APACHE_THRIFT_ACCESSOR_MyIntField 30 APACHE_THRIFT_DEFINE_ACCESSOR(MyIntField); 31 #endif 32 #ifndef APACHE_THRIFT_ACCESSOR_MyStringField 33 #define APACHE_THRIFT_ACCESSOR_MyStringField 34 APACHE_THRIFT_DEFINE_ACCESSOR(MyStringField); 35 #endif 36 #ifndef APACHE_THRIFT_ACCESSOR_MyDataField 37 #define APACHE_THRIFT_ACCESSOR_MyDataField 38 APACHE_THRIFT_DEFINE_ACCESSOR(MyDataField); 39 #endif 40 #ifndef APACHE_THRIFT_ACCESSOR_myEnum 41 #define APACHE_THRIFT_ACCESSOR_myEnum 42 APACHE_THRIFT_DEFINE_ACCESSOR(myEnum); 43 #endif 44 #ifndef APACHE_THRIFT_ACCESSOR_oneway 45 #define APACHE_THRIFT_ACCESSOR_oneway 46 APACHE_THRIFT_DEFINE_ACCESSOR(oneway); 47 #endif 48 #ifndef APACHE_THRIFT_ACCESSOR_readonly 49 #define APACHE_THRIFT_ACCESSOR_readonly 50 APACHE_THRIFT_DEFINE_ACCESSOR(readonly); 51 #endif 52 #ifndef APACHE_THRIFT_ACCESSOR_idempotent 53 #define APACHE_THRIFT_ACCESSOR_idempotent 54 APACHE_THRIFT_DEFINE_ACCESSOR(idempotent); 55 #endif 56 #ifndef APACHE_THRIFT_ACCESSOR_myEnum 57 #define APACHE_THRIFT_ACCESSOR_myEnum 58 APACHE_THRIFT_DEFINE_ACCESSOR(myEnum); 59 #endif 60 #ifndef APACHE_THRIFT_ACCESSOR_myStruct 61 #define APACHE_THRIFT_ACCESSOR_myStruct 62 APACHE_THRIFT_DEFINE_ACCESSOR(myStruct); 63 #endif 64 #ifndef APACHE_THRIFT_ACCESSOR_myDataItem 65 #define APACHE_THRIFT_ACCESSOR_myDataItem 66 APACHE_THRIFT_DEFINE_ACCESSOR(myDataItem); 67 #endif 68 } // namespace detail 69 } // namespace thrift 70 } // namespace apache 71 72 // BEGIN declare_enums 73 namespace cpp2 { 74 75 enum class MyEnum { 76 MyValue1 = 0, 77 MyValue2 = 1, 78 }; 79 80 81 82 83 } // cpp2 84 85 namespace std { 86 template<> struct hash<::cpp2::MyEnum> : 87 ::apache::thrift::detail::enum_hash<::cpp2::MyEnum> {}; 88 } // std 89 90 namespace apache { namespace thrift { 91 92 93 template <> struct TEnumDataStorage<::cpp2::MyEnum>; 94 95 template <> struct TEnumTraits<::cpp2::MyEnum> { 96 using type = ::cpp2::MyEnum; 97 98 static constexpr std::size_t const size = 2; 99 static folly::Range<type const*> const values; 100 static folly::Range<folly::StringPiece const*> const names; 101 102 static char const* findName(type value); 103 static bool findValue(char const* name, type* out); 104 105 static constexpr type min() { return type::MyValue1; } 106 static constexpr type max() { return type::MyValue2; } 107 }; 108 109 110 }} // apache::thrift 111 112 namespace cpp2 { 113 114 using _MyEnum_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<MyEnum>; 115 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]] 116 extern const _MyEnum_EnumMapFactory::ValuesToNamesMapType _MyEnum_VALUES_TO_NAMES; 117 [[deprecated("use apache::thrift::TEnumTraits")]] 118 extern const _MyEnum_EnumMapFactory::NamesToValuesMapType _MyEnum_NAMES_TO_VALUES; 119 120 } // cpp2 121 122 // END declare_enums 123 // BEGIN forward_declare 124 namespace cpp2 { 125 class MyDataItem; 126 class MyStruct; 127 class MyUnion; 128 } // cpp2 129 // END forward_declare 130 // BEGIN typedefs 131 132 // END typedefs 133 // BEGIN hash_and_equal_to 134 // END hash_and_equal_to 135 namespace cpp2 { 136 using ::apache::thrift::detail::operator!=; 137 using ::apache::thrift::detail::operator>; 138 using ::apache::thrift::detail::operator<=; 139 using ::apache::thrift::detail::operator>=; 140 } // cpp2 141 namespace cpp2 { 142 class MyDataItem final { 143 private: 144 friend struct ::apache::thrift::detail::st::struct_private_access; 145 146 // used by a static_assert in the corresponding source 147 static constexpr bool __fbthrift_cpp2_gen_json = false; 148 static constexpr bool __fbthrift_cpp2_gen_nimble = false; 149 static constexpr bool __fbthrift_cpp2_gen_has_thrift_uri = false; 150 151 void __fbthrift_clear(); 152 153 public: 154 using __fbthrift_cpp2_type = MyDataItem; 155 static constexpr bool __fbthrift_cpp2_is_union = 156 false; 157 158 159 public: 160 161 MyDataItem() { 162 } 163 // FragileConstructor for use in initialization lists only. 164 [[deprecated("This constructor is deprecated")]] 165 MyDataItem(apache::thrift::FragileConstructor); 166 167 MyDataItem(MyDataItem&&) = default; 168 169 MyDataItem(const MyDataItem&) = default; 170 171 172 MyDataItem& operator=(MyDataItem&&) = default; 173 174 MyDataItem& operator=(const MyDataItem&) = default; 175 176 public: 177 178 bool operator==(const MyDataItem&) const; 179 bool operator<(const MyDataItem&) const; 180 181 template <class Protocol_> 182 uint32_t read(Protocol_* iprot); 183 template <class Protocol_> 184 uint32_t serializedSize(Protocol_ const* prot_) const; 185 template <class Protocol_> 186 uint32_t serializedSizeZC(Protocol_ const* prot_) const; 187 template <class Protocol_> 188 uint32_t write(Protocol_* prot_) const; 189 190 private: 191 template <class Protocol_> 192 void readNoXfer(Protocol_* iprot); 193 194 friend class ::apache::thrift::Cpp2Ops<MyDataItem>; 195 friend void swap(MyDataItem& a, MyDataItem& b); 196 }; 197 198 template <class Protocol_> 199 uint32_t MyDataItem::read(Protocol_* iprot) { 200 auto _xferStart = iprot->getCursorPosition(); 201 readNoXfer(iprot); 202 return iprot->getCursorPosition() - _xferStart; 203 } 204 205 } // cpp2 206 namespace cpp2 { 207 class MyStruct final { 208 private: 209 friend struct ::apache::thrift::detail::st::struct_private_access; 210 211 // used by a static_assert in the corresponding source 212 static constexpr bool __fbthrift_cpp2_gen_json = false; 213 static constexpr bool __fbthrift_cpp2_gen_nimble = false; 214 static constexpr bool __fbthrift_cpp2_gen_has_thrift_uri = false; 215 216 void __fbthrift_clear(); 217 218 public: 219 using __fbthrift_cpp2_type = MyStruct; 220 static constexpr bool __fbthrift_cpp2_is_union = 221 false; 222 223 224 public: 225 226 MyStruct(); 227 228 // FragileConstructor for use in initialization lists only. 229 [[deprecated("This constructor is deprecated")]] 230 MyStruct(apache::thrift::FragileConstructor, ::std::int64_t MyIntField__arg, ::std::string MyStringField__arg, ::cpp2::MyDataItem MyDataField__arg, ::cpp2::MyEnum myEnum__arg, bool oneway__arg, bool readonly__arg, bool idempotent__arg); 231 232 MyStruct(MyStruct&&) noexcept; 233 234 MyStruct(const MyStruct& src); 235 236 237 MyStruct& operator=(MyStruct&&) noexcept; 238 MyStruct& operator=(const MyStruct& src); 239 240 ~MyStruct(); 241 242 private: 243 ::std::int64_t __fbthrift_field_MyIntField; 244 private: 245 ::std::string __fbthrift_field_MyStringField; 246 private: 247 ::cpp2::MyDataItem __fbthrift_field_MyDataField; 248 private: 249 ::cpp2::MyEnum __fbthrift_field_myEnum; 250 private: 251 bool __fbthrift_field_oneway; 252 private: 253 bool __fbthrift_field_readonly; 254 private: 255 bool __fbthrift_field_idempotent; 256 private: 257 apache::thrift::detail::isset_bitset<7, false> __isset; 258 259 public: 260 261 bool operator==(const MyStruct&) const; 262 bool operator<(const MyStruct&) const; 263 264 template <typename..., typename T = ::std::int64_t> 265 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyIntField_ref() const& { 266 return {this->__fbthrift_field_MyIntField, __isset.at(0), __isset.bit(0)}; 267 } 268 269 template <typename..., typename T = ::std::int64_t> 270 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyIntField_ref() const&& { 271 return {static_cast<const T&&>(this->__fbthrift_field_MyIntField), __isset.at(0), __isset.bit(0)}; 272 } 273 274 template <typename..., typename T = ::std::int64_t> 275 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyIntField_ref() & { 276 return {this->__fbthrift_field_MyIntField, __isset.at(0), __isset.bit(0)}; 277 } 278 279 template <typename..., typename T = ::std::int64_t> 280 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyIntField_ref() && { 281 return {static_cast<T&&>(this->__fbthrift_field_MyIntField), __isset.at(0), __isset.bit(0)}; 282 } 283 284 template <typename..., typename T = ::std::int64_t> 285 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyIntField() const& { 286 return {this->__fbthrift_field_MyIntField, __isset.at(0), __isset.bit(0)}; 287 } 288 289 template <typename..., typename T = ::std::int64_t> 290 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyIntField() const&& { 291 return {static_cast<const T&&>(this->__fbthrift_field_MyIntField), __isset.at(0), __isset.bit(0)}; 292 } 293 294 template <typename..., typename T = ::std::int64_t> 295 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyIntField() & { 296 return {this->__fbthrift_field_MyIntField, __isset.at(0), __isset.bit(0)}; 297 } 298 299 template <typename..., typename T = ::std::int64_t> 300 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyIntField() && { 301 return {static_cast<T&&>(this->__fbthrift_field_MyIntField), __isset.at(0), __isset.bit(0)}; 302 } 303 304 template <typename..., typename T = ::std::string> 305 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyStringField_ref() const& { 306 return {this->__fbthrift_field_MyStringField, __isset.at(1), __isset.bit(1)}; 307 } 308 309 template <typename..., typename T = ::std::string> 310 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyStringField_ref() const&& { 311 return {static_cast<const T&&>(this->__fbthrift_field_MyStringField), __isset.at(1), __isset.bit(1)}; 312 } 313 314 template <typename..., typename T = ::std::string> 315 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyStringField_ref() & { 316 return {this->__fbthrift_field_MyStringField, __isset.at(1), __isset.bit(1)}; 317 } 318 319 template <typename..., typename T = ::std::string> 320 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyStringField_ref() && { 321 return {static_cast<T&&>(this->__fbthrift_field_MyStringField), __isset.at(1), __isset.bit(1)}; 322 } 323 324 template <typename..., typename T = ::std::string> 325 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyStringField() const& { 326 return {this->__fbthrift_field_MyStringField, __isset.at(1), __isset.bit(1)}; 327 } 328 329 template <typename..., typename T = ::std::string> 330 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyStringField() const&& { 331 return {static_cast<const T&&>(this->__fbthrift_field_MyStringField), __isset.at(1), __isset.bit(1)}; 332 } 333 334 template <typename..., typename T = ::std::string> 335 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyStringField() & { 336 return {this->__fbthrift_field_MyStringField, __isset.at(1), __isset.bit(1)}; 337 } 338 339 template <typename..., typename T = ::std::string> 340 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyStringField() && { 341 return {static_cast<T&&>(this->__fbthrift_field_MyStringField), __isset.at(1), __isset.bit(1)}; 342 } 343 344 template <typename..., typename T = ::cpp2::MyDataItem> 345 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyDataField_ref() const& { 346 return {this->__fbthrift_field_MyDataField, __isset.at(2), __isset.bit(2)}; 347 } 348 349 template <typename..., typename T = ::cpp2::MyDataItem> 350 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyDataField_ref() const&& { 351 return {static_cast<const T&&>(this->__fbthrift_field_MyDataField), __isset.at(2), __isset.bit(2)}; 352 } 353 354 template <typename..., typename T = ::cpp2::MyDataItem> 355 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyDataField_ref() & { 356 return {this->__fbthrift_field_MyDataField, __isset.at(2), __isset.bit(2)}; 357 } 358 359 template <typename..., typename T = ::cpp2::MyDataItem> 360 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyDataField_ref() && { 361 return {static_cast<T&&>(this->__fbthrift_field_MyDataField), __isset.at(2), __isset.bit(2)}; 362 } 363 364 template <typename..., typename T = ::cpp2::MyDataItem> 365 FOLLY_ERASE ::apache::thrift::field_ref<const T&> MyDataField() const& { 366 return {this->__fbthrift_field_MyDataField, __isset.at(2), __isset.bit(2)}; 367 } 368 369 template <typename..., typename T = ::cpp2::MyDataItem> 370 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> MyDataField() const&& { 371 return {static_cast<const T&&>(this->__fbthrift_field_MyDataField), __isset.at(2), __isset.bit(2)}; 372 } 373 374 template <typename..., typename T = ::cpp2::MyDataItem> 375 FOLLY_ERASE ::apache::thrift::field_ref<T&> MyDataField() & { 376 return {this->__fbthrift_field_MyDataField, __isset.at(2), __isset.bit(2)}; 377 } 378 379 template <typename..., typename T = ::cpp2::MyDataItem> 380 FOLLY_ERASE ::apache::thrift::field_ref<T&&> MyDataField() && { 381 return {static_cast<T&&>(this->__fbthrift_field_MyDataField), __isset.at(2), __isset.bit(2)}; 382 } 383 384 template <typename..., typename T = ::cpp2::MyEnum> 385 FOLLY_ERASE ::apache::thrift::field_ref<const T&> myEnum_ref() const& { 386 return {this->__fbthrift_field_myEnum, __isset.at(3), __isset.bit(3)}; 387 } 388 389 template <typename..., typename T = ::cpp2::MyEnum> 390 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> myEnum_ref() const&& { 391 return {static_cast<const T&&>(this->__fbthrift_field_myEnum), __isset.at(3), __isset.bit(3)}; 392 } 393 394 template <typename..., typename T = ::cpp2::MyEnum> 395 FOLLY_ERASE ::apache::thrift::field_ref<T&> myEnum_ref() & { 396 return {this->__fbthrift_field_myEnum, __isset.at(3), __isset.bit(3)}; 397 } 398 399 template <typename..., typename T = ::cpp2::MyEnum> 400 FOLLY_ERASE ::apache::thrift::field_ref<T&&> myEnum_ref() && { 401 return {static_cast<T&&>(this->__fbthrift_field_myEnum), __isset.at(3), __isset.bit(3)}; 402 } 403 404 template <typename..., typename T = ::cpp2::MyEnum> 405 FOLLY_ERASE ::apache::thrift::field_ref<const T&> myEnum() const& { 406 return {this->__fbthrift_field_myEnum, __isset.at(3), __isset.bit(3)}; 407 } 408 409 template <typename..., typename T = ::cpp2::MyEnum> 410 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> myEnum() const&& { 411 return {static_cast<const T&&>(this->__fbthrift_field_myEnum), __isset.at(3), __isset.bit(3)}; 412 } 413 414 template <typename..., typename T = ::cpp2::MyEnum> 415 FOLLY_ERASE ::apache::thrift::field_ref<T&> myEnum() & { 416 return {this->__fbthrift_field_myEnum, __isset.at(3), __isset.bit(3)}; 417 } 418 419 template <typename..., typename T = ::cpp2::MyEnum> 420 FOLLY_ERASE ::apache::thrift::field_ref<T&&> myEnum() && { 421 return {static_cast<T&&>(this->__fbthrift_field_myEnum), __isset.at(3), __isset.bit(3)}; 422 } 423 424 template <typename..., typename T = bool> 425 FOLLY_ERASE ::apache::thrift::field_ref<const T&> oneway_ref() const& { 426 return {this->__fbthrift_field_oneway, __isset.at(4), __isset.bit(4)}; 427 } 428 429 template <typename..., typename T = bool> 430 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> oneway_ref() const&& { 431 return {static_cast<const T&&>(this->__fbthrift_field_oneway), __isset.at(4), __isset.bit(4)}; 432 } 433 434 template <typename..., typename T = bool> 435 FOLLY_ERASE ::apache::thrift::field_ref<T&> oneway_ref() & { 436 return {this->__fbthrift_field_oneway, __isset.at(4), __isset.bit(4)}; 437 } 438 439 template <typename..., typename T = bool> 440 FOLLY_ERASE ::apache::thrift::field_ref<T&&> oneway_ref() && { 441 return {static_cast<T&&>(this->__fbthrift_field_oneway), __isset.at(4), __isset.bit(4)}; 442 } 443 444 template <typename..., typename T = bool> 445 FOLLY_ERASE ::apache::thrift::field_ref<const T&> oneway() const& { 446 return {this->__fbthrift_field_oneway, __isset.at(4), __isset.bit(4)}; 447 } 448 449 template <typename..., typename T = bool> 450 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> oneway() const&& { 451 return {static_cast<const T&&>(this->__fbthrift_field_oneway), __isset.at(4), __isset.bit(4)}; 452 } 453 454 template <typename..., typename T = bool> 455 FOLLY_ERASE ::apache::thrift::field_ref<T&> oneway() & { 456 return {this->__fbthrift_field_oneway, __isset.at(4), __isset.bit(4)}; 457 } 458 459 template <typename..., typename T = bool> 460 FOLLY_ERASE ::apache::thrift::field_ref<T&&> oneway() && { 461 return {static_cast<T&&>(this->__fbthrift_field_oneway), __isset.at(4), __isset.bit(4)}; 462 } 463 464 template <typename..., typename T = bool> 465 FOLLY_ERASE ::apache::thrift::field_ref<const T&> readonly_ref() const& { 466 return {this->__fbthrift_field_readonly, __isset.at(5), __isset.bit(5)}; 467 } 468 469 template <typename..., typename T = bool> 470 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> readonly_ref() const&& { 471 return {static_cast<const T&&>(this->__fbthrift_field_readonly), __isset.at(5), __isset.bit(5)}; 472 } 473 474 template <typename..., typename T = bool> 475 FOLLY_ERASE ::apache::thrift::field_ref<T&> readonly_ref() & { 476 return {this->__fbthrift_field_readonly, __isset.at(5), __isset.bit(5)}; 477 } 478 479 template <typename..., typename T = bool> 480 FOLLY_ERASE ::apache::thrift::field_ref<T&&> readonly_ref() && { 481 return {static_cast<T&&>(this->__fbthrift_field_readonly), __isset.at(5), __isset.bit(5)}; 482 } 483 484 template <typename..., typename T = bool> 485 FOLLY_ERASE ::apache::thrift::field_ref<const T&> readonly() const& { 486 return {this->__fbthrift_field_readonly, __isset.at(5), __isset.bit(5)}; 487 } 488 489 template <typename..., typename T = bool> 490 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> readonly() const&& { 491 return {static_cast<const T&&>(this->__fbthrift_field_readonly), __isset.at(5), __isset.bit(5)}; 492 } 493 494 template <typename..., typename T = bool> 495 FOLLY_ERASE ::apache::thrift::field_ref<T&> readonly() & { 496 return {this->__fbthrift_field_readonly, __isset.at(5), __isset.bit(5)}; 497 } 498 499 template <typename..., typename T = bool> 500 FOLLY_ERASE ::apache::thrift::field_ref<T&&> readonly() && { 501 return {static_cast<T&&>(this->__fbthrift_field_readonly), __isset.at(5), __isset.bit(5)}; 502 } 503 504 template <typename..., typename T = bool> 505 FOLLY_ERASE ::apache::thrift::field_ref<const T&> idempotent_ref() const& { 506 return {this->__fbthrift_field_idempotent, __isset.at(6), __isset.bit(6)}; 507 } 508 509 template <typename..., typename T = bool> 510 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> idempotent_ref() const&& { 511 return {static_cast<const T&&>(this->__fbthrift_field_idempotent), __isset.at(6), __isset.bit(6)}; 512 } 513 514 template <typename..., typename T = bool> 515 FOLLY_ERASE ::apache::thrift::field_ref<T&> idempotent_ref() & { 516 return {this->__fbthrift_field_idempotent, __isset.at(6), __isset.bit(6)}; 517 } 518 519 template <typename..., typename T = bool> 520 FOLLY_ERASE ::apache::thrift::field_ref<T&&> idempotent_ref() && { 521 return {static_cast<T&&>(this->__fbthrift_field_idempotent), __isset.at(6), __isset.bit(6)}; 522 } 523 524 template <typename..., typename T = bool> 525 FOLLY_ERASE ::apache::thrift::field_ref<const T&> idempotent() const& { 526 return {this->__fbthrift_field_idempotent, __isset.at(6), __isset.bit(6)}; 527 } 528 529 template <typename..., typename T = bool> 530 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> idempotent() const&& { 531 return {static_cast<const T&&>(this->__fbthrift_field_idempotent), __isset.at(6), __isset.bit(6)}; 532 } 533 534 template <typename..., typename T = bool> 535 FOLLY_ERASE ::apache::thrift::field_ref<T&> idempotent() & { 536 return {this->__fbthrift_field_idempotent, __isset.at(6), __isset.bit(6)}; 537 } 538 539 template <typename..., typename T = bool> 540 FOLLY_ERASE ::apache::thrift::field_ref<T&&> idempotent() && { 541 return {static_cast<T&&>(this->__fbthrift_field_idempotent), __isset.at(6), __isset.bit(6)}; 542 } 543 544 ::std::int64_t get_MyIntField() const { 545 return __fbthrift_field_MyIntField; 546 } 547 548 [[deprecated("Use `FOO.MyIntField_ref() = BAR;` instead of `FOO.set_MyIntField(BAR);`")]] 549 ::std::int64_t& set_MyIntField(::std::int64_t MyIntField_) { 550 MyIntField_ref() = MyIntField_; 551 return __fbthrift_field_MyIntField; 552 } 553 554 const ::std::string& get_MyStringField() const& { 555 return __fbthrift_field_MyStringField; 556 } 557 558 ::std::string get_MyStringField() && { 559 return std::move(__fbthrift_field_MyStringField); 560 } 561 562 template <typename T_MyStruct_MyStringField_struct_setter = ::std::string> 563 [[deprecated("Use `FOO.MyStringField_ref() = BAR;` instead of `FOO.set_MyStringField(BAR);`")]] 564 ::std::string& set_MyStringField(T_MyStruct_MyStringField_struct_setter&& MyStringField_) { 565 MyStringField_ref() = std::forward<T_MyStruct_MyStringField_struct_setter>(MyStringField_); 566 return __fbthrift_field_MyStringField; 567 } 568 const ::cpp2::MyDataItem& get_MyDataField() const&; 569 ::cpp2::MyDataItem get_MyDataField() &&; 570 571 template <typename T_MyStruct_MyDataField_struct_setter = ::cpp2::MyDataItem> 572 [[deprecated("Use `FOO.MyDataField_ref() = BAR;` instead of `FOO.set_MyDataField(BAR);`")]] 573 ::cpp2::MyDataItem& set_MyDataField(T_MyStruct_MyDataField_struct_setter&& MyDataField_) { 574 MyDataField_ref() = std::forward<T_MyStruct_MyDataField_struct_setter>(MyDataField_); 575 return __fbthrift_field_MyDataField; 576 } 577 578 ::cpp2::MyEnum get_myEnum() const { 579 return __fbthrift_field_myEnum; 580 } 581 582 [[deprecated("Use `FOO.myEnum_ref() = BAR;` instead of `FOO.set_myEnum(BAR);`")]] 583 ::cpp2::MyEnum& set_myEnum(::cpp2::MyEnum myEnum_) { 584 myEnum_ref() = myEnum_; 585 return __fbthrift_field_myEnum; 586 } 587 588 bool get_oneway() const { 589 return __fbthrift_field_oneway; 590 } 591 592 [[deprecated("Use `FOO.oneway_ref() = BAR;` instead of `FOO.set_oneway(BAR);`")]] 593 bool& set_oneway(bool oneway_) { 594 oneway_ref() = oneway_; 595 return __fbthrift_field_oneway; 596 } 597 598 bool get_readonly() const { 599 return __fbthrift_field_readonly; 600 } 601 602 [[deprecated("Use `FOO.readonly_ref() = BAR;` instead of `FOO.set_readonly(BAR);`")]] 603 bool& set_readonly(bool readonly_) { 604 readonly_ref() = readonly_; 605 return __fbthrift_field_readonly; 606 } 607 608 bool get_idempotent() const { 609 return __fbthrift_field_idempotent; 610 } 611 612 [[deprecated("Use `FOO.idempotent_ref() = BAR;` instead of `FOO.set_idempotent(BAR);`")]] 613 bool& set_idempotent(bool idempotent_) { 614 idempotent_ref() = idempotent_; 615 return __fbthrift_field_idempotent; 616 } 617 618 template <class Protocol_> 619 uint32_t read(Protocol_* iprot); 620 template <class Protocol_> 621 uint32_t serializedSize(Protocol_ const* prot_) const; 622 template <class Protocol_> 623 uint32_t serializedSizeZC(Protocol_ const* prot_) const; 624 template <class Protocol_> 625 uint32_t write(Protocol_* prot_) const; 626 627 private: 628 template <class Protocol_> 629 void readNoXfer(Protocol_* iprot); 630 631 friend class ::apache::thrift::Cpp2Ops<MyStruct>; 632 friend void swap(MyStruct& a, MyStruct& b); 633 }; 634 635 template <class Protocol_> 636 uint32_t MyStruct::read(Protocol_* iprot) { 637 auto _xferStart = iprot->getCursorPosition(); 638 readNoXfer(iprot); 639 return iprot->getCursorPosition() - _xferStart; 640 } 641 642 } // cpp2 643 namespace cpp2 { 644 class MyUnion final { 645 private: 646 friend struct ::apache::thrift::detail::st::struct_private_access; 647 648 // used by a static_assert in the corresponding source 649 static constexpr bool __fbthrift_cpp2_gen_json = false; 650 static constexpr bool __fbthrift_cpp2_gen_nimble = false; 651 static constexpr bool __fbthrift_cpp2_gen_has_thrift_uri = false; 652 653 void __fbthrift_clear(); 654 655 public: 656 using __fbthrift_cpp2_type = MyUnion; 657 static constexpr bool __fbthrift_cpp2_is_union = 658 true; 659 660 661 public: 662 enum Type : int { 663 __EMPTY__ = 0, 664 myEnum = 1, 665 myStruct = 2, 666 myDataItem = 3, 667 } ; 668 669 MyUnion() 670 : type_(Type::__EMPTY__) {} 671 672 MyUnion(MyUnion&& rhs) noexcept 673 : type_(Type::__EMPTY__) { 674 if (this == &rhs) { return; } 675 if (rhs.type_ == Type::__EMPTY__) { return; } 676 switch (rhs.type_) { 677 case Type::myEnum: 678 { 679 set_myEnum(std::move(rhs.value_.myEnum)); 680 break; 681 } 682 case Type::myStruct: 683 { 684 set_myStruct(std::move(rhs.value_.myStruct)); 685 break; 686 } 687 case Type::myDataItem: 688 { 689 set_myDataItem(std::move(rhs.value_.myDataItem)); 690 break; 691 } 692 default: 693 { 694 assert(false); 695 break; 696 } 697 } 698 apache::thrift::clear(rhs); 699 } 700 701 MyUnion(const MyUnion& rhs) 702 : type_(Type::__EMPTY__) { 703 if (this == &rhs) { return; } 704 if (rhs.type_ == Type::__EMPTY__) { return; } 705 switch (rhs.type_) { 706 case Type::myEnum: 707 { 708 set_myEnum(rhs.value_.myEnum); 709 break; 710 } 711 case Type::myStruct: 712 { 713 set_myStruct(rhs.value_.myStruct); 714 break; 715 } 716 case Type::myDataItem: 717 { 718 set_myDataItem(rhs.value_.myDataItem); 719 break; 720 } 721 default: 722 { 723 assert(false); 724 break; 725 } 726 } 727 } 728 729 MyUnion& operator=(MyUnion&& rhs) noexcept { 730 if (this == &rhs) { return *this; } 731 __fbthrift_clear(); 732 if (rhs.type_ == Type::__EMPTY__) { return *this; } 733 switch (rhs.type_) { 734 case Type::myEnum: 735 { 736 set_myEnum(std::move(rhs.value_.myEnum)); 737 break; 738 } 739 case Type::myStruct: 740 { 741 set_myStruct(std::move(rhs.value_.myStruct)); 742 break; 743 } 744 case Type::myDataItem: 745 { 746 set_myDataItem(std::move(rhs.value_.myDataItem)); 747 break; 748 } 749 default: 750 { 751 assert(false); 752 break; 753 } 754 } 755 apache::thrift::clear(rhs); 756 return *this; 757 } 758 759 MyUnion& operator=(const MyUnion& rhs) { 760 if (this == &rhs) { return *this; } 761 __fbthrift_clear(); 762 if (rhs.type_ == Type::__EMPTY__) { return *this; } 763 switch (rhs.type_) { 764 case Type::myEnum: 765 { 766 set_myEnum(rhs.value_.myEnum); 767 break; 768 } 769 case Type::myStruct: 770 { 771 set_myStruct(rhs.value_.myStruct); 772 break; 773 } 774 case Type::myDataItem: 775 { 776 set_myDataItem(rhs.value_.myDataItem); 777 break; 778 } 779 default: 780 { 781 assert(false); 782 break; 783 } 784 } 785 return *this; 786 } 787 788 ~MyUnion() { 789 apache::thrift::clear(*this); 790 } 791 union storage_type { 792 ::cpp2::MyEnum myEnum; 793 ::cpp2::MyStruct myStruct; 794 ::cpp2::MyDataItem myDataItem; 795 796 storage_type() {} 797 ~storage_type() {} 798 } ; 799 800 bool operator==(const MyUnion&) const; 801 bool operator<(const MyUnion&) const; 802 803 ::cpp2::MyEnum& set_myEnum(::cpp2::MyEnum t = ::cpp2::MyEnum()) { 804 __fbthrift_clear(); 805 type_ = Type::myEnum; 806 ::new (std::addressof(value_.myEnum)) ::cpp2::MyEnum(t); 807 return value_.myEnum; 808 } 809 810 ::cpp2::MyStruct& set_myStruct(::cpp2::MyStruct const &t) { 811 __fbthrift_clear(); 812 type_ = Type::myStruct; 813 ::new (std::addressof(value_.myStruct)) ::cpp2::MyStruct(t); 814 return value_.myStruct; 815 } 816 817 ::cpp2::MyStruct& set_myStruct(::cpp2::MyStruct&& t) { 818 __fbthrift_clear(); 819 type_ = Type::myStruct; 820 ::new (std::addressof(value_.myStruct)) ::cpp2::MyStruct(std::move(t)); 821 return value_.myStruct; 822 } 823 824 template<typename... T, typename = ::apache::thrift::safe_overload_t<::cpp2::MyStruct, T...>> ::cpp2::MyStruct& set_myStruct(T&&... t) { 825 __fbthrift_clear(); 826 type_ = Type::myStruct; 827 ::new (std::addressof(value_.myStruct)) ::cpp2::MyStruct(std::forward<T>(t)...); 828 return value_.myStruct; 829 } 830 831 ::cpp2::MyDataItem& set_myDataItem(::cpp2::MyDataItem const &t) { 832 __fbthrift_clear(); 833 type_ = Type::myDataItem; 834 ::new (std::addressof(value_.myDataItem)) ::cpp2::MyDataItem(t); 835 return value_.myDataItem; 836 } 837 838 ::cpp2::MyDataItem& set_myDataItem(::cpp2::MyDataItem&& t) { 839 __fbthrift_clear(); 840 type_ = Type::myDataItem; 841 ::new (std::addressof(value_.myDataItem)) ::cpp2::MyDataItem(std::move(t)); 842 return value_.myDataItem; 843 } 844 845 template<typename... T, typename = ::apache::thrift::safe_overload_t<::cpp2::MyDataItem, T...>> ::cpp2::MyDataItem& set_myDataItem(T&&... t) { 846 __fbthrift_clear(); 847 type_ = Type::myDataItem; 848 ::new (std::addressof(value_.myDataItem)) ::cpp2::MyDataItem(std::forward<T>(t)...); 849 return value_.myDataItem; 850 } 851 852 ::cpp2::MyEnum const& get_myEnum() const { 853 if (type_ != Type::myEnum) { 854 ::apache::thrift::detail::throw_on_bad_field_access(); 855 } 856 return value_.myEnum; 857 } 858 859 ::cpp2::MyStruct const& get_myStruct() const { 860 if (type_ != Type::myStruct) { 861 ::apache::thrift::detail::throw_on_bad_field_access(); 862 } 863 return value_.myStruct; 864 } 865 866 ::cpp2::MyDataItem const& get_myDataItem() const { 867 if (type_ != Type::myDataItem) { 868 ::apache::thrift::detail::throw_on_bad_field_access(); 869 } 870 return value_.myDataItem; 871 } 872 873 ::cpp2::MyEnum& mutable_myEnum() { 874 assert(type_ == Type::myEnum); 875 return value_.myEnum; 876 } 877 878 ::cpp2::MyStruct& mutable_myStruct() { 879 assert(type_ == Type::myStruct); 880 return value_.myStruct; 881 } 882 883 ::cpp2::MyDataItem& mutable_myDataItem() { 884 assert(type_ == Type::myDataItem); 885 return value_.myDataItem; 886 } 887 888 ::cpp2::MyEnum move_myEnum() { 889 assert(type_ == Type::myEnum); 890 return std::move(value_.myEnum); 891 } 892 893 ::cpp2::MyStruct move_myStruct() { 894 assert(type_ == Type::myStruct); 895 return std::move(value_.myStruct); 896 } 897 898 ::cpp2::MyDataItem move_myDataItem() { 899 assert(type_ == Type::myDataItem); 900 return std::move(value_.myDataItem); 901 } 902 903 template <typename..., typename T = ::cpp2::MyEnum> 904 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&> myEnum_ref() const& { 905 return {value_.myEnum, type_, myEnum, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 906 } 907 908 template <typename..., typename T = ::cpp2::MyEnum> 909 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&&> myEnum_ref() const&& { 910 return {std::move(value_.myEnum), type_, myEnum, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 911 } 912 913 template <typename..., typename T = ::cpp2::MyEnum> 914 FOLLY_ERASE ::apache::thrift::union_field_ref<T&> myEnum_ref() & { 915 return {value_.myEnum, type_, myEnum, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 916 } 917 918 template <typename..., typename T = ::cpp2::MyEnum> 919 FOLLY_ERASE ::apache::thrift::union_field_ref<T&&> myEnum_ref() && { 920 return {std::move(value_.myEnum), type_, myEnum, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 921 } 922 template <typename..., typename T = ::cpp2::MyStruct> 923 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&> myStruct_ref() const& { 924 return {value_.myStruct, type_, myStruct, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 925 } 926 927 template <typename..., typename T = ::cpp2::MyStruct> 928 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&&> myStruct_ref() const&& { 929 return {std::move(value_.myStruct), type_, myStruct, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 930 } 931 932 template <typename..., typename T = ::cpp2::MyStruct> 933 FOLLY_ERASE ::apache::thrift::union_field_ref<T&> myStruct_ref() & { 934 return {value_.myStruct, type_, myStruct, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 935 } 936 937 template <typename..., typename T = ::cpp2::MyStruct> 938 FOLLY_ERASE ::apache::thrift::union_field_ref<T&&> myStruct_ref() && { 939 return {std::move(value_.myStruct), type_, myStruct, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 940 } 941 template <typename..., typename T = ::cpp2::MyDataItem> 942 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&> myDataItem_ref() const& { 943 return {value_.myDataItem, type_, myDataItem, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 944 } 945 946 template <typename..., typename T = ::cpp2::MyDataItem> 947 FOLLY_ERASE ::apache::thrift::union_field_ref<const T&&> myDataItem_ref() const&& { 948 return {std::move(value_.myDataItem), type_, myDataItem, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 949 } 950 951 template <typename..., typename T = ::cpp2::MyDataItem> 952 FOLLY_ERASE ::apache::thrift::union_field_ref<T&> myDataItem_ref() & { 953 return {value_.myDataItem, type_, myDataItem, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 954 } 955 956 template <typename..., typename T = ::cpp2::MyDataItem> 957 FOLLY_ERASE ::apache::thrift::union_field_ref<T&&> myDataItem_ref() && { 958 return {std::move(value_.myDataItem), type_, myDataItem, this, ::apache::thrift::detail::union_field_ref_owner_vtable_for<decltype(*this)>}; 959 } 960 Type getType() const { return static_cast<Type>(type_); } 961 962 template <class Protocol_> 963 uint32_t read(Protocol_* iprot); 964 template <class Protocol_> 965 uint32_t serializedSize(Protocol_ const* prot_) const; 966 template <class Protocol_> 967 uint32_t serializedSizeZC(Protocol_ const* prot_) const; 968 template <class Protocol_> 969 uint32_t write(Protocol_* prot_) const; 970 protected: 971 template <class T> 972 void destruct(T &val) { 973 (&val)->~T(); 974 } 975 976 storage_type value_; 977 std::underlying_type_t<Type> type_; 978 979 private: 980 template <class Protocol_> 981 void readNoXfer(Protocol_* iprot); 982 983 friend class ::apache::thrift::Cpp2Ops<MyUnion>; 984 friend void swap(MyUnion& a, MyUnion& b); 985 }; 986 987 template <class Protocol_> 988 uint32_t MyUnion::read(Protocol_* iprot) { 989 auto _xferStart = iprot->getCursorPosition(); 990 readNoXfer(iprot); 991 return iprot->getCursorPosition() - _xferStart; 992 } 993 994 } // cpp2 995 996 namespace apache { namespace thrift { 997 998 template <> struct TEnumDataStorage<::cpp2::MyUnion::Type>; 999 1000 template <> struct TEnumTraits<::cpp2::MyUnion::Type> { 1001 using type = ::cpp2::MyUnion::Type; 1002 1003 static constexpr std::size_t const size = 3; 1004 static folly::Range<type const*> const values; 1005 static folly::Range<folly::StringPiece const*> const names; 1006 1007 static char const* findName(type value); 1008 static bool findValue(char const* name, type* out); 1009 1010 }; 1011 }} // apache::thrift 1012