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; typedefunspecified
string_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; typedefunspecified
iterator; typedefunspecified
const_iterator; typedefunspecified
nested_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
オブジェクトの内容を交換する。例外を投げないことを保証する。