]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/include/boost/spirit/home/support/detail/lexer/partition/charset.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / support / detail / lexer / partition / charset.hpp
1 // charset.hpp
2 // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_LEXER_CHARSET_HPP
7 #define BOOST_LEXER_CHARSET_HPP
8
9 #include <set>
10 #include "../size_t.hpp"
11 #include "../string_token.hpp"
12
13 namespace boost
14 {
15 namespace lexer
16 {
17 namespace detail
18 {
19 template<typename CharT>
20 struct basic_charset
21 {
22 typedef basic_string_token<CharT> token;
23 typedef std::set<std::size_t> index_set;
24
25 token _token;
26 index_set _index_set;
27
28 basic_charset ()
29 {
30 }
31
32 basic_charset (const token &token_, const std::size_t index_) :
33 _token (token_)
34 {
35 _index_set.insert (index_);
36 }
37
38 bool empty () const
39 {
40 return _token.empty () && _index_set.empty ();
41 }
42
43 void intersect (basic_charset &rhs_, basic_charset &overlap_)
44 {
45 _token.intersect (rhs_._token, overlap_._token);
46
47 if (!overlap_._token.empty ())
48 {
49 typename index_set::const_iterator iter_ = _index_set.begin ();
50 typename index_set::const_iterator end_ = _index_set.end ();
51
52 for (; iter_ != end_; ++iter_)
53 {
54 overlap_._index_set.insert (*iter_);
55 }
56
57 iter_ = rhs_._index_set.begin ();
58 end_ = rhs_._index_set.end ();
59
60 for (; iter_ != end_; ++iter_)
61 {
62 overlap_._index_set.insert (*iter_);
63 }
64
65 if (_token.empty ())
66 {
67 _index_set.clear ();
68 }
69
70 if (rhs_._token.empty ())
71 {
72 rhs_._index_set.clear ();
73 }
74 }
75 }
76 };
77 }
78 }
79 }
80
81 #endif