Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / test / fixtures / mcpp2-compare / gen-cpp2 / enums_types.h
blob1388b8b47cde4b807b64b4e18d71304840f66663
1 /**
2 * Autogenerated by Thrift for src/enums.thrift
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated @nocommit
6 */
7 #pragma once
9 #include <thrift/lib/cpp2/gen/module_types_h.h>
11 #include <thrift/lib/cpp2/type/Tag.h>
14 namespace apache {
15 namespace thrift {
16 namespace tag {
17 struct fieldA;
18 } // namespace tag
19 namespace detail {
20 #ifndef APACHE_THRIFT_ACCESSOR_fieldA
21 #define APACHE_THRIFT_ACCESSOR_fieldA
22 APACHE_THRIFT_DEFINE_ACCESSOR(fieldA);
23 #endif
24 } // namespace detail
25 } // namespace thrift
26 } // namespace apache
28 // BEGIN declare_enums
29 namespace facebook { namespace ns { namespace qwerty {
31 enum class AnEnumA {
32 FIELDA = 0,
37 enum class AnEnumB {
38 FIELDA = 0,
39 FIELDB = 2,
44 enum class AnEnumC {
45 FIELDC = 0,
50 enum class AnEnumD {
51 FIELDD = 0,
56 enum class AnEnumE {
57 FIELDA = 0,
62 }}} // facebook::ns::qwerty
64 namespace std {
65 template<> struct hash<::facebook::ns::qwerty::AnEnumA> :
66 ::apache::thrift::detail::enum_hash<::facebook::ns::qwerty::AnEnumA> {};
67 template<> struct hash<::facebook::ns::qwerty::AnEnumB> :
68 ::apache::thrift::detail::enum_hash<::facebook::ns::qwerty::AnEnumB> {};
69 template<> struct hash<::facebook::ns::qwerty::AnEnumC> :
70 ::apache::thrift::detail::enum_hash<::facebook::ns::qwerty::AnEnumC> {};
71 template<> struct hash<::facebook::ns::qwerty::AnEnumD> :
72 ::apache::thrift::detail::enum_hash<::facebook::ns::qwerty::AnEnumD> {};
73 template<> struct hash<::facebook::ns::qwerty::AnEnumE> :
74 ::apache::thrift::detail::enum_hash<::facebook::ns::qwerty::AnEnumE> {};
75 } // std
77 namespace apache { namespace thrift {
80 template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumA>;
82 template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumA> {
83 using type = ::facebook::ns::qwerty::AnEnumA;
85 static constexpr std::size_t const size = 1;
86 static folly::Range<type const*> const values;
87 static folly::Range<folly::StringPiece const*> const names;
89 static bool findName(type value, folly::StringPiece* out) noexcept;
90 static bool findValue(folly::StringPiece name, type* out) noexcept;
92 #if FOLLY_HAS_STRING_VIEW
93 static bool findName(type value, std::string_view* out) noexcept {
94 folly::StringPiece outp;
95 return findName(value, &outp) && ((*out = outp), true);
97 #endif
98 static char const* findName(type value) noexcept {
99 folly::StringPiece ret;
100 (void)findName(value, &ret);
101 return ret.data();
103 static constexpr type min() { return type::FIELDA; }
104 static constexpr type max() { return type::FIELDA; }
108 template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumB>;
110 template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumB> {
111 using type = ::facebook::ns::qwerty::AnEnumB;
113 static constexpr std::size_t const size = 2;
114 static folly::Range<type const*> const values;
115 static folly::Range<folly::StringPiece const*> const names;
117 static bool findName(type value, folly::StringPiece* out) noexcept;
118 static bool findValue(folly::StringPiece name, type* out) noexcept;
120 #if FOLLY_HAS_STRING_VIEW
121 static bool findName(type value, std::string_view* out) noexcept {
122 folly::StringPiece outp;
123 return findName(value, &outp) && ((*out = outp), true);
125 #endif
126 static char const* findName(type value) noexcept {
127 folly::StringPiece ret;
128 (void)findName(value, &ret);
129 return ret.data();
131 static constexpr type min() { return type::FIELDA; }
132 static constexpr type max() { return type::FIELDB; }
136 template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumC>;
138 template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumC> {
139 using type = ::facebook::ns::qwerty::AnEnumC;
141 static constexpr std::size_t const size = 1;
142 static folly::Range<type const*> const values;
143 static folly::Range<folly::StringPiece const*> const names;
145 static bool findName(type value, folly::StringPiece* out) noexcept;
146 static bool findValue(folly::StringPiece name, type* out) noexcept;
148 #if FOLLY_HAS_STRING_VIEW
149 static bool findName(type value, std::string_view* out) noexcept {
150 folly::StringPiece outp;
151 return findName(value, &outp) && ((*out = outp), true);
153 #endif
154 static char const* findName(type value) noexcept {
155 folly::StringPiece ret;
156 (void)findName(value, &ret);
157 return ret.data();
159 static constexpr type min() { return type::FIELDC; }
160 static constexpr type max() { return type::FIELDC; }
164 template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumD>;
166 template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumD> {
167 using type = ::facebook::ns::qwerty::AnEnumD;
169 static constexpr std::size_t const size = 1;
170 static folly::Range<type const*> const values;
171 static folly::Range<folly::StringPiece const*> const names;
173 static bool findName(type value, folly::StringPiece* out) noexcept;
174 static bool findValue(folly::StringPiece name, type* out) noexcept;
176 #if FOLLY_HAS_STRING_VIEW
177 static bool findName(type value, std::string_view* out) noexcept {
178 folly::StringPiece outp;
179 return findName(value, &outp) && ((*out = outp), true);
181 #endif
182 static char const* findName(type value) noexcept {
183 folly::StringPiece ret;
184 (void)findName(value, &ret);
185 return ret.data();
187 static constexpr type min() { return type::FIELDD; }
188 static constexpr type max() { return type::FIELDD; }
192 template <> struct TEnumDataStorage<::facebook::ns::qwerty::AnEnumE>;
194 template <> struct TEnumTraits<::facebook::ns::qwerty::AnEnumE> {
195 using type = ::facebook::ns::qwerty::AnEnumE;
197 static constexpr std::size_t const size = 1;
198 static folly::Range<type const*> const values;
199 static folly::Range<folly::StringPiece const*> const names;
201 static bool findName(type value, folly::StringPiece* out) noexcept;
202 static bool findValue(folly::StringPiece name, type* out) noexcept;
204 #if FOLLY_HAS_STRING_VIEW
205 static bool findName(type value, std::string_view* out) noexcept {
206 folly::StringPiece outp;
207 return findName(value, &outp) && ((*out = outp), true);
209 #endif
210 static char const* findName(type value) noexcept {
211 folly::StringPiece ret;
212 (void)findName(value, &ret);
213 return ret.data();
215 static constexpr type min() { return type::FIELDA; }
216 static constexpr type max() { return type::FIELDA; }
220 }} // apache::thrift
222 namespace facebook { namespace ns { namespace qwerty {
224 using _AnEnumA_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumA>;
225 #ifndef ANDROID
226 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]]
227 extern const _AnEnumA_EnumMapFactory::ValuesToNamesMapType _AnEnumA_VALUES_TO_NAMES;
228 [[deprecated("use apache::thrift::TEnumTraits")]]
229 extern const _AnEnumA_EnumMapFactory::NamesToValuesMapType _AnEnumA_NAMES_TO_VALUES;
230 #endif
231 using _AnEnumB_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumB>;
232 #ifndef ANDROID
233 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]]
234 extern const _AnEnumB_EnumMapFactory::ValuesToNamesMapType _AnEnumB_VALUES_TO_NAMES;
235 [[deprecated("use apache::thrift::TEnumTraits")]]
236 extern const _AnEnumB_EnumMapFactory::NamesToValuesMapType _AnEnumB_NAMES_TO_VALUES;
237 #endif
238 using _AnEnumC_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumC>;
239 #ifndef ANDROID
240 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]]
241 extern const _AnEnumC_EnumMapFactory::ValuesToNamesMapType _AnEnumC_VALUES_TO_NAMES;
242 [[deprecated("use apache::thrift::TEnumTraits")]]
243 extern const _AnEnumC_EnumMapFactory::NamesToValuesMapType _AnEnumC_NAMES_TO_VALUES;
244 #endif
245 using _AnEnumD_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumD>;
246 #ifndef ANDROID
247 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]]
248 extern const _AnEnumD_EnumMapFactory::ValuesToNamesMapType _AnEnumD_VALUES_TO_NAMES;
249 [[deprecated("use apache::thrift::TEnumTraits")]]
250 extern const _AnEnumD_EnumMapFactory::NamesToValuesMapType _AnEnumD_NAMES_TO_VALUES;
251 #endif
252 using _AnEnumE_EnumMapFactory = apache::thrift::detail::TEnumMapFactory<AnEnumE>;
253 #ifndef ANDROID
254 [[deprecated("use apache::thrift::util::enumNameSafe, apache::thrift::util::enumName, or apache::thrift::TEnumTraits")]]
255 extern const _AnEnumE_EnumMapFactory::ValuesToNamesMapType _AnEnumE_VALUES_TO_NAMES;
256 [[deprecated("use apache::thrift::TEnumTraits")]]
257 extern const _AnEnumE_EnumMapFactory::NamesToValuesMapType _AnEnumE_NAMES_TO_VALUES;
258 #endif
259 }}} // facebook::ns::qwerty
261 // END declare_enums
262 // BEGIN forward_declare
263 namespace facebook { namespace ns { namespace qwerty {
264 class SomeStruct;
265 }}} // facebook::ns::qwerty
266 // END forward_declare
267 // BEGIN hash_and_equal_to
268 // END hash_and_equal_to
269 namespace facebook { namespace ns { namespace qwerty {
270 using ::apache::thrift::detail::operator!=;
271 using ::apache::thrift::detail::operator>;
272 using ::apache::thrift::detail::operator<=;
273 using ::apache::thrift::detail::operator>=;
276 class SomeStruct final {
277 private:
278 friend struct ::apache::thrift::detail::st::struct_private_access;
279 template<class> friend struct ::apache::thrift::detail::invoke_reffer;
281 // used by a static_assert in the corresponding source
282 static constexpr bool __fbthrift_cpp2_gen_json = true;
283 static const folly::StringPiece __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord);
285 void __fbthrift_clear();
286 void __fbthrift_clear_terse_fields();
287 bool __fbthrift_is_empty() const;
289 public:
290 using __fbthrift_cpp2_type = SomeStruct;
291 static constexpr bool __fbthrift_cpp2_is_union =
292 false;
295 public:
297 SomeStruct() :
298 __fbthrift_field_fieldA() {
300 // FragileConstructor for use in initialization lists only.
301 [[deprecated("This constructor is deprecated")]]
302 SomeStruct(apache::thrift::FragileConstructor, ::std::int32_t fieldA__arg);
304 SomeStruct(SomeStruct&&) = default;
306 SomeStruct(const SomeStruct&) = default;
309 SomeStruct& operator=(SomeStruct&&) = default;
311 SomeStruct& operator=(const SomeStruct&) = default;
312 private:
313 ::std::int32_t __fbthrift_field_fieldA;
314 private:
315 apache::thrift::detail::isset_bitset<1, apache::thrift::detail::IssetBitsetOption::Unpacked> __isset;
317 public:
319 bool operator==(const SomeStruct&) const;
320 bool operator<(const SomeStruct&) const;
322 template <typename..., typename T = ::std::int32_t>
323 FOLLY_ERASE ::apache::thrift::field_ref<const T&> fieldA_ref() const& {
324 return {this->__fbthrift_field_fieldA, __isset.at(0), __isset.bit(0)};
327 template <typename..., typename T = ::std::int32_t>
328 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> fieldA_ref() const&& {
329 return {static_cast<const T&&>(this->__fbthrift_field_fieldA), __isset.at(0), __isset.bit(0)};
332 template <typename..., typename T = ::std::int32_t>
333 FOLLY_ERASE ::apache::thrift::field_ref<T&> fieldA_ref() & {
334 return {this->__fbthrift_field_fieldA, __isset.at(0), __isset.bit(0)};
337 template <typename..., typename T = ::std::int32_t>
338 FOLLY_ERASE ::apache::thrift::field_ref<T&&> fieldA_ref() && {
339 return {static_cast<T&&>(this->__fbthrift_field_fieldA), __isset.at(0), __isset.bit(0)};
342 template <typename..., typename T = ::std::int32_t>
343 FOLLY_ERASE ::apache::thrift::field_ref<const T&> fieldA() const& {
344 return {this->__fbthrift_field_fieldA, __isset.at(0), __isset.bit(0)};
347 template <typename..., typename T = ::std::int32_t>
348 FOLLY_ERASE ::apache::thrift::field_ref<const T&&> fieldA() const&& {
349 return {static_cast<const T&&>(this->__fbthrift_field_fieldA), __isset.at(0), __isset.bit(0)};
352 template <typename..., typename T = ::std::int32_t>
353 FOLLY_ERASE ::apache::thrift::field_ref<T&> fieldA() & {
354 return {this->__fbthrift_field_fieldA, __isset.at(0), __isset.bit(0)};
357 template <typename..., typename T = ::std::int32_t>
358 FOLLY_ERASE ::apache::thrift::field_ref<T&&> fieldA() && {
359 return {static_cast<T&&>(this->__fbthrift_field_fieldA), __isset.at(0), __isset.bit(0)};
362 ::std::int32_t get_fieldA() const {
363 return __fbthrift_field_fieldA;
366 [[deprecated("Use `FOO.fieldA_ref() = BAR;` instead of `FOO.set_fieldA(BAR);`")]]
367 ::std::int32_t& set_fieldA(::std::int32_t fieldA_) {
368 fieldA_ref() = fieldA_;
369 return __fbthrift_field_fieldA;
372 template <class Protocol_>
373 unsigned long read(Protocol_* iprot);
374 template <class Protocol_>
375 uint32_t serializedSize(Protocol_ const* prot_) const;
376 template <class Protocol_>
377 uint32_t serializedSizeZC(Protocol_ const* prot_) const;
378 template <class Protocol_>
379 uint32_t write(Protocol_* prot_) const;
381 private:
382 template <class Protocol_>
383 void readNoXfer(Protocol_* iprot);
385 friend class ::apache::thrift::Cpp2Ops<SomeStruct>;
386 friend void swap(SomeStruct& a, SomeStruct& b);
389 template <class Protocol_>
390 unsigned long SomeStruct::read(Protocol_* iprot) {
391 auto _xferStart = iprot->getCursorPosition();
392 readNoXfer(iprot);
393 return iprot->getCursorPosition() - _xferStart;
397 }}} // facebook::ns::qwerty