![]() |
Spicy
|
#include <regexp.h>
Classes | |
class | Pimpl |
Public Member Functions | |
MatchState (const RegExp &re) | |
MatchState (const MatchState &other) | |
MatchState (MatchState &&) noexcept | |
MatchState & | operator= (const MatchState &other) |
MatchState & | operator= (MatchState &&) noexcept |
std::tuple< int32_t, stream::View > | advance (const stream::View &data) |
std::tuple< int32_t, uint64_t > | advance (const Bytes &data, bool is_final=false) |
Captures | captures (const Stream &data) const |
Match state for incremental regexp matching.
regexp::MatchState::MatchState | ( | const RegExp & | re | ) |
Creates a fresh instances ready to match data against a given regular expression. The expression will considered anchored to the beginning of any data.
std::tuple< int32_t, stream::View > regexp::MatchState::advance | ( | const stream::View & | data | ) |
Feeds the next chunk of data into the matcher.
data | chunk of data; if the underlying stream is frozen, this will be assumed to be the last chunk of data, and the result of any further calls to advance() will then trigger a MatchStateReuse exception |
compileSet
the integer value then indicates the ID of the pattern that was found. (2) zero if no match was found and advancing further to more data is guaranteed to not change that fact. (3) smaller than 0 if no match was found so far but advancing further may change that. In either case, the returned view trims data to the part not consumed yet. std::tuple< int32_t, uint64_t > regexp::MatchState::advance | ( | const Bytes & | data, |
bool | is_final = false |
||
) |
Feeds the next chunk of data into the matcher.
data | chunk of data |
is_final | true to signal the last chunk of data; the result of any further calls to advance() will then trigger a MatchStateReuse exception |
compileSet
the integer value then indicates the ID of the pattern that was found. (2) zero if no match was found and advancing further to more data is guaranteed to not change that fact. (3) smaller than 0 if no match was found so far but advancing further may change that. In either case, the 2nd element in the tuple returns the number of bytes that were consumed from data by the matching. regexp::Captures regexp::MatchState::captures | ( | const Stream & | data | ) | const |
Returns extracted capture groups after successful matching. Element zero will contain the full match. For i>0, index i will contain the i'th capture group. If capture groups cannot be extracted (e.g., because the regexp was compiled without support for that, or when matching has not finished successfully), the return vector will be empty.