regex_token_iterator クラス

更新 : 2007 年 11 月

サブマッチの反復子クラスです。

template<class BidIt, class Elem = iterator_traits<BidIt>::value_type,
    class RXtraits = regex_traits<Elem> >
        class regex_token_iterator {
public:
    typedef basic_regex<Elem, RXtraits> regex_type;
    typedef sub_match<BidIt> value_type;
    typedef std::forward_iterator_tag iterator_category;
    typedef std::ptrdiff_t difference_type;
    typedef const sub_match<BidIt> *pointer;
    typedef const sub_match<BidIt>& reference;

    regex_token_iterator();
    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, int submatch = 0,
        regex_constants::match_flag_type f = regex_constants::match_default);
    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, const std::vector<int> submatches,
        regex_constants::match_flag_type f = regex_constants::match_default);
    template<std::size_t N>
    regex_token_iterator(BidIt first, BidIt last,
        const regex_type& re, const int (&submatches)[N],
        regex_constants::match_flag_type f = regex_constants::match_default);

    bool operator==(const regex_token_iterator& right);
    bool operator!=(const regex_token_iterator& right);
    const basic_string<Elem>& operator*();
    const basic_string<Elem> *operator->();
    regex_token_iterator& operator++();
    regex_token_iterator& operator++(int);
private:
    regex_iterator<BidIt, Elem, RXtraits> it; // exposition only
    vector<int> subs;                         // exposition only
    int pos;                                  // exposition only
    };

パラメータ

  • BidIt
    サブマッチの反復子の型。

  • Elem
    一致させる要素の型。

  • RXtraits
    要素の特徴 (traits) クラス。

解説

このテンプレート クラスは、定数前方反復子オブジェクトを表します。概念的には、文字シーケンスから正規表現の一致を検索するために使用する regex_iterator オブジェクトを保持します。正規表現の各一致について、格納されているベクタ subs 内の (インデックス値で識別される) サブマッチを表す sub_match<BidIt> 型のオブジェクトを抽出します。

インデックス値 -1 は、前の正規表現一致の末尾の直後 (前の正規表現一致が存在しない場合は文字シーケンスの先頭) から、現在の正規表現一致の先頭文字の直前 (現在の一致が存在しない場合は文字シーケンスの最後) までの文字シーケンスを指定します。それ以外のインデックス値 (idx) は、it.match[idx] に保持されているキャプチャ グループの内容を指定します。

必要条件

ヘッダー : <regex>

名前空間 : std::tr1

参照

参照

<regex>

regex_token_iterator クラス

regex_iterator クラス