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 #include "thrift/compiler/test/fixtures/basic-stack-arguments/gen-cpp2/module_types.h"
8 #include "thrift/compiler/test/fixtures/basic-stack-arguments/gen-cpp2/module_types.tcc"
9 
10 #include <thrift/lib/cpp2/gen/module_types_cpp.h>
11 
12 #include "thrift/compiler/test/fixtures/basic-stack-arguments/gen-cpp2/module_data.h"
13 
14 
15 namespace apache { namespace thrift {
16 
17 constexpr std::size_t const TEnumTraits<::cpp2::MyEnum>::size;
18 folly::Range<::cpp2::MyEnum const*> const TEnumTraits<::cpp2::MyEnum>::values = folly::range(TEnumDataStorage<::cpp2::MyEnum>::values);
19 folly::Range<folly::StringPiece const*> const TEnumTraits<::cpp2::MyEnum>::names = folly::range(TEnumDataStorage<::cpp2::MyEnum>::names);
20 
findName(type value)21 char const* TEnumTraits<::cpp2::MyEnum>::findName(type value) {
22   using factory = ::cpp2::_MyEnum_EnumMapFactory;
23   static folly::Indestructible<factory::ValuesToNamesMapType> const map{
24       factory::makeValuesToNamesMap()};
25   auto found = map->find(value);
26   return found == map->end() ? nullptr : found->second;
27 }
28 
findValue(char const * name,type * out)29 bool TEnumTraits<::cpp2::MyEnum>::findValue(char const* name, type* out) {
30   using factory = ::cpp2::_MyEnum_EnumMapFactory;
31   static folly::Indestructible<factory::NamesToValuesMapType> const map{
32       factory::makeNamesToValuesMap()};
33   auto found = map->find(name);
34   return found == map->end() ? false : (*out = found->second, true);
35 }
36 
37 }} // apache::thrift
38 
39 namespace cpp2 {
40 FOLLY_PUSH_WARNING
41 FOLLY_GNU_DISABLE_WARNING("-Wdeprecated-declarations")
42 const _MyEnum_EnumMapFactory::ValuesToNamesMapType _MyEnum_VALUES_TO_NAMES = _MyEnum_EnumMapFactory::makeValuesToNamesMap();
43 const _MyEnum_EnumMapFactory::NamesToValuesMapType _MyEnum_NAMES_TO_VALUES = _MyEnum_EnumMapFactory::makeNamesToValuesMap();
44 FOLLY_POP_WARNING
45 
46 } // cpp2
47 
48 namespace apache {
49 namespace thrift {
50 namespace detail {
51 
translateFieldName(folly::StringPiece _fname,int16_t & fid,apache::thrift::protocol::TType & _ftype)52 void TccStructTraits<::cpp2::MyStruct>::translateFieldName(
53     folly::StringPiece _fname,
54     int16_t& fid,
55     apache::thrift::protocol::TType& _ftype) noexcept {
56   using data = apache::thrift::TStructDataStorage<::cpp2::MyStruct>;
57   static const st::translate_field_name_table table{
58       data::fields_size,
59       data::fields_names.data(),
60       data::fields_ids.data(),
61       data::fields_types.data()};
62   st::translate_field_name(_fname, fid, _ftype, table);
63 }
64 
65 } // namespace detail
66 } // namespace thrift
67 } // namespace apache
68 
69 namespace cpp2 {
70 
71 MyStruct::MyStruct(const MyStruct&) = default;
72 MyStruct& MyStruct::operator=(const MyStruct&) = default;
MyStruct(MyStruct && other)73 MyStruct::MyStruct(MyStruct&& other) noexcept  :
74     __fbthrift_field_MyIntField(std::move(other.__fbthrift_field_MyIntField)),
75     __fbthrift_field_MyStringField(std::move(other.__fbthrift_field_MyStringField)),
76     __isset(other.__isset) {
77 }
78 
operator =(FOLLY_MAYBE_UNUSED MyStruct && other)79 MyStruct& MyStruct::operator=(FOLLY_MAYBE_UNUSED MyStruct&& other) noexcept {
80     this->__fbthrift_field_MyIntField = std::move(other.__fbthrift_field_MyIntField);
81     this->__fbthrift_field_MyStringField = std::move(other.__fbthrift_field_MyStringField);
82     __isset = other.__isset;
83     return *this;
84 }
85 
86 
MyStruct(apache::thrift::FragileConstructor,::std::int64_t MyIntField__arg,::std::string MyStringField__arg)87 MyStruct::MyStruct(apache::thrift::FragileConstructor, ::std::int64_t MyIntField__arg, ::std::string MyStringField__arg) :
88     __fbthrift_field_MyIntField(std::move(MyIntField__arg)),
89     __fbthrift_field_MyStringField(std::move(MyStringField__arg)) {
90   __isset.set(folly::index_constant<0>(), true);
91   __isset.set(folly::index_constant<1>(), true);
92 }
93 
94 
__fbthrift_clear()95 void MyStruct::__fbthrift_clear() {
96   // clear all fields
97   this->__fbthrift_field_MyIntField = ::std::int64_t();
98   this->__fbthrift_field_MyStringField = apache::thrift::StringTraits<std::string>::fromStringLiteral("");
99   __isset = {};
100 }
101 
operator ==(const MyStruct & rhs) const102 bool MyStruct::operator==(const MyStruct& rhs) const {
103   (void)rhs;
104   auto& lhs = *this;
105   (void)lhs;
106   if (!(lhs.MyIntField_ref() == rhs.MyIntField_ref())) {
107     return false;
108   }
109   if (!(lhs.MyStringField_ref() == rhs.MyStringField_ref())) {
110     return false;
111   }
112   return true;
113 }
114 
operator <(const MyStruct & rhs) const115 bool MyStruct::operator<(const MyStruct& rhs) const {
116   (void)rhs;
117   auto& lhs = *this;
118   (void)lhs;
119   if (!(lhs.MyIntField_ref() == rhs.MyIntField_ref())) {
120     return lhs.MyIntField_ref() < rhs.MyIntField_ref();
121   }
122   if (!(lhs.MyStringField_ref() == rhs.MyStringField_ref())) {
123     return lhs.MyStringField_ref() < rhs.MyStringField_ref();
124   }
125   return false;
126 }
127 
128 
swap(MyStruct & a,MyStruct & b)129 void swap(MyStruct& a, MyStruct& b) {
130   using ::std::swap;
131   swap(a.MyIntField_ref().value(), b.MyIntField_ref().value());
132   swap(a.MyStringField_ref().value(), b.MyStringField_ref().value());
133   swap(a.__isset, b.__isset);
134 }
135 
136 template void MyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*);
137 template uint32_t MyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const;
138 template uint32_t MyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
139 template uint32_t MyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
140 template void MyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*);
141 template uint32_t MyStruct::write<>(apache::thrift::CompactProtocolWriter*) const;
142 template uint32_t MyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
143 template uint32_t MyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;
144 
145 
146 
147 } // cpp2
148 
149 namespace cpp2 { namespace {
validateAdapters()150 FOLLY_MAYBE_UNUSED FOLLY_ERASE void validateAdapters() {
151 }
152 }} // cpp2
153