]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/attribute/parametric.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / attribute / parametric.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 http://spirit.sourceforge.net/
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7=============================================================================*/
8#ifndef BOOST_SPIRIT_PARAMETRIC_HPP
9#define BOOST_SPIRIT_PARAMETRIC_HPP
10
11///////////////////////////////////////////////////////////////////////////////
12#include <boost/spirit/home/classic/namespace.hpp>
13#include <boost/spirit/home/classic/core/parser.hpp>
14#include <boost/spirit/home/classic/core/composite/composite.hpp>
15#include <boost/spirit/home/classic/core/primitives/primitives.hpp>
16
17namespace boost { namespace spirit {
18
19BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
20
21 ///////////////////////////////////////////////////////////////////////////
22 //
23 // f_chlit class [ functional version of chlit ]
24 //
25 ///////////////////////////////////////////////////////////////////////////
26 template <typename ChGenT>
27 struct f_chlit : public char_parser<f_chlit<ChGenT> >
28 {
29 f_chlit(ChGenT chgen_)
30 : chgen(chgen_) {}
31
32 template <typename T>
33 bool test(T ch) const
34 { return ch == chgen(); }
35
36 ChGenT chgen;
37 };
38
39 template <typename ChGenT>
40 inline f_chlit<ChGenT>
41 f_ch_p(ChGenT chgen)
42 { return f_chlit<ChGenT>(chgen); }
43
44 ///////////////////////////////////////////////////////////////////////////
45 //
46 // f_range class [ functional version of range ]
47 //
48 ///////////////////////////////////////////////////////////////////////////
49 template <typename ChGenAT, typename ChGenBT>
50 struct f_range : public char_parser<f_range<ChGenAT, ChGenBT> >
51 {
52 f_range(ChGenAT first_, ChGenBT last_)
53 : first(first_), last(last_)
54 {}
55
56 template <typename T>
57 bool test(T ch) const
58 {
59 BOOST_SPIRIT_ASSERT(first() <= last());
60 return (ch >= first()) && (ch <= last());
61 }
62
63 ChGenAT first;
64 ChGenBT last;
65 };
66
67 template <typename ChGenAT, typename ChGenBT>
68 inline f_range<ChGenAT, ChGenBT>
69 f_range_p(ChGenAT first, ChGenBT last)
70 { return f_range<ChGenAT, ChGenBT>(first, last); }
71
72 ///////////////////////////////////////////////////////////////////////////
73 //
74 // f_chseq class [ functional version of chseq ]
75 //
76 ///////////////////////////////////////////////////////////////////////////
77 template <typename IterGenAT, typename IterGenBT>
78 class f_chseq : public parser<f_chseq<IterGenAT, IterGenBT> >
79 {
80 public:
81
82 typedef f_chseq<IterGenAT, IterGenBT> self_t;
83
84 f_chseq(IterGenAT first_, IterGenBT last_)
85 : first(first_), last(last_) {}
86
87 template <typename ScannerT>
88 typename parser_result<self_t, ScannerT>::type
89 parse(ScannerT const& scan) const
90 {
91 typedef typename parser_result<self_t, ScannerT>::type result_t;
92 return impl::string_parser_parse<result_t>(first(), last(), scan);
93 }
94
95 private:
96
97 IterGenAT first;
98 IterGenBT last;
99 };
100
101 template <typename IterGenAT, typename IterGenBT>
102 inline f_chseq<IterGenAT, IterGenBT>
103 f_chseq_p(IterGenAT first, IterGenBT last)
104 { return f_chseq<IterGenAT, IterGenBT>(first, last); }
105
106 ///////////////////////////////////////////////////////////////////////////
107 //
108 // f_strlit class [ functional version of strlit ]
109 //
110 ///////////////////////////////////////////////////////////////////////////
111 template <typename IterGenAT, typename IterGenBT>
112 class f_strlit : public parser<f_strlit<IterGenAT, IterGenBT> >
113 {
114 public:
115
116 typedef f_strlit<IterGenAT, IterGenBT> self_t;
117
118 f_strlit(IterGenAT first, IterGenBT last)
119 : seq(first, last) {}
120
121 template <typename ScannerT>
122 typename parser_result<self_t, ScannerT>::type
123 parse(ScannerT const& scan) const
124 {
125 typedef typename parser_result<self_t, ScannerT>::type result_t;
126 return impl::contiguous_parser_parse<result_t>
127 (seq, scan, scan);
128 }
129
130 private:
131
132 f_chseq<IterGenAT, IterGenBT> seq;
133 };
134
135 template <typename IterGenAT, typename IterGenBT>
136 inline f_strlit<IterGenAT, IterGenBT>
137 f_str_p(IterGenAT first, IterGenBT last)
138 { return f_strlit<IterGenAT, IterGenBT>(first, last); }
139
140BOOST_SPIRIT_CLASSIC_NAMESPACE_END
141
142}} // namespace BOOST_SPIRIT_CLASSIC_NS
143
144#endif