Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:49

0001 // charset.hpp
0002 // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARTITION_CHARSET_HPP
0007 #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARTITION_CHARSET_HPP
0008 
0009 #include <set>
0010 #include "../size_t.hpp"
0011 #include "../string_token.hpp"
0012 
0013 namespace boost
0014 {
0015 namespace lexer
0016 {
0017 namespace detail
0018 {
0019 template<typename CharT>
0020 struct basic_charset
0021 {
0022     typedef basic_string_token<CharT> token;
0023     typedef std::set<std::size_t> index_set;
0024 
0025     token _token;
0026     index_set _index_set;
0027 
0028     basic_charset ()
0029     {
0030     }
0031 
0032     basic_charset (const token &token_, const std::size_t index_) :
0033         _token (token_)
0034     {
0035         _index_set.insert (index_);
0036     }
0037 
0038     bool empty () const
0039     {
0040         return _token.empty () && _index_set.empty ();
0041     }
0042 
0043     void intersect (basic_charset &rhs_, basic_charset &overlap_)
0044     {
0045         _token.intersect (rhs_._token, overlap_._token);
0046 
0047         if (!overlap_._token.empty ())
0048         {
0049             typename index_set::const_iterator iter_ = _index_set.begin ();
0050             typename index_set::const_iterator end_ = _index_set.end ();
0051 
0052             for (; iter_ != end_; ++iter_)
0053             {
0054                 overlap_._index_set.insert (*iter_);
0055             }
0056 
0057             iter_ = rhs_._index_set.begin ();
0058             end_ = rhs_._index_set.end ();
0059 
0060             for (; iter_ != end_; ++iter_)
0061             {
0062                 overlap_._index_set.insert (*iter_);
0063             }
0064 
0065             if (_token.empty ())
0066             {
0067                 _index_set.clear ();
0068             }
0069 
0070             if (rhs_._token.empty ())
0071             {
0072                 rhs_._index_set.clear ();
0073             }
0074         }
0075     }
0076 };
0077 }
0078 }
0079 }
0080 
0081 #endif