File indexing completed on 2025-02-28 09:59:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_SPIRIT_CLASSIC_ITERATOR_IMPL_POSITION_ITERATOR_IPP
0012 #define BOOST_SPIRIT_CLASSIC_ITERATOR_IMPL_POSITION_ITERATOR_IPP
0013
0014 #include <boost/config.hpp>
0015 #include <boost/iterator_adaptors.hpp>
0016 #include <boost/type_traits/add_const.hpp>
0017 #include <boost/mpl/if.hpp>
0018 #include <boost/type_traits/is_same.hpp>
0019 #include <boost/spirit/home/classic/core/nil.hpp> // for nil_t
0020 #include <iterator> // for std::iterator_traits
0021
0022 namespace boost { namespace spirit {
0023
0024 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 template <typename String>
0035 class position_policy<file_position_without_column_base<String> > {
0036
0037 public:
0038 void next_line(file_position_without_column_base<String>& pos)
0039 {
0040 ++pos.line;
0041 }
0042
0043 void set_tab_chars(unsigned int ){}
0044 void next_char(file_position_without_column_base<String>& ) {}
0045 void tabulation(file_position_without_column_base<String>& ) {}
0046 };
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 template <typename String>
0060 class position_policy<file_position_base<String> > {
0061
0062 public:
0063 position_policy()
0064 : m_CharsPerTab(4)
0065 {}
0066
0067 void next_line(file_position_base<String>& pos)
0068 {
0069 ++pos.line;
0070 pos.column = 1;
0071 }
0072
0073 void set_tab_chars(unsigned int chars)
0074 {
0075 m_CharsPerTab = chars;
0076 }
0077
0078 void next_char(file_position_base<String>& pos)
0079 {
0080 ++pos.column;
0081 }
0082
0083 void tabulation(file_position_base<String>& pos)
0084 {
0085 pos.column += m_CharsPerTab - (pos.column - 1) % m_CharsPerTab;
0086 }
0087
0088 private:
0089 unsigned int m_CharsPerTab;
0090 };
0091
0092 namespace iterator_ { namespace impl {
0093
0094 template <typename T>
0095 struct make_const : boost::add_const<T>
0096 {};
0097
0098 template <typename T>
0099 struct make_const<T&>
0100 {
0101 typedef typename boost::add_const<T>::type& type;
0102 };
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 template <typename MainIterT, typename ForwardIterT, typename PositionT>
0114 struct position_iterator_base_generator
0115 {
0116 private:
0117 typedef std::iterator_traits<ForwardIterT> traits;
0118 typedef typename traits::value_type value_type;
0119 typedef typename traits::iterator_category iter_category_t;
0120 typedef typename traits::reference reference;
0121
0122
0123 typedef typename boost::add_const<value_type>::type const_value_type;
0124
0125 public:
0126
0127
0128
0129 typedef typename boost::mpl::if_<
0130 typename boost::is_same<MainIterT, nil_t>::type,
0131 position_iterator<ForwardIterT, PositionT, nil_t>,
0132 MainIterT
0133 >::type main_iter_t;
0134
0135 typedef boost::iterator_adaptor<
0136 main_iter_t,
0137 ForwardIterT,
0138 const_value_type,
0139 boost::forward_traversal_tag,
0140 typename make_const<reference>::type
0141 > type;
0142 };
0143
0144 }}
0145
0146 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0147
0148 }}
0149
0150 #endif