Home | Libraries | People | FAQ | More |
boost::xpressive::cpp_regex_traits — Encapsaulates a std::locale for use by the basic_regex<> class template.
// In header: <boost/xpressive/traits/cpp_regex_traits.hpp> template<typename Char> struct cpp_regex_traits { // types typedef Char char_type; typedef std::basic_string< char_type > string_type; typedef std::locale locale_type; typedef unspecified char_class_type; typedef regex_traits_version_2_tag version_tag; typedef unspecified base_type; // construct/copy/destruct cpp_regex_traits(locale_type const & = locale_type()); // public member functions bool operator==(cpp_regex_traits< char_type > const &) const; bool operator!=(cpp_regex_traits< char_type > const &) const; char_type widen(char) const; char_type translate_nocase(char_type) const; char_type tolower(char_type) const; char_type toupper(char_type) const; string_type fold_case(char_type) const; bool in_range_nocase(char_type, char_type, char_type) const; template<typename FwdIter> string_type transform_primary(FwdIter, FwdIter) const; template<typename FwdIter> string_type lookup_collatename(FwdIter, FwdIter) const; template<typename FwdIter> char_class_type lookup_classname(FwdIter, FwdIter, bool) const; bool isctype(char_type, char_class_type) const; int value(char_type, int) const; locale_type imbue(locale_type); locale_type getloc() const; template<> unsigned char hash(unsigned char); template<> unsigned char hash(char); template<> unsigned char hash(signed char); template<> unsigned char hash(wchar_t); // public static functions static unsigned char hash(char_type); static char_type translate(char_type); static bool in_range(char_type, char_type, char_type); };
cpp_regex_traits
public
construct/copy/destructcpp_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.
cpp_regex_traits
public member functionsbool operator==(cpp_regex_traits< char_type > const & that) const;
Checks two cpp_regex_traits
objects for equality
Returns: |
this->getloc() == that.getloc(). |
bool operator!=(cpp_regex_traits< char_type > const & that) const;
Checks two cpp_regex_traits
objects for inequality
Returns: |
this->getloc() != that.getloc(). |
char_type widen(char ch) const;
Convert a char to a Char
Parameters: |
|
||
Returns: |
std::use_facet<std::ctype<char_type> >(this->getloc()).widen(ch). |
char_type translate_nocase(char_type ch) const;
Converts a character to lower-case using the internally-stored std::locale.
Parameters: |
|
||
Returns: |
std::tolower(ch, this->getloc()). |
char_type tolower(char_type ch) const;
Converts a character to lower-case using the internally-stored std::locale.
Parameters: |
|
||
Returns: |
std::tolower(ch, this->getloc()). |
char_type toupper(char_type ch) const;
Converts a character to upper-case using the internally-stored std::locale.
Parameters: |
|
||
Returns: |
std::toupper(ch, this->getloc()). |
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. This function can only be called if has_fold_case
<cpp_regex_traits
<Char> >::value is true.
Parameters: |
|
||
Returns: |
string_type containing all chars which are equal to ch when disregarding case |
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.
Note | |
---|---|
The default implementation doesn't do proper Unicode case folding, but this is the best we can do with the standard ctype facet. |
Parameters: |
|
||||||
Returns: |
in_range(first, last, ch) || in_range(first, last, tolower(ch, this->getloc())) || in_range(first, last, toupper(ch, this->getloc())) |
template<typename FwdIter> string_type transform_primary(FwdIter begin, FwdIter end) 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).
Note | |
---|---|
Not currently used |
template<typename FwdIter> string_type lookup_collatename(FwdIter begin, FwdIter end) const;
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.
Note | |
---|---|
Not currently used |
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.
Parameters: |
|
||||||
Returns: |
A bitmask representing the character class. |
bool isctype(char_type ch, char_class_type mask) const;
Tests a character against a character class bitmask.
Parameters: |
|
||||
Requires: |
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. |
int value(char_type ch, int radix) const;
Convert a digit character into the integer it represents.
Parameters: |
|
||||
Requires: |
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. |
locale_type imbue(locale_type loc);
Imbues *this with loc
Parameters: |
|
||
Returns: |
the previous std::locale used by *this. |
locale_type getloc() const;
Returns the current std::locale used by *this.
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);
cpp_regex_traits
public static functionsstatic unsigned char hash(char_type ch);
Returns a hash value for a Char in the range [0, UCHAR_MAX]
Parameters: |
|
||
Returns: |
a value between 0 and UCHAR_MAX, inclusive. |
static char_type translate(char_type ch);
No-op
Parameters: |
|
||
Returns: |
ch |
static bool in_range(char_type first, char_type last, char_type ch);
Checks to see if a character is within a character range.
Parameters: |
|
||||||
Returns: |
first <= ch && ch <= last. |