26 #include <boost/algorithm/string/join.hpp>
27 #include <boost/assign/list_of.hpp>
28 #include <boost/bimap.hpp>
29 #include <boost/range/adaptor/map.hpp>
30 #include <boost/range/algorithm/copy.hpp>
35 template <
typename Type1,
typename Type2,
typename CRTP>
40 typedef boost::bimap<Type1, Type2> bm_type;
41 static const typename bm_type::left_map& left() {
return CRTP::map_.left; }
42 static const typename bm_type::right_map& right() {
return CRTP::map_.right; }
43 static typename bm_type::left_const_iterator beginLeft() {
return CRTP::map_.left.begin(); }
44 static typename bm_type::left_const_iterator endLeft() {
return CRTP::map_.left.end(); }
45 static typename bm_type::left_const_iterator findLeft(
const type1& rhs) {
46 return CRTP::map_.left.find(rhs);
48 static typename bm_type::right_const_iterator beginRight() {
return CRTP::map_.right.begin(); }
49 static typename bm_type::right_const_iterator endRight() {
return CRTP::map_.right.end(); }
50 static typename bm_type::right_const_iterator findRight(
const type2& rhs) {
51 return CRTP::map_.right.find(rhs);
61 template <
typename Type1,
typename Type2,
typename CRTP>
65 typedef typename base::bm_type bm_type;
66 typedef typename base::type1 type1;
67 typedef typename base::type2 type2;
70 static auto beginImpl(
const Type1* =
nullptr) -> decltype(base::beginLeft()) {
71 return base::beginLeft();
74 static auto beginImpl(
const Type2* =
nullptr) -> decltype(base::beginRight()) {
75 return base::beginRight();
83 static auto endImpl(
const Type1* =
nullptr) -> decltype(base::endLeft()) {
84 return base::endLeft();
87 static auto endImpl(
const Type2* =
nullptr) -> decltype(base::endRight()) {
88 return base::endRight();
97 static auto findImpl(
const type1& item) -> decltype(base::findLeft(item)) {
98 return base::findLeft(item);
101 static auto findImpl(
const type2& item) -> decltype(base::findRight(item)) {
102 return base::findRight(item);
105 template <
typename T>
117 template <
typename Type1,
typename Type2>
122 typedef boost::bimap<type1, type2> bm_type;
125 static const bm_type map_;
126 template <
typename Type3,
typename Type4,
typename CRTP2>
128 template <
typename Type3,
typename Type4,
typename CRTP2>
133 template <
typename Type>
138 typedef boost::bimap<type1, type2> bm_type;
141 static const bm_type map_;
142 template <
typename Type1,
typename Type2,
typename CRTP>
144 template <
typename Type1,
typename Type2,
typename CRTP>
148 template <
typename TEnum>
152 typedef typename base::bm_type bm_type;
153 typedef typename base::type1 type1;
154 typedef typename base::type2 type2;
157 static const bm_type map_;
158 template <
typename Type1,
typename Type2,
typename CRTP>
160 template <
typename Type1,
typename Type2,
typename CRTP>
166 #define IMPLEMENT_ENUMSTRINGMAP(ENUMSTRINGMAPTYPE) \
168 const EnumStringMap<ENUMSTRINGMAPTYPE>::bm_type EnumStringMap<ENUMSTRINGMAPTYPE>::map_ = \
169 boost::assign::list_of<EnumStringMap<ENUMSTRINGMAPTYPE>::bm_type::relation>
BimapBase1 implements basic functions.
Definition: bimap.hpp:36
static auto find(const T &item) -> decltype(findImpl(item))
map::find()
Definition: bimap.hpp:106
static auto beginImpl(const Type1 *=nullptr) -> decltype(base::beginLeft())
Implementation of begin() for the left-map.
Definition: bimap.hpp:70
static auto end() -> decltype(endImpl((T *) nullptr))
map::end()
Definition: bimap.hpp:92
static auto endImpl(const Type1 *=nullptr) -> decltype(base::endLeft())
Implementation of end() for the left-map.
Definition: bimap.hpp:83
static auto findImpl(const type2 &item) -> decltype(base::findRight(item))
Implementation of find() for right-map.
Definition: bimap.hpp:101
static auto beginImpl(const Type2 *=nullptr) -> decltype(base::beginRight())
Implementation of begin() for the right-map.
Definition: bimap.hpp:74
static auto findImpl(const type1 &item) -> decltype(base::findLeft(item))
Implementation of find() for left-map.
Definition: bimap.hpp:97
static auto endImpl(const Type2 *=nullptr) -> decltype(base::endRight())
Implementation of end() for the right-map.
Definition: bimap.hpp:87
static auto begin() -> decltype(beginImpl((T *) nullptr))
Derivate of map::begin()
Definition: bimap.hpp:79
BimapBase class for a pair of identical types, which will get derived further.
Definition: bimap.hpp:118
Definition: bimap.hpp:149