framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
field_type.hpp
Go to the documentation of this file.
1 // Copyright (C) 2013 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
13 #pragma once
14 
15 namespace framework
16 {
17  namespace protocol_buffers
18  {
19  namespace detail
20  {
21  template <typename T, typename Enabler = void>
22  struct is_field_type_impl;
23 
24  template <typename T>
25  struct field_number_impl;
26 
27  template <typename T>
28  struct field_type_impl;
29 
30  template <typename T>
31  struct is_required_impl;
32 
33  template <typename T>
34  struct is_repeated_impl;
35 
36  template <typename T>
37  struct is_optional_impl;
38  };
39 
43  enum class e_field_type
44  {
45  optional,
46  required,
47  repeated
48  };
49 
53  template <typename Type, typename Number>
54  struct field_base
55  {
56 // GCC bug workaround - www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580
57 #if MAX_GNUC_VERSION(4, 8, 0)
58  public:
59 #else
60  template <typename T, typename Enabler>
61  friend struct detail::is_field_type_impl;
62 
63  template <typename T>
64  friend struct detail::field_number_impl;
65 
66  template <typename T>
67  friend struct detail::field_type_impl;
68 
69  private:
70 #endif
71  using protocol_buffers_field_enabler = void;
72  using protocol_buffers_field_number = Number;
73  using protocol_buffers_field_type = Type;
74  };
75 
79  template <typename T>
80  using is_field_type = typename detail::is_field_type_impl <T>::type;
81 
85  template <typename T>
86  using is_required = typename detail::is_required_impl <T>::type;
87 
91  template <typename T>
92  using is_optional = typename detail::is_optional_impl <T>::type;
93 
97  template <typename T>
98  using is_repeated = typename detail::is_repeated_impl <T>::type;
99 
103  template <typename T>
104  using field_number = typename detail::field_number_impl <T>::type;
105 
109  template <typename T>
110  using field_type = typename detail::field_type_impl <T>::type;
111 
118  template <typename Lhs, typename Rhs>
120 
127  template <uint64_t Number>
129  {
130  template <typename T>
131  using type =
132  typename std::conditional <
133  field_number <T>::value == Number,
134  std::true_type,
135  std::false_type
136  >::type;
137  };
138  }
139 }
140 
141 #include <framework/protocol_buffers/field_type.inl>