diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-03 12:02:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-03 12:02:30 +0200 |
commit | bb48c54f1080874f5a10907714f5fbae0b985ce9 (patch) | |
tree | 8d15b4c6a569a49d22074391440bb5424b7311ef /boost/common/multi-index/test.hxx | |
parent | 92ebb8c861c4986e10d38d949a024aee205b14b2 (diff) |
Add support for Boost Multi-Index container in Boost profile
Diffstat (limited to 'boost/common/multi-index/test.hxx')
-rw-r--r-- | boost/common/multi-index/test.hxx | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/boost/common/multi-index/test.hxx b/boost/common/multi-index/test.hxx new file mode 100644 index 0000000..4018b61 --- /dev/null +++ b/boost/common/multi-index/test.hxx @@ -0,0 +1,114 @@ +// file : boost/common/multi-index/test.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/member.hpp> +#include <boost/multi_index/identity.hpp> +#include <boost/multi_index/ordered_index.hpp> +#include <boost/multi_index/sequenced_index.hpp> +#include <boost/multi_index/random_access_index.hpp> + +#include <odb/core.hxx> + +namespace mi = boost::multi_index; + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const std::string& s) : num (n), str (s) {} + + #pragma db column("number") + int num; + std::string str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +typedef +mi::multi_index_container< + int, + mi::indexed_by<mi::sequenced<> > +> int_lst; + +typedef +mi::multi_index_container< + int, + mi::indexed_by<mi::random_access<> > +> int_vec; + +typedef +mi::multi_index_container< + int, + mi::indexed_by<mi::ordered_unique<mi::identity<int> > > +> int_set; + +typedef +mi::multi_index_container< + int, + mi::indexed_by< + mi::sequenced<>, + mi::ordered_unique<mi::identity<int> > + > +> int_lst_set; + +typedef +mi::multi_index_container< + comp, + mi::indexed_by< + mi::ordered_unique<mi::member<comp, std::string, &comp::str> >, + mi::random_access<> + > +> comp_set_vec; + +typedef +mi::multi_index_container< + comp, + mi::indexed_by< + mi::ordered_unique<mi::member<comp, int, &comp::num> >, + mi::ordered_unique<mi::member<comp, std::string, &comp::str> > + > +> comp_set_set; + +#pragma db object +struct object +{ + object () {} + object (const std::string& id): id (id) {} + + #pragma db id + std::string id; + + int_lst il; + int_lst iv; + int_set is; + + int_lst_set ils; + comp_set_vec csv; + comp_set_set css; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return + x.id == y.id && + + x.il == y.il && + x.iv == y.iv && + x.is == y.is && + + x.ils == y.ils && + x.csv == y.csv && + x.css == y.css; +} + +#endif // TEST_HXX |