c_regex_traits 構造体テンプレート

template<typename Char>
struct c_regex_traits

basic_regex<> クラステンプレートで使用するために標準の C ロカール関数をカプセル化する。

概要

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

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

  // 公開メンバ関数
  bool operator==(c_regex_traits< char_type > const &) const;
  bool operator!=(c_regex_traits< char_type > const &) const;
  string_type fold_case(char_type) const;
  locale_type imbue(locale_type);
  template<> char widen(char);
  template<> wchar_t widen(char);
  template<> unsigned char hash(char);
  template<> unsigned char hash(wchar_t);
  template<> int value(char, int);
  template<> int value(wchar_t, int);

  // 公開静的メンバ関数
  static char_type widen(char);
  static unsigned char hash(char_type);
  static char_type translate(char_type);
  static char_type translate_nocase(char_type);
  static char_type tolower(char_type);
  static char_type toupper(char_type);
  static bool in_range(char_type, char_type, char_type);
  static bool in_range_nocase(char_type, char_type, char_type);
  template<typename FwdIter> static string_type transform(FwdIter, FwdIter);
  template<typename FwdIter>
    static string_type transform_primary(FwdIter, FwdIter);
  template<typename FwdIter>
    static string_type lookup_collatename(FwdIter, FwdIter);
  template<typename FwdIter>
    static char_class_type lookup_classname(FwdIter, FwdIter, bool);
  static bool isctype(char_type, char_class_type);
  static int value(char_type, int);
  static locale_type getloc();
};

説明

c_regex_traits 構築、コピー、解体の公開演算

c_regex_traits(locale_type const &loc = locale_type())

グローバルな C ロカールを使用する c_regex_traits オブジェクトを初期化する。

c_regex_traits 公開メンバ関数

bool operator==(c_regex_traits<char_type> const&) const

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

戻り値

真。

bool operator!=(c_regex_traits<char_type> const&) const

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

戻り値

偽。

string_type fold_case(char_type ch) const

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

パラメータ

ch -- 元の文字。

戻り値

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

locale_type imbue(locale_type loc)

何もしない。

template<>
char widen(char ch)
template<>
wchar_t widen(char ch)
template<>
unsigned char hash(char ch)
template<>
unsigned char hash(wchar_t ch)
template<>
int value(char ch, int radix)
template<>
int value(wchar_t ch, int radix)

c_regex_traits 公開静的メンバ関数

static char_type widen(char ch)

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

パラメータ

ch -- 元の文字。

戻り値

Charchar であれば chCharwchar_t であれば std::btowc(ch)

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 char_type translate_nocase(char_type ch)

現在のグローバルな C ロカールを使用して、文字を小文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

Charchar であれば std::tolower(ch)Charwchar_t であれば std::towlower(ch)

static char_type tolower(char_type ch)

現在のグローバルな C ロカールを使用して、文字を小文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

Charchar であれば std::tolower(ch)Charwchar_t であれば std::towlower(ch)

static char_type toupper(char_type ch)

現在のグローバルな C ロカールを使用して、文字を大文字に変換する。

パラメータ

ch -- 元の文字。

戻り値

Charchar であれば std::toupper(ch)Charwchar_t であれば std::towupper(ch)

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

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

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

  • first -- 範囲の下限。

  • last -- 範囲の上限。

戻り値

first <= ch && ch <= last

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

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

注釈

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

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

  • first -- 範囲の下限。

  • last -- 範囲の上限。

戻り値

in_range(first, last, ch) || in_range(first, last, tolower(ch)) || in_range(first, last, toupper(ch))

template<typename FwdIter>
static string_type transform(FwdIter begin, FwdIter end)

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

注釈

現在使用していない。

template<typename FwdIter>
static string_type transform_primary(FwdIter begin, FwdIter end)

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

注釈

現在使用していない。

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

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

注釈

現在使用していない。

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

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

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

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

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

戻り値

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

static bool isctype(char_type ch, char_class_type mask)

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

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

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

要件

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

戻り値

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

static int value(char_type ch, int radix)

数字を数値に変換する。

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

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

要件

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

戻り値

ch が数字でなければ -1 、それ以外は文字が表す数値。char_typechar であれば std::strtol を、char_typewchar_t であれば std::wcstol を使用する。

static locale_type getloc()

何もしない。