ICU 72.1 72.1
|
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... | |
uint64_t | getState64 () const |
Returns the state of this trie as a 64-bit integer. More... | |
BytesTrie & | resetToState64 (uint64_t state) |
Resets this trie to the saved 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 |
class | ::BytesTrieTest |
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 55 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 71 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 87 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 203 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 the state of this trie as a 64-bit integer.
The state value is never 0.
Definition at line 110 of file bytestrie.h.
|
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 246 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 262 of file bytestrie.h.
References NULL.
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. |
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. |
|
inline |
Resets this trie to its initial state.
Definition at line 96 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 179 of file bytestrie.h.
References NULL.
|
inline |
Resets this trie to the saved state.
Unlike resetToState(State), the 64-bit state value must be from getState64() from the same trie object or from one initialized the exact same way. Because of no validation, this method is faster.
state | The opaque trie state value from getState64(). |
Definition at line 129 of file bytestrie.h.
Saves the state of this trie.
state | The State object to hold the trie's state. |
Definition at line 162 of file bytestrie.h.
|
friend |
Definition at line 383 of file bytestrie.h.
|
friend |
Definition at line 382 of file bytestrie.h.