// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * Copyright (C) 2014, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * dictionarydata.h * * created on: 2012may31 * created by: Markus W. Scherer & Maxime Serrano */ #ifndef __DICTIONARYDATA_H__ #define __DICTIONARYDATA_H__ #include "unicode/utypes.h" #if !UCONFIG_NO_BREAK_ITERATION #include "unicode/utext.h" #include "unicode/udata.h" #include "udataswp.h" #include "unicode/uobject.h" #include "unicode/ustringtrie.h" U_NAMESPACE_BEGIN class UCharsTrie; class BytesTrie; class U_COMMON_API DictionaryData : public UMemory { … }; /** * Wrapper class around generic dictionaries, implementing matches(). * getType() should return a TRIE_TYPE_??? constant from DictionaryData. * * All implementations of this interface must be thread-safe if they are to be used inside of the * dictionary-based break iteration code. */ class U_COMMON_API DictionaryMatcher : public UMemory { … }; // Implementation of the DictionaryMatcher interface for a UCharsTrie dictionary class U_COMMON_API UCharsDictionaryMatcher : public DictionaryMatcher { … }; // Implementation of the DictionaryMatcher interface for a BytesTrie dictionary class U_COMMON_API BytesDictionaryMatcher : public DictionaryMatcher { … }; U_NAMESPACE_END U_CAPI int32_t U_EXPORT2 udict_swap(const UDataSwapper *ds, const void *inData, int32_t length, void *outData, UErrorCode *pErrorCode); /** * Format of dictionary .dict data files. * Format version 1.0. * * A dictionary .dict data file contains a byte-serialized BytesTrie or * a UChars-serialized UCharsTrie. * Such files are used in dictionary-based break iteration (DBBI). * * For a BytesTrie, a transformation type is specified for * transforming Unicode strings into byte sequences. * * A .dict file begins with a standard ICU data file header * (DataHeader, see ucmndata.h and unicode/udata.h). * The UDataInfo.dataVersion field is currently unused (set to 0.0.0.0). * * After the header, the file contains the following parts. * Constants are defined in the DictionaryData class. * * For the data structure of BytesTrie & UCharsTrie see * https://icu.unicode.org/design/struct/tries * and the bytestrie.h and ucharstrie.h header files. * * int32_t indexes[indexesLength]; -- indexesLength=indexes[IX_STRING_TRIE_OFFSET]/4; * * The first four indexes are byte offsets in ascending order. * Each byte offset marks the start of the next part in the data file, * and the end of the previous one. * When two consecutive byte offsets are the same, then the corresponding part is empty. * Byte offsets are offsets from after the header, * that is, from the beginning of the indexes[]. * Each part starts at an offset with proper alignment for its data. * If necessary, the previous part may include padding bytes to achieve this alignment. * * trieType=indexes[IX_TRIE_TYPE] defines the trie type. * transform=indexes[IX_TRANSFORM] defines the Unicode-to-bytes transformation. * If the transformation type is TRANSFORM_TYPE_OFFSET, * then the lower 21 bits contain the offset code point. * Each code point c is mapped to byte b = (c - offset). * Code points outside the range offset..(offset+0xff) cannot be mapped * and do not occur in the dictionary. * * stringTrie; -- a serialized BytesTrie or UCharsTrie * * The dictionary maps strings to specific values (TRIE_HAS_VALUES bit set in trieType), * or it maps all strings to 0 (TRIE_HAS_VALUES bit not set). */ #endif /* !UCONFIG_NO_BREAK_ITERATION */ #endif /* __DICTIONARYDATA_H__ */