vdj_pipe
pipeline for processing DNA sequence data
value_variant.hpp
Go to the documentation of this file.
1 
7 #ifndef VALUE_VARIANT_HPP_
8 #define VALUE_VARIANT_HPP_
9 #include <iosfwd>
10 #include "boost/array.hpp"
11 #include "boost/mpl/begin.hpp"
12 #include "boost/mpl/distance.hpp"
13 #include "boost/mpl/find.hpp"
14 #include "boost/mpl/size.hpp"
15 #include "boost/variant.hpp"
16 #include "vdj_pipe/config.hpp"
17 #include "vdj_pipe/object_ids.hpp"
20 
21 namespace vdj_pipe{
22 
25 struct Blank {
26  bool operator==(Blank const&) const {return true;}
27  bool operator<(Blank const&) const {return false;}
28 };
29 
32 inline std::size_t hash_value(Blank const&) {return 0xd5d6573673acc2a3;}
33 
36 template<class ChT, class Tr> inline
37 std::basic_ostream<ChT,Tr>& operator<<(
38  std::basic_ostream<ChT,Tr>& os,
39  Blank const&
40 ) {
41  return os << "Undetermined";
42 }
43 
46 typedef boost::variant<
47  Blank, bool, long, double, std::string,
49  >
51 
54 inline std::string const& variable_type_str(const int which) {
55  typedef boost::array<
56  std::string,
58  > array;
59  static const array a =
60  {{
61  "blank", "bool", "integer", "float", "string",
62  "interval", "quality"
63  }};
64  return a[which];
65 }
66 
69 template<typename T> struct Type_index :
70  boost::mpl::distance<
71  typename boost::mpl::begin<value_variant::types>::type,
72  typename boost::mpl::find<value_variant::types,T>::type
73  >::type
74  {};
75 
78 inline bool is_blank(value_variant const& vv) {
79  return boost::get<Blank>(&vv);
80 }
81 
82 namespace detail{
83 
84 struct Type_name : public boost::static_visitor<std::string const&> {
85  template<typename T>
86  std::string const& operator()(T const&) const {
88  }
89 };
90 
91 }//namespace detail
92 
95 inline std::string const& variable_type_str(value_variant const& vv) {
96  return boost::apply_visitor(detail::Type_name(), vv);
97 }
98 
101 VDJ_PIPE_DECL value_variant parse_variant(std::string const& s);
102 
103 }//namespace vdj_pipe
104 #endif /* VALUE_VARIANT_HPP_ */
value_variant parse_variant(std::string const &s)
Definition: value_variant.cpp:19
Definition: value_variant.hpp:69
Qual_record::quality::value_type value
Definition: find_interval_run.cpp:17
Definition: sequence_record.hpp:35
std::string const & variable_type_str(const int which)
Definition: value_variant.hpp:54
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
bool is_blank(value_variant const &vv)
Definition: value_variant.hpp:78
bool operator<(Blank const &) const
Definition: value_variant.hpp:27
#define VDJ_PIPE_DECL
Definition: config.hpp:23
Definition: value_variant.hpp:84
boost::variant< Blank, bool, long, double, std::string, sequence_interval, Qual_record::quality > value_variant
Definition: value_variant.hpp:50
std::size_t hash_value(File const &f)
Definition: file.cpp:158
boost::numeric::interval< int, boost::numeric::interval_lib::policies< boost::numeric::interval_lib::rounded_math< int >, detail::Interval_checking_policy< int > > > sequence_interval
Definition: sequence_interval.hpp:40
std::basic_ostream< ChT, Tr > & operator<<(std::basic_ostream< ChT, Tr > &os, Blank const &)
Definition: value_variant.hpp:37
Definition: value_variant.hpp:25
std::string const & operator()(T const &) const
Definition: value_variant.hpp:86
bool operator==(Blank const &) const
Definition: value_variant.hpp:26