Espaços nominais
Variantes
Acções

std::regex_token_iterator

Da cppreference.com
< cpp‎ | regex

 
 
Biblioteca de expressões regulares
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_regex(C++11)
sub_match(C++11)
match_results(C++11)
Algoritmos
Original:
Algorithms
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_match(C++11)
regex_search(C++11)
regex_replace(C++11)
Iteradores
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_iterator(C++11)
regex_token_iterator(C++11)
Exceções
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_error(C++11)
Características
Original:
Traits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_traits(C++11)
Constantes
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
syntax_option_type(C++11)
match_flag_type(C++11)
error_type(C++11)
 
template<

    class BidirIt,
    class CharT = typename std::iterator_traits<BidirIt>::value_type,
    class Traits = std::regex_traits<CharT>

> class regex_token_iterator
(a partir do C++ 11)
std::regex_token_iterator é um ForwardIterator somente leitura que acessa os individuais sub-partidas de cada jogo de uma expressão regular dentro da seqüência de caracteres subjacente. Ele também pode ser usado para aceder às partes da sequência que não foram correspondidas pela expressão regular (por exemplo, como um tokenizer).
Original:
std::regex_token_iterator is a read-only ForwardIterator that accesses the individual sub-matches of every match of a regular expression within the underlying character sequence. It can also be used to access the parts of the sequence that were not matched by the given regular expression (e.g. as a tokenizer).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Na construção, ela constrói um std::regex_iterator e em cada incremento que percorre os pedidos sub-partidas dos match_results atuais, incrementando o regex_iterator subjacente ao incremento de distância da submatch passado.
Original:
On construction, it constructs an std::regex_iterator and on every increment it steps through the requested sub-matches from the current match_results, incrementing the underlying regex_iterator when incrementing away from the last submatch.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O padrão construído std::regex_token_iterator é o iterador de fim de seqüência. Quando um std::regex_token_iterator válido é incrementado depois de atingir o último submatch do último jogo, torna-se igual ao iterador de fim de sequência. Dereferencing ou incrementá-lo ainda mais invoca comportamento indefinido.
Original:
The default-constructed std::regex_token_iterator is the end-of-sequence iterator. When a valid std::regex_token_iterator is incremented after reaching the last submatch of the last match, it becomes equal to the end-of-sequence iterator. Dereferencing or incrementing it further invokes undefined behavior.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Pouco antes de se tornar o iterador de fim de seqüência, um std::regex_token_iterator pode se tornar um' iterador sufixo, se o índice -1 (não-pareado fragmento) aparece na lista dos índices submatch solicitados. Iterador tal, se dereferenced, retorna um match_results correspondentes à seqüência de caracteres entre o último jogo e no final da sequência.
Original:
Just before becoming the end-of-sequence iterator, a std::regex_token_iterator may become a suffix iterator, if the index -1 (non-matched fragment) appears in the list of the requested submatch indexes. Such iterator, if dereferenced, returns a match_results corresponding to the sequence of characters between the last match and the end of sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Uma implementação típica de std::regex_token_iterator detém o std::regex_iterator subjacente, um recipiente (por exemplo, std::vector<int>) dos índices submatch requeridos, o contador interno igual ao índice do submatch, um ponteiro para std::match_results, apontando para o submatch actual do jogo actual e uma std::match_results objeto que contém a seqüência de caracteres passado não-pareado (usado no modo tokenizer).
Original:
A typical implementation of std::regex_token_iterator holds the underlying std::regex_iterator, a container (e.g. std::vector<int>) of the requested submatch indexes, the internal counter equal to the index of the submatch, a pointer to std::match_results, pointing at the current submatch of the current match, and a std::match_results object containing the last non-matched character sequence (used in tokenizer mode).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Requisitos de tipo

-
BidirIt must meet the requirements of BidirectionalIterator.

[editar] Especializações

Várias especializações para tipos de seqüência de caracteres comuns são definidas:
Original:
Several specializations for common character sequence types are defined:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Defined in header <regex>
Tipo
Original:
Type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
cregex_token_iterator regex_token_iterator<const char*>
wcregex_token_iterator regex_token_iterator<const wchar_t*>
sregex_token_iterator regex_token_iterator<std::string::const_iterator>
wsregex_token_iterator regex_token_iterator<std::wstring::const_iterator>

[editar] Tipos de membro

Tipo de membro
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
value_type std::sub_match<BidirIt>
difference_type std::ptrdiff_t
pointer const value_type*
reference const value_type&
iterator_category std::forward_iterator_tag
regex_type basic_regex<CharT, Traits>

[editar] Funções de membro

constrói um novo regex_token_iterator
Original:
constructs a new regex_token_iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
(destructor)
(declarada implicitamente)
destructs a regex_token_iterator, including the cached value
(função pública membro)
substitui um regex_token_iterator
Original:
replaces a regex_token_iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
compara dois regex_token_iterators
Original:
compares two regex_token_iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
accsses submatch actual
Original:
accsses current submatch
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)
avança a regex_token_iterator ao submatch seguinte
Original:
advances the regex_token_iterator to the next submatch
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função pública membro)

[editar] Notas

É responsabilidade do programador para garantir que o objeto std::basic_regex passado para o construtor do iterador sobrevive o iterador. Porque o iterador armazena uma std::regex_iterator que armazena um ponteiro para a regex, incrementando o iterador após os resultados do regex foi destruído em um comportamento indefinido.
Original:
It is the programmer's responsibility to ensure that the std::basic_regex object passed to the iterator's constructor outlives the iterator. Because the iterator stores a std::regex_iterator which stores a pointer to the regex, incrementing the iterator after the regex was destroyed results in undefined behavior.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

#include <fstream>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <regex>
int main()
{
   std::string text = "Quick brown fox.";
   // tokenization (non-matched fragments)
   // Note that regex is matched only two times: when the third value is obtained
   // the iterator is a suffix iterator.
   std::regex ws_re("\\s+"); // whitespace
   std::copy( std::sregex_token_iterator(text.begin(), text.end(), ws_re, -1),
              std::sregex_token_iterator(),
              std::ostream_iterator<std::string>(std::cout, "\n"));
 
   // iterating the first submatches
   std::string html = "<p><a href=\"http://google.com\">google</a> "
                      "< a HREF =\"http://cppreference.com\">cppreference</a>\n</p>";
   std::regex url_re("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"", std::regex::icase);
   std::copy( std::sregex_token_iterator(html.begin(), html.end(), url_re, 1),
              std::sregex_token_iterator(),
              std::ostream_iterator<std::string>(std::cout, "\n"));
}

Output:

Quick
brown
fox.
http://google.com
http://cppreference.com