// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** * * Copyright (C) 2007, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** * file name: bmpset.h * encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * * created on: 2007jan29 * created by: Markus W. Scherer */ #ifndef __BMPSET_H__ #define __BMPSET_H__ #include "unicode/utypes.h" #include "unicode/uniset.h" U_NAMESPACE_BEGIN /* * Helper class for frozen UnicodeSets, implements contains() and span() * optimized for BMP code points. Structured to be UTF-8-friendly. * * ASCII: Look up bytes. * 2-byte characters: Bits organized vertically. * 3-byte characters: Use zero/one/mixed data per 64-block in U+0000..U+FFFF, * with mixed for illegal ranges. * Supplementary characters: Call contains() on the parent set. */ class BMPSet : public UMemory { public: BMPSet(const int32_t *parentList, int32_t parentListLength); BMPSet(const BMPSet &otherBMPSet, const int32_t *newParentList, int32_t newParentListLength); virtual ~BMPSet(); virtual UBool contains(UChar32 c) const; /* * Span the initial substring for which each character c has spanCondition==contains(c). * It must be s0 and spanCondition==0 or 1. * @return The string pointer which limits the span. */ const uint8_t *spanUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const; /* * Span the trailing substring for which each character c has spanCondition==contains(c). * It must be length>0 and spanCondition==0 or 1. * @return The start of the span. */ int32_t spanBackUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const; private: void initBits(); void overrideIllegal(); /** * Same as UnicodeSet::findCodePoint(UChar32 c) const except that the * binary search is restricted for finding code points in a certain range. * * For restricting the search for finding in the range start..end, * pass in * lo=findCodePoint(start) and * hi=findCodePoint(end) * with 0<=lo<=hi