1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
/*
This is part of pyahocorasick Python module.
AutomatonItemsIter const, struct & methods declarations.
This class implements iterator walk over trie, that returns
words and associated values. Object of this class is
returned by 'keys'/'values'/'items' methods of Automaton class.
Author : Wojciech Muła, wojciech_mula@poczta.onet.pl
WWW : http://0x80.pl
License : BSD-3-Clause (see LICENSE)
*/
#ifndef ahocorasick_AutomatonItemsIter_h_included
#define ahocorasick_AutomatonItemsIter_h_included
#include "common.h"
#include "Automaton.h"
typedef enum {
ITER_KEYS,
ITER_VALUES,
ITER_ITEMS
} ItemsType;
typedef enum {
MATCH_EXACT_LENGTH,
MATCH_AT_MOST_PREFIX,
MATCH_AT_LEAST_PREFIX
} PatternMatchType;
typedef struct AutomatonItemsIter {
PyObject_HEAD
Automaton* automaton;
int version; ///< automaton version
TrieNode* state; ///< current automaton node
TRIE_LETTER_TYPE letter; ///< current letter
List stack; ///< stack
ItemsType type; ///< type of iterator (KEYS/VALUES/ITEMS)
TRIE_LETTER_TYPE* buffer; ///< buffer to construct key representation
#ifndef AHOCORASICK_UNICODE
char *char_buffer;
#endif
size_t pattern_length;
TRIE_LETTER_TYPE* pattern; ///< pattern
bool use_wildcard;
TRIE_LETTER_TYPE wildcard; ///< wildcard char
PatternMatchType matchtype; ///< how pattern have to be handled
} AutomatonItemsIter;
/* new() */
static PyObject*
automaton_items_iter_new(
Automaton* automaton,
const TRIE_LETTER_TYPE* word,
const ssize_t wordlen,
const bool use_wildcard,
const TRIE_LETTER_TYPE wildcard,
const PatternMatchType matchtype
);
#endif
|