basic_regex 構造体テンプレート

template<typename BidiIter>
struct basic_regex

basic_regex<> クラステンプレートはコンパイル済み正規表現を保持するクラスである。

概要

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

template<typename BidiIter>
struct basic_regex {
  // 構築、コピー、解体
  basic_regex();
  basic_regex(basic_regex< BidiIter > const &);
  template<typename Expr> basic_regex(Expr const &);
  basic_regex< BidiIter >& operator=(basic_regex< BidiIter > const &);
  template<typename Expr> basic_regex< BidiIter >& operator=(Expr const &);

  // 公開メンバ関数
  std::size_t mark_count() const;
  regex_id_type regex_id() const;
  void swap(basic_regex< BidiIter > &);

  // 公開静的メンバ関数
  template<typename InputIter>
    static basic_regex< BidiIter >
    compile(InputIter, InputIter, flag_type = regex_constants::ECMAScript);
  template<typename InputRange>
    static basic_regex< BidiIter >
    compile(InputRange const &, flag_type = regex_constants::ECMAScript);
  static basic_regex< BidiIter >
  compile(char_type const *, flag_type = regex_constants::ECMAScript);
  static basic_regex< BidiIter >
  compile(char_type const *, std::size_t, flag_type);
};

説明

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

basic_regex()
事後条件

regex_id() == 0

事後条件

mark_count() == 0

basic_regex(basic_regex<BidiIter> const &that)
パラメータ

that -- コピーする basic_regex オブジェクト。

事後条件

regex_id() == that.regex_id()

事後条件

mark_count() == that.mark_count()

template<typename Expr>
basic_regex(Expr const &expr)

静的正規表現から構築する。

パラメータ

expr -- 静的正規表現。

要件

Expr は静的正規表現の型。

事後条件

regex_id() != 0

事後条件

mark_count() >= 0

basic_regex<BidiIter> &operator=(basic_regex<BidiIter> const &that)
パラメータ

that -- コピーする basic_regex オブジェクト。

事後条件

regex_id() == that.regex_id()

事後条件

mark_count() == that.mark_count()

戻り値

*this

template<typename Expr>
basic_regex<BidiIter> &operator=(Expr const &expr)

静的正規表現から構築する。

パラメータ

expr -- 静的正規表現。

要件

Expr は静的正規表現の型。

事後条件

regex_id() != 0

事後条件

mark_count() >= 0

戻り値

*this

例外

std::bad_alloc -- メモリ不足のとき

basic_regex の公開メンバ関数

std::size_t mark_count() const

この正規表現内の捕捉済み部分式の数を返す。

regex_id_type regex_id() const

この正規表現を一意に識別するトークンを返す。

void swap(basic_regex<BidiIter> &that)

この basic_regex オブジェクトの内容を別のものと交換する。

注釈

参照まで追跡しない浅い交換である。basic_regex オブジェクトを参照により別の正規表現に組み込み、他の basic_regex オブジェクトと内容を交換すると、外側の正規表現からはこの変更を検出できない。これは swap が例外を送出できないためである。

パラメータ

that -- 他の basic_regex オブジェクト。

例外

例外を送出しない。

basic_regex の公開静的メンバ関数

template<typename InputIter>
static basic_regex<BidiIter> compile(InputIter begin, InputIter end, flag_type flags)

文字の範囲から正規表現オブジェクトを構築するファクトリメソッド。regex_compiler<BidiIter>().compile(begin, end, flags) と等価。

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

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

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

要件

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

戻り値

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

例外

regex_error --

template<typename InputRange>
static basic_regex<BidiIter> compile(InputRange const &pat, flag_type flags)

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

static basic_regex<BidiIter> compile(char_type const *begin, flag_type flags)

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

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

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