match_results 構造体テンプレート
-
template<typename BidiIter>
struct match_results match_results<>クラステンプレートはregex_matchやregex_searchの結果をsub_matchオブジェクトのコレクションとして保持する。
概要
// ヘッダ:<boost/xpressive/match_results.hpp> template<typename BidiIter> structmatch_results{ // 型 typedef iterator_value< BidiIter >::type char_type; typedefunspecifiedstring_type; typedef std::size_t size_type; typedefsub_match< BidiIter > value_type; typedef iterator_difference< BidiIter >::type difference_type; typedef value_type const & reference; typedef value_type const & const_reference; typedefunspecifiediterator; typedefunspecifiedconst_iterator; typedefunspecifiednested_results_type; // 構築、コピー、解体match_results();match_results(match_results< BidiIter > const &);match_results< BidiIter >&operator=(match_results< BidiIter > const &);~match_results(); // 公開メンバ関数 size_typesize() const; boolempty() const; difference_typelength(size_type = 0) const; difference_typeposition(size_type = 0) const; string_typestr(size_type = 0) const; template<typename Sub> const_referenceoperator[](Sub const &) const; const_referenceprefix() const; const_referencesuffix() const; const_iteratorbegin() const; const_iteratorend() const; operatorbool_type() const; booloperator!() const; regex_id_typeregex_id() const; nested_results_type const &nested_results() const; template<typename Format, typename OutputIterator> OutputIteratorformat(OutputIterator, Format const &, regex_constants::match_flag_type = regex_constants::format_default,unspecified= 0) const; template<typename OutputIterator> OutputIteratorformat(OutputIterator, char_type const *, regex_constants::match_flag_type = regex_constants::format_default) const; template<typename Format, typename OutputIterator> string_typeformat(Format const &, regex_constants::match_flag_type = regex_constants::format_default,unspecified= 0) const; string_typeformat(char_type const *, regex_constants::match_flag_type = regex_constants::format_default) const; voidswap(match_results< BidiIter > &); template<typename Arg>match_results< BidiIter > &let(Arg const &); }
説明
クラステンプレート match_results<> は、正規表現マッチの結果を表すシーケンスのコレクションである。コレクションの領域は match_results<> クラスのメンバ関数が必要に応じて確保・解放する。
クラステンプレート match_results<> は、lib.sequence.reqmts が規定するシーケンスの要件に適合するが、const なシーケンスに対して定義された演算だけをサポートする。
match_results の構築、コピー、解体公開演算
-
match_results()
-
match_results(match_results<BidiIter> const &that)
-
match_results<BidiIter> &operator=(match_results<BidiIter> const &that)
-
~match_results()
match_results 公開メンバ関数
-
size_type size() const
*this が成功したマッチ結果を表す場合は、マッチしたマーク済み部分式の総数に 1 を足した数を返す。それ以外の場合は 0 を返す。
-
difference_type position(size_type sub = 0) const
!(*this)[sub].matched であれば
-1を返す。それ以外の場合は std::distance(base, (*this)[sub].first) を返す(baseは検索対象のシーケンスの開始イテレータ)。注釈
regex_iteratorによる繰り返し検索の途中でなければ、baseは prefix().first と同じである。
-
template<typename Sub>
const_reference operator[](Sub const &sub) const マーク済み部分式
subにマッチしたシーケンスを表すsub_matchオブジェクトへの参照を返す。sub == 0 であれば正規表現全体にマッチしたシーケンスを表すsub_matchオブジェクトへの参照を返す。sub >= size() であればマッチしなかった部分式を表すsub_matchオブジェクトへの参照を返す。
-
const_reference prefix() const
マッチ・検索対象文字列の先頭からマッチが見つかった位置までの文字シーケンスを表す
sub_matchオブジェクトへの参照を返す。- 要件
(*this)[0].matched が真
-
const_reference suffix() const
マッチが見つかった位置の終端からマッチ・検索対象文字列の終端までの文字シーケンスを表す
sub_matchオブジェクトへの参照を返す。- 要件
(*this)[0].matched が真
-
const_iterator begin() const
*this に格納されたマーク済み部分式マッチをすべて列挙する開始イテレータを返す。
-
const_iterator end() const
*this に格納されたマーク済み部分式マッチをすべて列挙する終了イテレータを返す。
-
operator bool_type() const
(*this)[0].matched であれば真を、そうでなければ偽を返す。
-
regex_id_type regex_id() const
この
match_resultsオブジェクトで最近使用したbasic_regexオブジェクトの識別子を返す。
-
nested_results_type const &nested_results() const
入れ子の
match_results要素のシーケンスを返す。
-
template<typename Format, typename OutputIterator>
OutputIterator format(OutputIterator out, Format const &fmt, regex_constants::match_flag_type flags = regex_constants::format_default, unspecified = 0) const Formatが ForwardRange か null 終端文字列であれば、fmt内の文字シーケンスを OutputIterator であるoutにコピーする。fmt内の各書式化子およびエスケープシーケンスについて、それらが表す文字(列)かそれらが参照する *this 内のシーケンスで置換する。flagsで指定したビットマスクは、どの書式化子あるいはエスケープシーケンスを使用するかを決定する。既定では『ECMA-262 、ECMAScript 言語仕様 15 章 5.4.11 String.prototype.replace』が使用する書式である。それ以外で
FormatがCallable<match_results<BidiIter>, OutputIterator, regex_constants::match_flag_type>であれば、この関数は fmt(*this, out, flags) を返す。それ以外で
FormatがCallable<match_results<BidiIter>, OutputIterator>であれば、この関数は fmt(*this, out) を返す。それ以外で
FormatがCallable<match_results<BidiIter> >であれば、この関数は std::copy(x.begin(), x.end(), out) を返す。xは fmt(*this) を呼び出した結果である。
-
template<typename OutputIterator>
OutputIterator format(OutputIterator out, char_type const *fmt, regex_constants::match_flag_type flags = regex_constants::format_default) const 利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。
-
template<typename Format, typename OutputIterator>
string_type format(Format const &fmt, regex_constants::match_flag_type flags = regex_constants::format_default, unspecified = 0) const Formatが ForwardRange か null 終端文字列であれば、この関数は文字シーケンスfmtのコピーを返す。fmt内の各書式化子およびエスケープシーケンスについて、それらが表す文字(列)かそれらが参照する *this 内のシーケンスで置換する。flagsで指定したビットマスクは、どの書式化子あるいはエスケープシーケンスを使用するかを決定する。既定では『ECMA-262 、ECMAScript 言語仕様 15 章 5.4.11 String.prototype.replace』が使用する書式である。それ以外で
FormatがCallable<match_results<BidiIter>, OutputIterator, regex_constants::match_flag_type>であれば、この関数は fmt(*this, out, flags) 呼び出しで得られたstring_typeオブジェクトxを返す。outはxへのback_insert_iteratorである。それ以外で
FormatがCallable<match_results<BidiIter>, OutputIterator>であれば、この関数は fmt(*this, out) の呼び出しで得られたstring_typeオブジェクトxを返す。outはxへのback_insert_iteratorである。それ以外で
FormatがCallable<match_results<BidiIter> >であれば、この関数は fmt(*this) を返す。
-
string_type format(char_type const *fmt, regex_constants::match_flag_type flags = regex_constants::format_default) const
利便性のためのメンバ関数多重定義。上記関数と受け取る引数が異なるのみ。
-
void swap(match_results<BidiIter> &that)
2 つの
match_resultsオブジェクトの内容を交換する。例外を投げないことを保証する。