Warning, file /include/boost/spirit/home/qi/string/tst.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_TST_JUNE_03_2007_1031AM)
0008 #define BOOST_SPIRIT_TST_JUNE_03_2007_1031AM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/qi/string/detail/tst.hpp>
0015
0016 namespace boost { namespace spirit { namespace qi
0017 {
0018 struct tst_pass_through
0019 {
0020 template <typename Char>
0021 Char operator()(Char ch) const
0022 {
0023 return ch;
0024 }
0025 };
0026
0027 template <typename Char, typename T>
0028 struct tst
0029 {
0030 typedef Char char_type;
0031 typedef T value_type;
0032 typedef detail::tst_node<Char, T> node;
0033
0034 tst()
0035 : root(0)
0036 {
0037 }
0038
0039 ~tst()
0040 {
0041 clear();
0042 }
0043
0044 tst(tst const& rhs)
0045 : root(0)
0046 {
0047 copy(rhs);
0048 }
0049
0050 tst& operator=(tst const& rhs)
0051 {
0052 return assign(rhs);
0053 }
0054
0055 template <typename Iterator, typename Filter>
0056 T* find(Iterator& first, Iterator last, Filter filter) const
0057 {
0058 return node::find(root, first, last, filter);
0059 }
0060
0061 template <typename Iterator>
0062 T* find(Iterator& first, Iterator last) const
0063 {
0064 return find(first, last, tst_pass_through());
0065 }
0066
0067 template <typename Iterator>
0068 T* add(
0069 Iterator first
0070 , Iterator last
0071 , typename boost::call_traits<T>::param_type val)
0072 {
0073 return node::add(root, first, last, val, this);
0074 }
0075
0076 template <typename Iterator>
0077 void remove(Iterator first, Iterator last)
0078 {
0079 node::remove(root, first, last, this);
0080 }
0081
0082 void clear()
0083 {
0084 node::destruct_node(root, this);
0085 root = 0;
0086 }
0087
0088 template <typename F>
0089 void for_each(F f) const
0090 {
0091 node::for_each(root, std::basic_string<Char>(), f);
0092 }
0093
0094 private:
0095
0096 friend struct detail::tst_node<Char, T>;
0097
0098 void copy(tst const& rhs)
0099 {
0100 root = node::clone_node(rhs.root, this);
0101 }
0102
0103 tst& assign(tst const& rhs)
0104 {
0105 if (this != &rhs)
0106 {
0107 clear();
0108 copy(rhs);
0109 }
0110 return *this;
0111 }
0112
0113 node* root;
0114
0115 node* new_node(Char id)
0116 {
0117 return new node(id);
0118 }
0119
0120 T* new_data(typename boost::call_traits<T>::param_type val)
0121 {
0122 return new T(val);
0123 }
0124
0125 void delete_node(node* p)
0126 {
0127 delete p;
0128 }
0129
0130 void delete_data(T* p)
0131 {
0132 delete p;
0133 }
0134 };
0135 }}}
0136
0137 #endif