cpp_regex_traits 構造体テンプレート

template<typename Char>
struct cpp_regex_traits

basic_regex<> クラステンプレートで使用するために std::locale をカプセル化する。

概要

// ヘッダ:<boost/xpressive/xpressive_fwd.hpp>

template<typename Char>
struct cpp_regex_traits {
  // 構築、コピー、解体
  cpp_regex_traits(locale_type const & = locale_type());

  // 公開メンバ関数
  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);

  // 公開静的メンバ関数
  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 構築、コピー、解体の公開演算

cpp_regex_traits(locale_type const &loc = locale_type())

指定した std::locale を使用する cpp_regex_traits オブジェクトを初期化する。引数を省略した場合はグローバルな std::locale を使用する。

cpp_regex_traits 公開メンバ関数

bool operator==(cpp_regex_traits<char_type> const &that) const

2 つの cpp_regex_traits オブジェクトが等値か調べる。

戻り値

this->getloc() == that.getloc()

bool operator!=(cpp_regex_traits<char_type> const &that) const

2 つの cpp_regex_traits オブジェクトが等値でないか調べる。

戻り値

this->getloc() != that.getloc()

char_type widen(char ch) const

char 型の値を Char 型に変換する。

パラメータ

ch -- 元の文字。

戻り値

std::use_facet<std::ctype<char_type>>(this->getloc()).widen(ch)

char_type translate_nocase(char_type ch)

内部保持した std::locale を使用して、文字を小文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

std::tolower(ch, this->getloc())

char_type tolower(char_type ch)

内部保持した std::locale を使用して、文字を小文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

std::tolower(ch, this->getloc())

char_type toupper(char_type ch)

内部保持した std::locale を使用して、文字を大文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

std::toupper(ch, this->getloc())

string_type fold_case(char_type ch) const

渡した文字と大文字小文字を区別せずに比較すると等値となる文字をすべて含む string_type を返す。この関数が呼び出されるのは has_fold_case<cpp_regex_traits<Char>> が真の場合のみである。

パラメータ

ch -- 元の文字。

戻り値

ch と大文字小文字を区別せずに比較すると等値となる文字をすべて含む string_type

bool in_range_nocase(char_type first, char_type last, char_type ch)

文字が文字範囲に含まれるか調べる。大文字小文字を区別しない。

注釈

既定の実装は適正な Unicode ケースフォールディングを行わないが、標準の ctype ファセットではこれが最善である。

パラメータ
  • ch -- 元の文字。

  • first -- 範囲の下限。

  • last -- 範囲の上限。

戻り値

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, FwdIter)

イテレータ範囲 [F1, F2) が示す文字シーケンスのソートキーを返す。大文字小文字を区別せずにソートして文字シーケンス [G1, G2) が文字シーケンス [H1, H2) の前に現れる場合に v.transform(G1, G2) < v.transform(H1, H2) とならなければならない。

注釈

現在使用していない。

template<typename FwdIter>
string_type lookup_collatename(FwdIter begin, FwdIter end)

イテレータ範囲 [F1, F2) が示す文字シーケンスが構成する照合要素を表す文字シーケンスを返す。文字シーケンスが正しい照合要素でなければ空文字列を返す。

注釈

現在使用していない。

template<typename FwdIter>
char_class_type lookup_classname(FwdIter begin, FwdIter end, bool icase)

指定した文字シーケンスが表す文字分類について、相当するビットマスクを返す。

パラメータ
  • begin -- 文字分類の名前を表す文字シーケンスの先頭を指す前進イテレータ。

  • end -- 文字シーケンスの終端。

  • icase -- 戻り値のビットマスクが大文字小文字を区別しない文字分類を表すかを指定する。

戻り値

文字分類を表すビットマスク。

bool isctype(char_type ch, char_class_type mask)

文字分類ビットマスクに対して文字をテストする。

パラメータ
  • ch -- テストする文字。

  • mask -- テストする文字分類のビットマスク。

要件

masklookup_classname が返したビットマスクか、それらのビット和。

戻り値

文字が指定した文字分類に含まれれば真、それ以外は偽。

int value(char_type ch, int radix) const

数字を数値に変換する。

パラメータ
  • ch -- 数字。

  • radix -- 変換に使用する序数。

要件

radix は 8 、10 、16 のいずれか。

戻り値

ch が数字でなければ -1 、それ以外は文字が表す数値。変換は次の要領で行う:std::stringstreamthis->getloc() を指示する。序数を 8 、16 、10 のいずれかに設定する。ch をストリームに挿入する。int を抽出する。

locale_type imbue(locale_type loc)

*thisloc を指示する。

パラメータ

loc -- std::locale

戻り値

*this が直前まで使用していた std::locale

locale_type getloc() const

*this が現在使用している std::locale を返す。

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 公開静的メンバ関数

static unsigned char hash(char_type ch)

[0, UCHAR_MAX] の範囲で Char のハッシュ値を返す。

パラメータ

ch -- 元の文字。

戻り値

0 以上 UCHAR_MAX 以下の値。

static char_type translate(char_type ch)

何もしない。

パラメータ

ch -- 元の文字。

戻り値

ch

static bool in_range(char_type first, char_type last, char_type ch)

文字が文字範囲に含まれるか調べる。

パラメータ
  • ch -- 元の文字。

  • first -- 範囲の下限。

  • last -- 範囲の上限。

戻り値

first <= ch && ch <= last