Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::xpressive::cpp_regex_traits< Char > Struct Template Reference

Encapsaulates a std::locale for use by the basic_regex<> class template. More...

#include <xpressive_fwd.hpp>

Inheritance diagram for boost::xpressive::cpp_regex_traits< Char >:
Collaboration diagram for boost::xpressive::cpp_regex_traits< Char >:

Public Types

typedef Char char_type
 
typedef std::basic_string
< char_type
string_type
 
typedef std::locale locale_type
 
typedef detail::umaskex_t char_class_type
 
typedef regex_traits_version_2_tag version_tag
 
typedef
detail::cpp_regex_traits_base
< Char > 
base_type
 

Public Member Functions

 cpp_regex_traits (locale_type const &loc=locale_type())
 Initialize a cpp_regex_traits object to use the specified std::locale, or the global std::locale if none is specified. More...
 
bool operator== (cpp_regex_traits< char_type > const &that) const
 Checks two cpp_regex_traits objects for equality. More...
 
bool operator!= (cpp_regex_traits< char_type > const &that) const
 Checks two cpp_regex_traits objects for inequality. More...
 
char_type widen (char ch) const
 Convert a char to a Char. More...
 
char_type translate_nocase (char_type ch) const
 Converts a character to lower-case using the internally-stored std::locale. More...
 
char_type tolower (char_type ch) const
 Converts a character to lower-case using the internally-stored std::locale. More...
 
char_type toupper (char_type ch) const
 Converts a character to upper-case using the internally-stored std::locale. More...
 
string_type fold_case (char_type ch) const
 Returns a string_type containing all the characters that compare equal disregrarding case to the one passed in. More...
 
bool in_range_nocase (char_type first, char_type last, char_type ch) const
 Checks to see if a character is within a character range, irregardless of case. More...
 
template<typename FwdIter >
string_type transform (FwdIter, FwdIter) const
 INTERNAL ONLY. More...
 
template<typename FwdIter >
string_type transform_primary (FwdIter, FwdIter) const
 Returns a sort key for the character sequence designated by the iterator range [F1, F2) such that if the character sequence [G1, G2) sorts before the character sequence [H1, H2) when character case is not considered then v.transform_primary(G1, G2) < v.transform_primary(H1, H2). More...
 
template<typename FwdIter >
string_type lookup_collatename (FwdIter, FwdIter) const
 Returns a sequence of characters that represents the collating element consisting of the character sequence designated by the iterator range [F1, F2). More...
 
template<typename FwdIter >
char_class_type lookup_classname (FwdIter begin, FwdIter end, bool icase) const
 For the character class name represented by the specified character sequence, return the corresponding bitmask representation. More...
 
bool isctype (char_type ch, char_class_type mask) const
 Tests a character against a character class bitmask. More...
 
int value (char_type ch, int radix) const
 Convert a digit character into the integer it represents. More...
 
locale_type imbue (locale_type loc)
 Imbues *this with loc. More...
 
locale_type getloc () const
 Returns the current std::locale used by *this. More...
 
template<>
unsigned char hash (unsigned char ch)
 
template<>
unsigned char hash (char ch)
 
template<>
unsigned char hash (signed char ch)
 
template<>
unsigned char hash (wchar_t ch)
 

Static Public Member Functions

static unsigned char hash (char_type ch)
 Returns a hash value for a Char in the range [0, UCHAR_MAX]. More...
 
static char_type translate (char_type ch)
 No-op. More...
 
static bool in_range (char_type first, char_type last, char_type ch)
 Checks to see if a character is within a character range. More...
 

Protected Member Functions

void imbue (std::locale const &)
 

Static Protected Member Functions

static bool is (std::ctype< Char > const &ct, Char ch, umaskex_t mask)
 

Detailed Description

template<typename Char>
struct boost::xpressive::cpp_regex_traits< Char >

Encapsaulates a std::locale for use by the basic_regex<> class template.

Member Typedef Documentation

template<typename Char>
typedef detail::cpp_regex_traits_base<Char> boost::xpressive::cpp_regex_traits< Char >::base_type
template<typename Char>
typedef detail::umaskex_t boost::xpressive::cpp_regex_traits< Char >::char_class_type
template<typename Char>
typedef Char boost::xpressive::cpp_regex_traits< Char >::char_type
template<typename Char>
typedef std::locale boost::xpressive::cpp_regex_traits< Char >::locale_type
template<typename Char>
typedef std::basic_string<char_type> boost::xpressive::cpp_regex_traits< Char >::string_type

Constructor & Destructor Documentation

