regex_compiler 構造体テンプレート

template<typename BidiIter, typename RegexTraits, typename CompilerTraits>
struct regex_compiler

regex_compiler クラステンプレートは文字列から basic_regex オブジェクトを構築するファクトリである。

概要

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

template<typename BidiIter, typename RegexTraits, typename CompilerTraits>
struct regex_compiler {
  // 型
  typedef BidiIter                            iterator_type;
  typedef iterator_value< BidiIter >::type    char_type;
  typedef regex_constants::syntax_option_type flag_type;
  typedef RegexTraits                         traits_type;
  typedef traits_type::string_type            string_type;
  typedef traits_type::locale_type            locale_type;
  typedef traits_type::char_class_type        char_class_type;

  // 構築、コピー、解体
  explicit regex_compiler(RegexTraits const & = RegexTraits());

  // 公開メンバ関数
  locale_type imbue(locale_type);
  locale_type getloc() const;
  template<typename InputIter>
    basic_regex< BidiIter >
  compile(InputIter, InputIter, flag_type = regex_constants::ECMAScript);
  template<typename InputRange>
    disable_if< is_pointer< InputRange >, basic_regex< BidiIter > >::type
  compile(InputRange const &, flag_type = regex_constants::ECMAScript);
  basic_regex< BidiIter >
  compile(char_type const *, flag_type = regex_constants::ECMAScript);
  basic_regex< BidiIter > compile(char_type const *, std::size_t, flag_type);
  basic_regex< BidiIter > & operator[](string_type const &);
  basic_regex< BidiIter > const & operator[](string_type const &) const;

  // 非公開メンバ関数
  bool is_upper_(char_type) const;
};

説明

regex_compiler クラステンプレートは、文字列から basic_regex オブジェクトを構築するのに使用する。文字列は正しい正規表現でなければならない。regex_compiler オブジェクトにロカールを指示すると、以降その regex_compiler オブジェクトが作成する basic_regex オブジェクトはすべてそのロカールを使用する。regex_compiler オブジェクト作成後、(必要であればロカールを与え、)正規表現を表す文字列を使って compile メソッドを呼び出すことで basic_regex オブジェクトを構築する。同じ regex_compiler オブジェクトに対して compile は複数回呼び出すことができる。同じ文字列からコンパイルした 2 つの basic_regex オブジェクトは異なる regex_id をもつ。

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

regex_compiler(RegexTraits const &traits = RegexTraits())

regex_compiler 公開メンバ関数

locale_type imbue(locale_type loc)

regex_compiler が使用するロカールを指定する。

パラメータ

loc -- この regex_compiler が使用するロカール。

戻り値

直前のロカール。

locale_type getloc() const

regex_compiler が使用しているロカールを返す。

戻り値

この regex_compiler が使用しているロカール。

template<typename InputIter>
basic_regex<BidiIter> compile(InputIter begin, InputIter end, flag_type flags = regex_constants::ECMAScript)

文字の範囲から basic_regex オブジェクトを構築する。

パラメータ
  • begin -- コンパイルする正規表現を表す文字範囲の先頭。

  • end -- コンパイルする正規表現を表す文字範囲の終端。

  • flags -- パターン文字列をどのように解釈するか決める省略可能なビットマスク(syntax_option_type を見よ)。

要件

InputIter が入力イテレータの要件を満たす。

要件

[begin, end) が有効な範囲である。

要件

[begin, end) で指定した文字範囲が正しい正規表現の文字列表現である。

戻り値

文字範囲が表す正規表現に相当する basic_regex オブジェクト。

例外

regex_error -- 文字範囲に不正な正規表現構文がある場合。

template<typename InputRange>
disable_if<is_pointer<InputRange>, basic_regex<BidiIter>>::type compile(InputRange const &pat, flag_type flags = regex_constants::ECMAScript)

利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。

basic_regex<BidiIter> compile(char_type const *begin, flag_type flags = regex_constants::ECMAScript)

利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。

basic_regex<BidiIter> compile(char_type const *begin, std::size_t size, flag_type flags)

利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。

basic_regex<BidiIter> &operator[](string_type const &name)

名前付き正規表現への参照を返す。指定した名前をもつ正規表現が存在しない場合は、新しい正規表現を作成し参照を返す。

パラメータ

name -- 正規表現の名前を表す std::string

要件

文字列が空でない。

例外

bad_alloc -- メモリ確保に失敗した場合。

basic_regex<BidiIter> const &operator[](string_type const &name) const

利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。

regex_compiler 非公開メンバ関数

bool is_upper_(char_type ch)