ICU 64.2
64.2
|
Light-weight, non-const reader class for a BytesTrie. More...
#include <bytestrie.h>
Data Structures | |
class | Iterator |
Iterator for all of the (byte sequence, value) pairs in a BytesTrie. More... | |
class | State |
BytesTrie state object, for saving a trie's current state and resetting the trie back to this state later. More... | |
Public Member Functions | |
BytesTrie (const void *trieBytes) | |
Constructs a BytesTrie reader instance. More... | |
~BytesTrie () | |
Destructor. More... | |
BytesTrie (const BytesTrie &other) | |
Copy constructor, copies the other trie reader object and its state, but not the byte array which will be shared. More... | |
BytesTrie & | reset () |
Resets this trie to its initial state. More... | |
const BytesTrie & | saveState (State &state) const |
Saves the state of this trie. More... | |
BytesTrie & | resetToState (const State &state) |
Resets this trie to the saved state. More... | |
UStringTrieResult | current () const |
Determines whether the byte sequence so far matches, whether it has a value, and whether another input byte can continue a matching byte sequence. More... | |
UStringTrieResult | first (int32_t inByte) |
Traverses the trie from the initial state for this input byte. More... | |
UStringTrieResult | next (int32_t inByte) |
Traverses the trie from the current state for this input byte. More... | |
UStringTrieResult | next (const char *s, int32_t length) |
Traverses the trie from the current state for this byte sequence. More... | |
int32_t | getValue () const |
Returns a matching byte sequence's value if called immediately after current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE. More... | |
UBool | hasUniqueValue (int32_t &uniqueValue) const |
Determines whether all byte sequences reachable from the current state map to the same value. More... | |
int32_t | getNextBytes (ByteSink &out) const |
Finds each byte which continues the byte sequence from the current state. More... | |
Friends | |
class | BytesTrieBuilder |
Light-weight, non-const reader class for a BytesTrie.
Traverses a byte-serialized data structure with minimal state, for mapping byte sequences to non-negative integer values.
This class owns the serialized trie data only if it was constructed by the builder's build() method. The public constructor and the copy constructor only alias the data (only copy the pointer). There is no assignment operator.
This class is not intended for public subclassing.
Definition at line 50 of file bytestrie.h.
|
inline |
Constructs a BytesTrie reader instance.
The trieBytes must contain a copy of a byte sequence from the BytesTrieBuilder, starting with the first byte of that sequence. The BytesTrie object will not read more bytes than the BytesTrieBuilder generated in the corresponding build() call.
The array is not copied/cloned and must not be modified while the BytesTrie object is in use.
trieBytes | The byte array that contains the serialized trie. |
Definition at line 66 of file bytestrie.h.
icu::BytesTrie::~BytesTrie | ( | ) |
Destructor.
|
inline |
Copy constructor, copies the other trie reader object and its state, but not the byte array which will be shared.
(Shallow copy.)
other | Another BytesTrie object. |
Definition at line 82 of file bytestrie.h.
UStringTrieResult icu::BytesTrie::current | ( | ) | const |
Determines whether the byte sequence so far matches, whether it has a value, and whether another input byte can continue a matching byte sequence.
|
inline |
Traverses the trie from the initial state for this input byte.
Equivalent to reset().next(inByte).
inByte | Input byte value. Values -0x100..-1 are treated like 0..0xff. Values below -0x100 and above 0xff will never match. |
Definition at line 165 of file bytestrie.h.
int32_t icu::BytesTrie::getNextBytes | ( | ByteSink & | out | ) | const |
Finds each byte which continues the byte sequence from the current state.
That is, each byte b for which it would be next(b)!=USTRINGTRIE_NO_MATCH now.
out | Each next byte is appended to this object. (Only uses the out.Append(s, length) method.) |
|
inline |
Returns a matching byte sequence's value if called immediately after current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.
getValue() can be called multiple times.
Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!
Definition at line 208 of file bytestrie.h.
|
inline |
Determines whether all byte sequences reachable from the current state map to the same value.
uniqueValue | Receives the unique value, if this function returns TRUE. (output-only) |
Definition at line 224 of file bytestrie.h.
UStringTrieResult icu::BytesTrie::next | ( | int32_t | inByte | ) |
Traverses the trie from the current state for this input byte.
inByte | Input byte value. Values -0x100..-1 are treated like 0..0xff. Values below -0x100 and above 0xff will never match. |
UStringTrieResult icu::BytesTrie::next | ( | const char * | s, |
int32_t | length | ||
) |
Traverses the trie from the current state for this byte sequence.
Equivalent to
s | A string or byte sequence. Can be NULL if length is 0. |
length | The length of the byte sequence. Can be -1 if NUL-terminated. |
|
inline |
Resets this trie to its initial state.
Definition at line 91 of file bytestrie.h.
Resets this trie to the saved state.
If the state object contains no state, or the state of a different trie, then this trie remains unchanged.
state | The State object which holds a saved trie state. |
Definition at line 141 of file bytestrie.h.
References NULL.
Saves the state of this trie.
state | The State object to hold the trie's state. |
Definition at line 124 of file bytestrie.h.