sl@0: /*============================================================================= sl@0: Copyright (c) 2001-2003 Joel de Guzman sl@0: Copyright (c) 2001-2003 Daniel Nuffer sl@0: http://spirit.sourceforge.net/ sl@0: sl@0: Use, modification and distribution is subject to the Boost Software sl@0: License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: http://www.boost.org/LICENSE_1_0.txt) sl@0: =============================================================================*/ sl@0: #ifndef BOOST_SPIRIT_CHSET_HPP sl@0: #define BOOST_SPIRIT_CHSET_HPP sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: namespace boost { namespace spirit { sl@0: sl@0: namespace utility { namespace impl { sl@0: sl@0: // This is here because some compilers choke on out-of-line member sl@0: // template functions. And we don't want to put the whole algorithm sl@0: // in the chset constructor in the class definition. sl@0: template sl@0: void construct_chset(boost::shared_ptr >& ptr, sl@0: CharT2 const* definition); sl@0: sl@0: }} // namespace utility::impl sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // sl@0: // chset class sl@0: // sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: template sl@0: class chset: public char_parser > { sl@0: sl@0: public: sl@0: chset(); sl@0: chset(chset const& arg_); sl@0: explicit chset(CharT arg_); sl@0: explicit chset(anychar_parser arg_); sl@0: explicit chset(nothing_parser arg_); sl@0: explicit chset(chlit const& arg_); sl@0: explicit chset(range const& arg_); sl@0: explicit chset(negated_char_parser > const& arg_); sl@0: explicit chset(negated_char_parser > const& arg_); sl@0: sl@0: template sl@0: explicit chset(CharT2 const* definition) sl@0: : ptr(new basic_chset()) sl@0: { sl@0: utility::impl::construct_chset(ptr, definition); sl@0: } sl@0: ~chset(); sl@0: sl@0: chset& operator=(chset const& rhs); sl@0: chset& operator=(CharT rhs); sl@0: chset& operator=(anychar_parser rhs); sl@0: chset& operator=(nothing_parser rhs); sl@0: chset& operator=(chlit const& rhs); sl@0: chset& operator=(range const& rhs); sl@0: chset& operator=(negated_char_parser > const& rhs); sl@0: chset& operator=(negated_char_parser > const& rhs); sl@0: sl@0: void set(range const& arg_); sl@0: void set(negated_char_parser > const& arg_); sl@0: void set(negated_char_parser > const& arg_); sl@0: sl@0: void clear(range const& arg_); sl@0: void clear(negated_char_parser > const& arg_); sl@0: bool test(CharT ch) const; sl@0: chset& inverse(); sl@0: void swap(chset& x); sl@0: sl@0: chset& operator|=(chset const& x); sl@0: chset& operator&=(chset const& x); sl@0: chset& operator-=(chset const& x); sl@0: chset& operator^=(chset const& x); sl@0: sl@0: private: sl@0: sl@0: boost::shared_ptr > ptr; sl@0: }; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: // sl@0: // Generator functions sl@0: // sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: template sl@0: inline chset sl@0: chset_p(chlit const& arg_) sl@0: { return chset(arg_); } sl@0: sl@0: ////////////////////////////////// sl@0: template sl@0: inline chset sl@0: chset_p(range const& arg_) sl@0: { return chset(arg_); } sl@0: sl@0: template sl@0: inline chset sl@0: chset_p(negated_char_parser > const& arg_) sl@0: { return chset(arg_); } sl@0: sl@0: template sl@0: inline chset sl@0: chset_p(negated_char_parser > const& arg_) sl@0: { return chset(arg_); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(char const* init) sl@0: { return chset(init); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(wchar_t const* init) sl@0: { return chset(init); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(char ch) sl@0: { return chset(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(wchar_t ch) sl@0: { return chset(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(int ch) sl@0: { return chset(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(unsigned int ch) sl@0: { return chset(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(short ch) sl@0: { return chset(ch); } sl@0: sl@0: #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(unsigned short ch) sl@0: { return chset(ch); } sl@0: #endif sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(long ch) sl@0: { return chset(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset sl@0: chset_p(unsigned long ch) sl@0: { return chset(ch); } sl@0: sl@0: #ifdef BOOST_HAS_LONG_LONG sl@0: ////////////////////////////////// sl@0: inline chset< ::boost::long_long_type> sl@0: chset_p( ::boost::long_long_type ch) sl@0: { return chset< ::boost::long_long_type>(ch); } sl@0: sl@0: ////////////////////////////////// sl@0: inline chset< ::boost::ulong_long_type> sl@0: chset_p( ::boost::ulong_long_type ch) sl@0: { return chset< ::boost::ulong_long_type>(ch); } sl@0: #endif sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////// sl@0: }} // namespace boost::spirit sl@0: sl@0: #endif sl@0: sl@0: #include sl@0: #include