os/ossrv/ossrv_pub/boost_apis/boost/spirit/utility/chset.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*=============================================================================
     2     Copyright (c) 2001-2003 Joel de Guzman
     3     Copyright (c) 2001-2003 Daniel Nuffer
     4     http://spirit.sourceforge.net/
     5 
     6     Use, modification and distribution is subject to the Boost Software
     7     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     8     http://www.boost.org/LICENSE_1_0.txt)
     9 =============================================================================*/
    10 #ifndef BOOST_SPIRIT_CHSET_HPP
    11 #define BOOST_SPIRIT_CHSET_HPP
    12 
    13 ///////////////////////////////////////////////////////////////////////////////
    14 #include <boost/shared_ptr.hpp>
    15 #include <boost/spirit/core/primitives/primitives.hpp>
    16 #include <boost/spirit/utility/impl/chset/basic_chset.hpp>
    17 
    18 ///////////////////////////////////////////////////////////////////////////////
    19 namespace boost { namespace spirit {
    20 
    21 namespace utility { namespace impl {
    22 
    23     // This is here because some compilers choke on out-of-line member
    24     // template functions.  And we don't want to put the whole algorithm
    25     // in the chset constructor in the class definition.
    26     template <typename CharT, typename CharT2>
    27     void construct_chset(boost::shared_ptr<basic_chset<CharT> >& ptr,
    28             CharT2 const* definition);
    29 
    30 }} // namespace utility::impl
    31 
    32 ///////////////////////////////////////////////////////////////////////////////
    33 //
    34 //  chset class
    35 //
    36 ///////////////////////////////////////////////////////////////////////////////
    37 template <typename CharT = char>
    38 class chset: public char_parser<chset<CharT> > {
    39 
    40 public:
    41                     chset();
    42                     chset(chset const& arg_);
    43     explicit        chset(CharT arg_);
    44     explicit        chset(anychar_parser arg_);
    45     explicit        chset(nothing_parser arg_);
    46     explicit        chset(chlit<CharT> const& arg_);
    47     explicit        chset(range<CharT> const& arg_);
    48     explicit        chset(negated_char_parser<chlit<CharT> > const& arg_);
    49     explicit        chset(negated_char_parser<range<CharT> > const& arg_);
    50 
    51                     template <typename CharT2>
    52     explicit        chset(CharT2 const* definition)
    53                     : ptr(new basic_chset<CharT>())
    54                     {
    55                         utility::impl::construct_chset(ptr, definition);
    56                     }
    57                     ~chset();
    58 
    59     chset&          operator=(chset const& rhs);
    60     chset&          operator=(CharT rhs);
    61     chset&          operator=(anychar_parser rhs);
    62     chset&          operator=(nothing_parser rhs);
    63     chset&          operator=(chlit<CharT> const& rhs);
    64     chset&          operator=(range<CharT> const& rhs);
    65     chset&          operator=(negated_char_parser<chlit<CharT> > const& rhs);
    66     chset&          operator=(negated_char_parser<range<CharT> > const& rhs);
    67 
    68     void            set(range<CharT> const& arg_);
    69     void            set(negated_char_parser<chlit<CharT> > const& arg_);
    70     void            set(negated_char_parser<range<CharT> > const& arg_);
    71 
    72     void            clear(range<CharT> const& arg_);
    73     void            clear(negated_char_parser<range<CharT> > const& arg_);
    74     bool            test(CharT ch) const;
    75     chset&          inverse();
    76     void            swap(chset& x);
    77 
    78     chset&          operator|=(chset const& x);
    79     chset&          operator&=(chset const& x);
    80     chset&          operator-=(chset const& x);
    81     chset&          operator^=(chset const& x);
    82 
    83 private:
    84 
    85     boost::shared_ptr<basic_chset<CharT> > ptr;
    86 };
    87 
    88 ///////////////////////////////////////////////////////////////////////////////
    89 //
    90 //  Generator functions
    91 //
    92 ///////////////////////////////////////////////////////////////////////////////
    93 template <typename CharT>
    94 inline chset<CharT>
    95 chset_p(chlit<CharT> const& arg_)
    96 { return chset<CharT>(arg_); }
    97 
    98 //////////////////////////////////
    99 template <typename CharT>
   100 inline chset<CharT>
   101 chset_p(range<CharT> const& arg_)
   102 { return chset<CharT>(arg_); }
   103 
   104 template <typename CharT>
   105 inline chset<CharT>
   106 chset_p(negated_char_parser<chlit<CharT> > const& arg_)
   107 { return chset<CharT>(arg_); }
   108 
   109 template <typename CharT>
   110 inline chset<CharT>
   111 chset_p(negated_char_parser<range<CharT> > const& arg_)
   112 { return chset<CharT>(arg_); }
   113 
   114 //////////////////////////////////
   115 inline chset<char>
   116 chset_p(char const* init)
   117 { return chset<char>(init); }
   118 
   119 //////////////////////////////////
   120 inline chset<wchar_t>
   121 chset_p(wchar_t const* init)
   122 { return chset<wchar_t>(init); }
   123 
   124 //////////////////////////////////
   125 inline chset<char>
   126 chset_p(char ch)
   127 { return chset<char>(ch); }
   128 
   129 //////////////////////////////////
   130 inline chset<wchar_t>
   131 chset_p(wchar_t ch)
   132 { return chset<wchar_t>(ch); }
   133 
   134 //////////////////////////////////
   135 inline chset<int>
   136 chset_p(int ch)
   137 { return chset<int>(ch); }
   138 
   139 //////////////////////////////////
   140 inline chset<unsigned int>
   141 chset_p(unsigned int ch)
   142 { return chset<unsigned int>(ch); }
   143 
   144 //////////////////////////////////
   145 inline chset<short>
   146 chset_p(short ch)
   147 { return chset<short>(ch); }
   148 
   149 #if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
   150 //////////////////////////////////
   151 inline chset<unsigned short>
   152 chset_p(unsigned short ch)
   153 { return chset<unsigned short>(ch); }
   154 #endif
   155 //////////////////////////////////
   156 inline chset<long>
   157 chset_p(long ch)
   158 { return chset<long>(ch); }
   159 
   160 //////////////////////////////////
   161 inline chset<unsigned long>
   162 chset_p(unsigned long ch)
   163 { return chset<unsigned long>(ch); }
   164 
   165 #ifdef BOOST_HAS_LONG_LONG
   166 //////////////////////////////////
   167 inline chset< ::boost::long_long_type>
   168 chset_p( ::boost::long_long_type ch)
   169 { return chset< ::boost::long_long_type>(ch); }
   170 
   171 //////////////////////////////////
   172 inline chset< ::boost::ulong_long_type>
   173 chset_p( ::boost::ulong_long_type ch)
   174 { return chset< ::boost::ulong_long_type>(ch); }
   175 #endif
   176 
   177 ///////////////////////////////////////////////////////////////////////////////
   178 }} // namespace boost::spirit
   179 
   180 #endif
   181 
   182 #include <boost/spirit/utility/impl/chset.ipp>
   183 #include <boost/spirit/utility/chset_operators.hpp>