Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:02:35

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file null_regex_traits.hpp
0003 /// Contains the definition of the null_regex_traits\<\> template, which is a
0004 /// stub regex traits implementation that can be used by static and dynamic
0005 /// regexes for searching non-character data.
0006 //
0007 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0008 //  Software License, Version 1.0. (See accompanying file
0009 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_XPRESSIVE_TRAITS_NULL_REGEX_TRAITS_HPP_EAN_10_04_2005
0012 #define BOOST_XPRESSIVE_TRAITS_NULL_REGEX_TRAITS_HPP_EAN_10_04_2005
0013 
0014 // MS compatible compilers support #pragma once
0015 #if defined(_MSC_VER)
0016 # pragma once
0017 #endif
0018 
0019 #include <vector>
0020 #include <boost/assert.hpp>
0021 #include <boost/mpl/assert.hpp>
0022 #include <boost/xpressive/detail/detail_fwd.hpp>
0023 #include <boost/xpressive/detail/utility/never_true.hpp>
0024 #include <boost/xpressive/detail/utility/ignore_unused.hpp>
0025 
0026 namespace boost { namespace xpressive
0027 {
0028 
0029 namespace detail
0030 {
0031     struct not_a_locale {};
0032 }
0033 
0034 struct regex_traits_version_1_tag;
0035 
0036 ///////////////////////////////////////////////////////////////////////////////
0037 // null_regex_traits
0038 //
0039 /// \brief stub regex_traits for non-char data
0040 ///
0041 template<typename Elem>
0042 struct null_regex_traits
0043 {
0044     typedef Elem char_type;
0045     typedef std::vector<char_type> string_type;
0046     typedef detail::not_a_locale locale_type;
0047     typedef int char_class_type;
0048     typedef regex_traits_version_1_tag version_tag;
0049 
0050     /// Initialize a null_regex_traits object.
0051     ///
0052     null_regex_traits(locale_type = locale_type())
0053     {
0054     }
0055 
0056     /// Checks two null_regex_traits objects for equality
0057     ///
0058     /// \return true.
0059     bool operator ==(null_regex_traits<char_type> const &that) const
0060     {
0061         detail::ignore_unused(that);
0062         return true;
0063     }
0064 
0065     /// Checks two null_regex_traits objects for inequality
0066     ///
0067     /// \return false.
0068     bool operator !=(null_regex_traits<char_type> const &that) const
0069     {
0070         detail::ignore_unused(that);
0071         return false;
0072     }
0073 
0074     /// Convert a char to a Elem
0075     ///
0076     /// \param ch The source character.
0077     /// \return Elem(ch).
0078     char_type widen(char ch) const
0079     {
0080         return char_type(ch);
0081     }
0082 
0083     /// Returns a hash value for a Elem in the range [0, UCHAR_MAX]
0084     ///
0085     /// \param ch The source character.
0086     /// \return a value between 0 and UCHAR_MAX, inclusive.
0087     static unsigned char hash(char_type ch)
0088     {
0089         return static_cast<unsigned char>(ch);
0090     }
0091 
0092     /// No-op
0093     ///
0094     /// \param ch The source character.
0095     /// \return ch
0096     static char_type translate(char_type ch)
0097     {
0098         return ch;
0099     }
0100 
0101     /// No-op
0102     ///
0103     /// \param ch The source character.
0104     /// \return ch
0105     static char_type translate_nocase(char_type ch)
0106     {
0107         return ch;
0108     }
0109 
0110     /// Checks to see if a character is within a character range.
0111     ///
0112     /// \param first The bottom of the range, inclusive.
0113     /// \param last The top of the range, inclusive.
0114     /// \param ch The source character.
0115     /// \return first <= ch && ch <= last.
0116     static bool in_range(char_type first, char_type last, char_type ch)
0117     {
0118         return first <= ch && ch <= last;
0119     }
0120 
0121     /// Checks to see if a character is within a character range.
0122     ///
0123     /// \param first The bottom of the range, inclusive.
0124     /// \param last The top of the range, inclusive.
0125     /// \param ch The source character.
0126     /// \return first <= ch && ch <= last.
0127     /// \attention Since the null_regex_traits does not do case-folding,
0128     /// this function is equivalent to in_range().
0129     static bool in_range_nocase(char_type first, char_type last, char_type ch)
0130     {
0131         return first <= ch && ch <= last;
0132     }
0133 
0134     /// Returns a sort key for the character sequence designated by the iterator range [F1, F2)
0135     /// such that if the character sequence [G1, G2) sorts before the character sequence [H1, H2)
0136     /// then v.transform(G1, G2) < v.transform(H1, H2).
0137     ///
0138     /// \attention Not currently used
0139     template<typename FwdIter>
0140     static string_type transform(FwdIter begin, FwdIter end)
0141     {
0142         return string_type(begin, end);
0143     }
0144 
0145     /// Returns a sort key for the character sequence designated by the iterator range [F1, F2)
0146     /// such that if the character sequence [G1, G2) sorts before the character sequence [H1, H2)
0147     /// when character case is not considered then
0148     /// v.transform_primary(G1, G2) < v.transform_primary(H1, H2).
0149     ///
0150     /// \attention Not currently used
0151     template<typename FwdIter>
0152     static string_type transform_primary(FwdIter begin, FwdIter end)
0153     {
0154         return string_type(begin, end);
0155     }
0156 
0157     /// Returns a sequence of characters that represents the collating element
0158     /// consisting of the character sequence designated by the iterator range [F1, F2).
0159     /// Returns an empty string if the character sequence is not a valid collating element.
0160     ///
0161     /// \attention Not currently used
0162     template<typename FwdIter>
0163     static string_type lookup_collatename(FwdIter begin, FwdIter end)
0164     {
0165         detail::ignore_unused(begin);
0166         detail::ignore_unused(end);
0167         return string_type();
0168     }
0169 
0170     /// The null_regex_traits does not have character classifications, so lookup_classname()
0171     /// is unused.
0172     ///
0173     /// \param begin not used
0174     /// \param end not used
0175     /// \param icase not used
0176     /// \return static_cast\<char_class_type\>(0)
0177     template<typename FwdIter>
0178     static char_class_type lookup_classname(FwdIter begin, FwdIter end, bool icase)
0179     {
0180         detail::ignore_unused(begin);
0181         detail::ignore_unused(end);
0182         detail::ignore_unused(icase);
0183         return 0;
0184     }
0185 
0186     /// The null_regex_traits does not have character classifications, so isctype()
0187     /// is unused.
0188     ///
0189     /// \param ch not used
0190     /// \param mask not used
0191     /// \return false
0192     static bool isctype(char_type ch, char_class_type mask)
0193     {
0194         detail::ignore_unused(ch);
0195         detail::ignore_unused(mask);
0196         return false;
0197     }
0198 
0199     /// The null_regex_traits recognizes no elements as digits, so value() is unused.
0200     ///
0201     /// \param ch not used
0202     /// \param radix not used
0203     /// \return -1
0204     static int value(char_type ch, int radix)
0205     {
0206         detail::ignore_unused(ch);
0207         detail::ignore_unused(radix);
0208         return -1;
0209     }
0210 
0211     /// Not used
0212     ///
0213     /// \param loc not used
0214     /// \return loc
0215     static locale_type imbue(locale_type loc)
0216     {
0217         return loc;
0218     }
0219 
0220     /// Returns locale_type().
0221     ///
0222     /// \return locale_type()
0223     static locale_type getloc()
0224     {
0225         return locale_type();
0226     }
0227 };
0228 
0229 }}
0230 
0231 #endif