24 #include <boost/algorithm/string/join.hpp>
25 #include <boost/assign/list_of.hpp>
26 #include <boost/bimap.hpp>
27 #include <boost/range/adaptor/map.hpp>
28 #include <boost/range/algorithm/copy.hpp>
33 template <
typename Type1,
typename Type2,
typename CRTP>
38 typedef boost::bimap<Type1, Type2> bm_type;
39 static const typename bm_type::left_map& left() {
return CRTP::map_.left; }
40 static const typename bm_type::right_map& right() {
return CRTP::map_.right; }
41 static typename bm_type::left_const_iterator beginLeft() {
return CRTP::map_.left.begin(); }
42 static typename bm_type::left_const_iterator endLeft() {
return CRTP::map_.left.end(); }
43 static typename bm_type::left_const_iterator findLeft(
const type1& rhs) {
44 return CRTP::map_.left.find(rhs);
46 static typename bm_type::right_const_iterator beginRight() {
return CRTP::map_.right.begin(); }
47 static typename bm_type::right_const_iterator endRight() {
return CRTP::map_.right.end(); }
48 static typename bm_type::right_const_iterator findRight(
const type2& rhs) {
49 return CRTP::map_.right.find(rhs);
59 template <
typename Type1,
typename Type2,
typename CRTP>
63 typedef typename base::bm_type bm_type;
64 typedef typename base::type1 type1;
65 typedef typename base::type2 type2;
68 static auto beginImpl(
const Type1* =
nullptr) -> decltype(base::beginLeft()) {
69 return base::beginLeft();
72 static auto beginImpl(
const Type2* =
nullptr) -> decltype(base::beginRight()) {
73 return base::beginRight();
81 static auto endImpl(
const Type1* =
nullptr) -> decltype(base::endLeft()) {
82 return base::endLeft();
85 static auto endImpl(
const Type2* =
nullptr) -> decltype(base::endRight()) {
86 return base::endRight();
95 static auto findImpl(
const type1& item) -> decltype(base::findLeft(item)) {
96 return base::findLeft(item);
99 static auto findImpl(
const type2& item) -> decltype(base::findRight(item)) {
100 return base::findRight(item);
103 template <
typename T>
115 template <
typename Type1,
typename Type2>
120 typedef boost::bimap<type1, type2> bm_type;
123 static const bm_type map_;
124 template <
typename Type3,
typename Type4,
typename CRTP2>
126 template <
typename Type3,
typename Type4,
typename CRTP2>
131 template <
typename Type>
136 typedef boost::bimap<type1, type2> bm_type;
139 static const bm_type map_;
140 template <
typename Type1,
typename Type2,
typename CRTP>
142 template <
typename Type1,
typename Type2,
typename CRTP>
146 template <
typename TEnum>
150 typedef typename base::bm_type bm_type;
151 typedef typename base::type1 type1;
152 typedef typename base::type2 type2;
155 static const bm_type map_;
156 template <
typename Type1,
typename Type2,
typename CRTP>
158 template <
typename Type1,
typename Type2,
typename CRTP>
164 #define IMPLEMENT_ENUMSTRINGMAP(ENUMSTRINGMAPTYPE) \
166 const EnumStringMap<ENUMSTRINGMAPTYPE>::bm_type EnumStringMap<ENUMSTRINGMAPTYPE>::map_ = \
167 boost::assign::list_of<EnumStringMap<ENUMSTRINGMAPTYPE>::bm_type::relation>
BimapBase1 implements basic functions.
Definition: bimap.hpp:34
static auto find(const T &item) -> decltype(findImpl(item))
map::find()
Definition: bimap.hpp:104
static auto beginImpl(const Type1 *=nullptr) -> decltype(base::beginLeft())
Implementation of begin() for the left-map.
Definition: bimap.hpp:68
static auto end() -> decltype(endImpl((T *) nullptr))
map::end()
Definition: bimap.hpp:90
static auto endImpl(const Type1 *=nullptr) -> decltype(base::endLeft())
Implementation of end() for the left-map.
Definition: bimap.hpp:81
static auto findImpl(const type2 &item) -> decltype(base::findRight(item))
Implementation of find() for right-map.
Definition: bimap.hpp:99
static auto beginImpl(const Type2 *=nullptr) -> decltype(base::beginRight())
Implementation of begin() for the right-map.
Definition: bimap.hpp:72
static auto findImpl(const type1 &item) -> decltype(base::findLeft(item))
Implementation of find() for left-map.
Definition: bimap.hpp:95
static auto endImpl(const Type2 *=nullptr) -> decltype(base::endRight())
Implementation of end() for the right-map.
Definition: bimap.hpp:85
static auto begin() -> decltype(beginImpl((T *) nullptr))
Derivate of map::begin()
Definition: bimap.hpp:77
BimapBase class for a pair of identical types, which will get derived further.
Definition: bimap.hpp:116
Definition: bimap.hpp:147