/opt/alt/libicu/usr/include/unicode
NameSizeModeActions
alphaindex.h270560644editdlrm
appendable.h86320644editdlrm
basictz.h90550644editdlrm
brkiter.h281950644editdlrm
bytestream.h97670644editdlrm
bytestrie.h197180644editdlrm
bytestriebuilder.h71860644editdlrm
calendar.h1075810644editdlrm
caniter.h75500644editdlrm
casemap.h258710644editdlrm
char16ptr.h73310644editdlrm
chariter.h245730644editdlrm
choicfmt.h244180644editdlrm
coleitr.h140330644editdlrm
coll.h569280644editdlrm
compactdecimalformat.h69710644editdlrm
curramt.h37820644editdlrm
currpinf.h74120644editdlrm
currunit.h36060644editdlrm
datefmt.h413340644editdlrm
dbbi.h11330644editdlrm
dcfmtsym.h205840644editdlrm
decimfmt.h884780644editdlrm
docmain.h68780644editdlrm
dtfmtsym.h385480644editdlrm
dtintrv.h38480644editdlrm
dtitvfmt.h438980644editdlrm
dtitvinf.h189030644editdlrm
dtptngen.h256260644editdlrm
dtrule.h88310644editdlrm
edits.h211690644editdlrm
enumset.h21300644editdlrm
errorcode.h48940644editdlrm
fieldpos.h88380644editdlrm
filteredbrk.h53640644editdlrm
fmtable.h249460644editdlrm
format.h127410644editdlrm
fpositer.h30470644editdlrm
gender.h33470644editdlrm
gregocal.h323310644editdlrm
icudataver.h10510644editdlrm
icuplug.h121660644editdlrm
idna.h129380644editdlrm
listformatter.h63310644editdlrm
localpointer.h172840644editdlrm
locdspnm.h72240644editdlrm
locid.h460010644editdlrm
measfmt.h122980644editdlrm
measunit.h394270644editdlrm
measure.h43610644editdlrm
messagepattern.h344600644editdlrm
msgfmt.h443980644editdlrm
normalizer2.h347890644editdlrm
normlzr.h314760644editdlrm
nounit.h26930644editdlrm
numberformatter.h891640644editdlrm
numberrangeformatter.h294300644editdlrm
numfmt.h503220644editdlrm
numsys.h68950644editdlrm
parseerr.h31550644editdlrm
parsepos.h55810644editdlrm
platform.h277540644editdlrm
plurfmt.h257860644editdlrm
plurrule.h178340644editdlrm
ptypes.h35770644editdlrm
putil.h64870644editdlrm
rbbi.h270470644editdlrm
rbnf.h509840644editdlrm
rbtz.h158380644editdlrm
regex.h869430644editdlrm
region.h93420644editdlrm
reldatefmt.h148120644editdlrm
rep.h97260644editdlrm
resbund.h184400644editdlrm
schriter.h64100644editdlrm
scientificnumberformatter.h64740644editdlrm
search.h227420644editdlrm
selfmt.h145790644editdlrm
simpleformatter.h117010644editdlrm
simpletz.h463890644editdlrm
smpdtfmt.h724420644editdlrm
sortkey.h113830644editdlrm
std_string.h10150644editdlrm
strenum.h102790644editdlrm
stringoptions.h59260644editdlrm
stringpiece.h66100644editdlrm
stringtriebuilder.h156360644editdlrm
stsearch.h218010644editdlrm
symtable.h43120644editdlrm
tblcoll.h372720644editdlrm
timezone.h418620644editdlrm
tmunit.h33710644editdlrm
tmutamt.h49180644editdlrm
tmutfmt.h79770644editdlrm
translit.h673390644editdlrm
tzfmt.h438460644editdlrm
tznames.h171900644editdlrm
tzrule.h361700644editdlrm
tztrans.h62140644editdlrm
ubidi.h917110644editdlrm
ubiditransform.h129500644editdlrm
ubrk.h245470644editdlrm
ucal.h565260644editdlrm
ucasemap.h155460644editdlrm
ucat.h54840644editdlrm
uchar.h1433140644editdlrm
ucharstrie.h215690644editdlrm
ucharstriebuilder.h73160644editdlrm
uchriter.h134570644editdlrm
uclean.h114740644editdlrm
ucnv.h850850644editdlrm
ucnvsel.h62830644editdlrm
ucnv_cb.h67480644editdlrm
ucnv_err.h214920644editdlrm
ucol.h628640644editdlrm
ucoleitr.h96840644editdlrm
uconfig.h119490644editdlrm
ucpmap.h57090644editdlrm
ucptrie.h228240644editdlrm
ucsdet.h150180644editdlrm
ucurr.h159470644editdlrm
udat.h615720644editdlrm
udata.h159050644editdlrm
udateintervalformat.h69500644editdlrm
udatpg.h266640644editdlrm
udisplaycontext.h60290644editdlrm
uenum.h79700644editdlrm
ufieldpositer.h44610644editdlrm
uformattable.h111980644editdlrm
ugender.h20520644editdlrm
uidna.h341690644editdlrm
uiter.h233190644editdlrm
uldnames.h107020644editdlrm
ulistformatter.h51480644editdlrm
uloc.h519710644editdlrm
ulocdata.h115330644editdlrm
umachine.h135090644editdlrm
umisc.h13650644editdlrm
umsg.h248120644editdlrm
umutablecptrie.h84770644editdlrm
unifilt.h37160644editdlrm
unifunct.h40790644editdlrm
unimatch.h61840644editdlrm
unirepl.h34030644editdlrm
uniset.h657960644editdlrm
unistr.h1785870644editdlrm
unorm.h209380644editdlrm
unorm2.h252540644editdlrm
unum.h546660644editdlrm
unumberformatter.h243350644editdlrm
unumsys.h73140644editdlrm
uobject.h109580644editdlrm
upluralrules.h68800644editdlrm
uregex.h737840644editdlrm
uregion.h100730644editdlrm
ureldatefmt.h125180644editdlrm
urename.h1307910644editdlrm
urep.h55070644editdlrm
ures.h374040644editdlrm
uscript.h271530644editdlrm
usearch.h390380644editdlrm
uset.h409580644editdlrm
usetiter.h97190644editdlrm
ushape.h184320644editdlrm
uspoof.h676130644editdlrm
usprep.h83310644editdlrm
ustdio.h394690644editdlrm
ustream.h18440644editdlrm
ustring.h742110644editdlrm
ustringtrie.h32240644editdlrm
utext.h595030644editdlrm
utf.h80460644editdlrm
utf8.h307340644editdlrm
utf16.h228660644editdlrm
utf32.h7630644editdlrm
utf_old.h448270644editdlrm
utmscale.h141130644editdlrm
utrace.h142190644editdlrm
utrans.h261570644editdlrm
utypes.h312120644editdlrm
uvernum.h62060644editdlrm
uversion.h68650644editdlrm
vtzone.h206510644editdlrm
Edit: /opt/alt/libicu/usr/include/unicode/bytestrie.h (19718B)
// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * Copyright (C) 2010-2012, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: bytestrie.h * encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * * created on: 2010sep25 * created by: Markus W. Scherer */ #ifndef __BYTESTRIE_H__ #define __BYTESTRIE_H__ /** * \file * \brief C++ API: Trie for mapping byte sequences to integer values. */ #include "unicode/utypes.h" #include "unicode/stringpiece.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" U_NAMESPACE_BEGIN class ByteSink; class BytesTrieBuilder; class CharString; class UVector32; /** * 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. * @stable ICU 4.8 */ class U_COMMON_API BytesTrie : public UMemory { public: /** * 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. * * @param trieBytes The byte array that contains the serialized trie. * @stable ICU 4.8 */ BytesTrie(const void *trieBytes) : ownedArray_(NULL), bytes_(static_cast(trieBytes)), pos_(bytes_), remainingMatchLength_(-1) {} /** * Destructor. * @stable ICU 4.8 */ ~BytesTrie(); /** * Copy constructor, copies the other trie reader object and its state, * but not the byte array which will be shared. (Shallow copy.) * @param other Another BytesTrie object. * @stable ICU 4.8 */ BytesTrie(const BytesTrie &other) : ownedArray_(NULL), bytes_(other.bytes_), pos_(other.pos_), remainingMatchLength_(other.remainingMatchLength_) {} /** * Resets this trie to its initial state. * @return *this * @stable ICU 4.8 */ BytesTrie &reset() { pos_=bytes_; remainingMatchLength_=-1; return *this; } /** * BytesTrie state object, for saving a trie's current state * and resetting the trie back to this state later. * @stable ICU 4.8 */ class State : public UMemory { public: /** * Constructs an empty State. * @stable ICU 4.8 */ State() { bytes=NULL; } private: friend class BytesTrie; const uint8_t *bytes; const uint8_t *pos; int32_t remainingMatchLength; }; /** * Saves the state of this trie. * @param state The State object to hold the trie's state. * @return *this * @see resetToState * @stable ICU 4.8 */ const BytesTrie &saveState(State &state) const { state.bytes=bytes_; state.pos=pos_; state.remainingMatchLength=remainingMatchLength_; return *this; } /** * 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. * @param state The State object which holds a saved trie state. * @return *this * @see saveState * @see reset * @stable ICU 4.8 */ BytesTrie &resetToState(const State &state) { if(bytes_==state.bytes && bytes_!=NULL) { pos_=state.pos; remainingMatchLength_=state.remainingMatchLength; } return *this; } /** * Determines whether the byte sequence so far matches, whether it has a value, * and whether another input byte can continue a matching byte sequence. * @return The match/value Result. * @stable ICU 4.8 */ UStringTrieResult current() const; /** * Traverses the trie from the initial state for this input byte. * Equivalent to reset().next(inByte). * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff. * Values below -0x100 and above 0xff will never match. * @return The match/value Result. * @stable ICU 4.8 */ inline UStringTrieResult first(int32_t inByte) { remainingMatchLength_=-1; if(inByte<0) { inByte+=0x100; } return nextImpl(bytes_, inByte); } /** * Traverses the trie from the current state for this input byte. * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff. * Values below -0x100 and above 0xff will never match. * @return The match/value Result. * @stable ICU 4.8 */ UStringTrieResult next(int32_t inByte); /** * Traverses the trie from the current state for this byte sequence. * Equivalent to * \code * Result result=current(); * for(each c in s) * if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH; * result=next(c); * return result; * \endcode * @param s A string or byte sequence. Can be NULL if length is 0. * @param length The length of the byte sequence. Can be -1 if NUL-terminated. * @return The match/value Result. * @stable ICU 4.8 */ UStringTrieResult next(const char *s, int32_t length); /** * 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! * @return The value for the byte sequence so far. * @stable ICU 4.8 */ inline int32_t getValue() const { const uint8_t *pos=pos_; int32_t leadByte=*pos++; // U_ASSERT(leadByte>=kMinValueLead); return readValue(pos, leadByte>>1); } /** * Determines whether all byte sequences reachable from the current state * map to the same value. * @param uniqueValue Receives the unique value, if this function returns TRUE. * (output-only) * @return TRUE if all byte sequences reachable from the current state * map to the same value. * @stable ICU 4.8 */ inline UBool hasUniqueValue(int32_t &uniqueValue) const { const uint8_t *pos=pos_; // Skip the rest of a pending linear-match node. return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue); } /** * 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. * @param out Each next byte is appended to this object. * (Only uses the out.Append(s, length) method.) * @return the number of bytes which continue the byte sequence from here * @stable ICU 4.8 */ int32_t getNextBytes(ByteSink &out) const; /** * Iterator for all of the (byte sequence, value) pairs in a BytesTrie. * @stable ICU 4.8 */ class U_COMMON_API Iterator : public UMemory { public: /** * Iterates from the root of a byte-serialized BytesTrie. * @param trieBytes The trie bytes. * @param maxStringLength If 0, the iterator returns full strings/byte sequences. * Otherwise, the iterator returns strings with this maximum length. * @param errorCode Standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @stable ICU 4.8 */ Iterator(const void *trieBytes, int32_t maxStringLength, UErrorCode &errorCode); /** * Iterates from the current state of the specified BytesTrie. * @param trie The trie whose state will be copied for iteration. * @param maxStringLength If 0, the iterator returns full strings/byte sequences. * Otherwise, the iterator returns strings with this maximum length. * @param errorCode Standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @stable ICU 4.8 */ Iterator(const BytesTrie &trie, int32_t maxStringLength, UErrorCode &errorCode); /** * Destructor. * @stable ICU 4.8 */ ~Iterator(); /** * Resets this iterator to its initial state. * @return *this * @stable ICU 4.8 */ Iterator &reset(); /** * @return TRUE if there are more elements. * @stable ICU 4.8 */ UBool hasNext() const; /** * Finds the next (byte sequence, value) pair if there is one. * * If the byte sequence is truncated to the maximum length and does not * have a real value, then the value is set to -1. * In this case, this "not a real value" is indistinguishable from * a real value of -1. * @param errorCode Standard ICU error code. Its input value must * pass the U_SUCCESS() test, or else the function returns * immediately. Check for U_FAILURE() on output or use with * function chaining. (See User Guide for details.) * @return TRUE if there is another element. * @stable ICU 4.8 */ UBool next(UErrorCode &errorCode); /** * @return The NUL-terminated byte sequence for the last successful next(). * @stable ICU 4.8 */ StringPiece getString() const; /** * @return The value for the last successful next(). * @stable ICU 4.8 */ int32_t getValue() const { return value_; } private: UBool truncateAndStop(); const uint8_t *branchNext(const uint8_t *pos, int32_t length, UErrorCode &errorCode); const uint8_t *bytes_; const uint8_t *pos_; const uint8_t *initialPos_; int32_t remainingMatchLength_; int32_t initialRemainingMatchLength_; CharString *str_; int32_t maxLength_; int32_t value_; // The stack stores pairs of integers for backtracking to another // outbound edge of a branch node. // The first integer is an offset from bytes_. // The second integer has the str_->length() from before the node in bits 15..0, // and the remaining branch length in bits 24..16. (Bits 31..25 are unused.) // (We could store the remaining branch length minus 1 in bits 23..16 and not use bits 31..24, // but the code looks more confusing that way.) UVector32 *stack_; }; private: friend class BytesTrieBuilder; /** * Constructs a BytesTrie reader instance. * Unlike the public constructor which just aliases an array, * this constructor adopts the builder's array. * This constructor is only called by the builder. */ BytesTrie(void *adoptBytes, const void *trieBytes) : ownedArray_(static_cast(adoptBytes)), bytes_(static_cast(trieBytes)), pos_(bytes_), remainingMatchLength_(-1) {} // No assignment operator. BytesTrie &operator=(const BytesTrie &other); inline void stop() { pos_=NULL; } // Reads a compact 32-bit integer. // pos is already after the leadByte, and the lead byte is already shifted right by 1. static int32_t readValue(const uint8_t *pos, int32_t leadByte); static inline const uint8_t *skipValue(const uint8_t *pos, int32_t leadByte) { // U_ASSERT(leadByte>=kMinValueLead); if(leadByte>=(kMinTwoByteValueLead<<1)) { if(leadByte<(kMinThreeByteValueLead<<1)) { ++pos; } else if(leadByte<(kFourByteValueLead<<1)) { pos+=2; } else { pos+=3+((leadByte>>1)&1); } } return pos; } static inline const uint8_t *skipValue(const uint8_t *pos) { int32_t leadByte=*pos++; return skipValue(pos, leadByte); } // Reads a jump delta and jumps. static const uint8_t *jumpByDelta(const uint8_t *pos); static inline const uint8_t *skipDelta(const uint8_t *pos) { int32_t delta=*pos++; if(delta>=kMinTwoByteDeltaLead) { if(delta>8)+1; // 0x6c static const int32_t kFourByteValueLead=0x7e; // A little more than Unicode code points. (0x11ffff) static const int32_t kMaxThreeByteValue=((kFourByteValueLead-kMinThreeByteValueLead)<<16)-1; static const int32_t kFiveByteValueLead=0x7f; // Compact delta integers. static const int32_t kMaxOneByteDelta=0xbf; static const int32_t kMinTwoByteDeltaLead=kMaxOneByteDelta+1; // 0xc0 static const int32_t kMinThreeByteDeltaLead=0xf0; static const int32_t kFourByteDeltaLead=0xfe; static const int32_t kFiveByteDeltaLead=0xff; static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1; // 0x2fff static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1; // 0xdffff uint8_t *ownedArray_; // Fixed value referencing the BytesTrie bytes. const uint8_t *bytes_; // Iterator variables. // Pointer to next trie byte to read. NULL if no more matches. const uint8_t *pos_; // Remaining length of a linear-match node, minus 1. Negative if not in such a node. int32_t remainingMatchLength_; }; U_NAMESPACE_END #endif // __BYTESTRIE_H__