template<typename Char>
boost::xpressive::cpp_regex_traits< Char >::cpp_regex_traits ( locale_type const &  loc = locale_type())
inline

Initialize a cpp_regex_traits object to use the specified std::locale, or the global std::locale if none is specified.

References boost::xpressive::cpp_regex_traits< Char >::imbue().

Member Function Documentation

template<typename Char>
string_type boost::xpressive::cpp_regex_traits< Char >::fold_case ( char_type  ch) const
inline

Returns a string_type containing all the characters that compare equal disregrarding case to the one passed in.

This function can only be called if has_fold_case<cpp_regex_traits<Char> >::value is true.

Parameters
chThe source character.
Returns
string_type containing all chars which are equal to ch when disregarding case

References BOOST_MPL_ASSERT.

template<typename Char>
locale_type boost::xpressive::cpp_regex_traits< Char >::getloc ( ) const
inline

Returns the current std::locale used by *this.

Referenced by boost::xpressive::cpp_regex_traits< Char >::value().

template<typename Char>
static unsigned char boost::xpressive::cpp_regex_traits< Char >::hash ( char_type  ch)
inlinestatic

Returns a hash value for a Char in the range [0, UCHAR_MAX].

Parameters
chThe source character.
Returns
a value between 0 and UCHAR_MAX, inclusive.
template<>
unsigned char boost::xpressive::cpp_regex_traits< unsigned char >::hash ( unsigned char  ch)
inline
template<>
unsigned char boost::xpressive::cpp_regex_traits< char >::hash ( char  ch)
inline
template<>
unsigned char boost::xpressive::cpp_regex_traits< signed char >::hash ( signed char  ch)
inline
template<>
unsigned char boost::xpressive::cpp_regex_traits< wchar_t >::hash ( wchar_t  ch)
inline
void boost::xpressive::detail::cpp_regex_traits_base< Char, SizeOfChar >::imbue ( std::locale const &  )
inlineprotectedinherited
template<typename Char>
locale_type boost::xpressive::cpp_regex_traits< Char >::imbue ( locale_type  loc)
inline

Imbues *this with loc.

Parameters
locA std::locale.
Returns
the previous std::locale used by *this.

References BOOST_USE_FACET, and boost::xpressive::detail::cpp_regex_traits_base< Char >::imbue().

Referenced by boost::xpressive::cpp_regex_traits< Char >::cpp_regex_traits().

template<typename Char>
static bool boost::xpressive::cpp_regex_traits< Char >::in_range ( char_type  first,
char_type  last,
char_type  ch 
)
inlinestatic

Checks to see if a character is within a character range.

Parameters
firstThe bottom of the range, inclusive.
lastThe top of the range, inclusive.
chThe source character.
Returns
first <= ch && ch <= last.

References boost::last.

Referenced by boost::xpressive::cpp_regex_traits< Char >::in_range_nocase().

template<typename Char>
bool boost::xpressive::cpp_regex_traits< Char >::in_range_nocase ( char_type  first,
char_type  last,
char_type  ch 
) const
inline

Checks to see if a character is within a character range, irregardless of case.

Parameters
firstThe bottom of the range, inclusive.
lastThe top of the range, inclusive.
chThe source character.
Returns
in_range(first, last, ch) || in_range(first, last, tolower(ch, this->getloc())) || in_range(first, last, toupper(ch, this->getloc()))
Attention
The default implementation doesn't do proper Unicode case folding, but this is the best we can do with the standard ctype facet.

References boost::xpressive::cpp_regex_traits< Char >::in_range().

static bool boost::xpressive::detail::cpp_regex_traits_base< Char, SizeOfChar >::is ( std::ctype< Char > const &  ct,
Char  ch,
umaskex_t  mask 
)
inlinestaticprotectedinherited
template<typename Char>
bool boost::xpressive::cpp_regex_traits< Char >::isctype ( char_type  ch,
char_class_type  mask 
) const
inline

Tests a character against a character class bitmask.

Parameters
chThe character to test.
maskThe character class bitmask against which to test.
Precondition
mask is a bitmask returned by lookup_classname, or is several such masks bit-or'ed together.
Returns
true if the character is a member of any of the specified character classes, false otherwise.

References boost::xpressive::detail::cpp_regex_traits_base< Char >::is().

template<typename Char>
template<typename FwdIter >
char_class_type boost::xpressive::cpp_regex_traits< Char >::lookup_classname ( FwdIter  begin,
FwdIter  end,
bool  icase 
) const
inline

For the character class name represented by the specified character sequence, return the corresponding bitmask representation.

Parameters
beginA forward iterator to the start of the character sequence representing the name of the character class.
endThe end of the character sequence.
icaseSpecifies whether the returned bitmask should represent the case-insensitive version of the character class.
Returns
A bitmask representing the character class.

References BOOST_ASSERT, boost::multiprecision::backends::i, boost::python::len(), boost::xpressive::detail::std_ctype_lower, boost::xpressive::detail::std_ctype_upper, and boost::xpressive::cpp_regex_traits< Char >::translate_nocase().

template<typename Char>
template<typename FwdIter >
string_type boost::xpressive::cpp_regex_traits< Char >::lookup_collatename ( FwdIter  ,
FwdIter   
) const
inline

Returns a sequence of characters that represents the collating element consisting of the character sequence designated by the iterator range [F1, F2).

Returns an empty string if the character sequence is not a valid collating element.

Attention
Not currently used

References BOOST_ASSERT.

template<typename Char>
bool boost::xpressive::cpp_regex_traits< Char >::operator!= ( cpp_regex_traits< char_type > const &  that) const
inline

Checks two cpp_regex_traits objects for inequality.

Returns
this->getloc() != that.getloc().
template<typename Char>
bool boost::xpressive::cpp_regex_traits< Char >::operator== ( cpp_regex_traits< char_type > const &  that) const
inline

Checks two cpp_regex_traits objects for equality.

Returns
this->getloc() == that.getloc().
template<typename Char>
char_type boost::xpressive::cpp_regex_traits< Char >::tolower ( char_type  ch) const
inline

Converts a character to lower-case using the internally-stored std::locale.

Parameters
chThe source character.
Returns
std::tolower(ch, this->getloc()).
template<typename Char>
char_type boost::xpressive::cpp_regex_traits< Char >::toupper ( char_type  ch) const
inline

Converts a character to upper-case using the internally-stored std::locale.

Parameters
chThe source character.
Returns
std::toupper(ch, this->getloc()).
template<typename Char>
template<typename FwdIter >
string_type boost::xpressive::cpp_regex_traits< Char >::transform ( FwdIter  ,
FwdIter   
) const
inline

INTERNAL ONLY.

Returns a sort key for the character sequence designated by the iterator range [F1, F2) such that if the character sequence [G1, G2) sorts before the character sequence [H1, H2) then v.transform(G1, G2) < v.transform(H1, H2).

Attention
Not currently used

References BOOST_ASSERT.

template<typename Char>
template<typename FwdIter >
string_type boost::xpressive::cpp_regex_traits< Char >::transform_primary ( FwdIter  ,
FwdIter   
) const
inline

Returns a sort key for the character sequence designated by the iterator range [F1, F2) such that if the character sequence [G1, G2) sorts before the character sequence [H1, H2) when character case is not considered then v.transform_primary(G1, G2) < v.transform_primary(H1, H2).

Attention
Not currently used

References BOOST_ASSERT.

template<typename Char>
static char_type boost::xpressive::cpp_regex_traits< Char >::translate ( char_type  ch)
inlinestatic

No-op.

Parameters
chThe source character.
Returns
ch
template<typename Char>
char_type boost::xpressive::cpp_regex_traits< Char >::translate_nocase ( char_type  ch) const
inline

Converts a character to lower-case using the internally-stored std::locale.

Parameters
chThe source character.
Returns
std::tolower(ch, this->getloc()).

Referenced by boost::xpressive::cpp_regex_traits< Char >::lookup_classname().

template<typename Char>
int boost::xpressive::cpp_regex_traits< Char >::value ( char_type  ch,
int  radix 
) const
inline

Convert a digit character into the integer it represents.

Parameters
chThe digit character.
radixThe radix to use for the conversion.
Precondition
radix is one of 8, 10, or 16.
Returns
-1 if ch is not a digit character, the integer value of the character otherwise. The conversion is performed by imbueing a std::stringstream with this->getloc(); setting the radix to one of oct, hex or dec; inserting ch into the stream; and extracting an int.

References BOOST_ASSERT, boost::xpressive::cpp_regex_traits< Char >::getloc(), boost::spirit::x3::hex, boost::spirit::x3::oct, boost::xpressive::str, and boost::xpressive::val().

template<typename Char>
char_type boost::xpressive::cpp_regex_traits< Char >::widen ( char  ch) const
inline

Convert a char to a Char.

Parameters
chThe source character.
Returns
std::use_facet<std::ctype<char_type> >(this->getloc()).widen(ch).

The documentation for this struct was generated from the following file: