1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ********************************************************************** 5 * Copyright (C) 2013, International Business Machines 6 * Corporation and others. All Rights Reserved. 7 ********************************************************************** 8 * 9 * scriptset.h 10 * 11 * created on: 2013 Jan 7 12 * created by: Andy Heninger 13 */ 14 15 #ifndef __SCRIPTSET_H__ 16 #define __SCRIPTSET_H__ 17 18 #include "unicode/utypes.h" 19 #include "unicode/uobject.h" 20 #include "unicode/uscript.h" 21 22 #include "uelement.h" 23 24 U_NAMESPACE_BEGIN 25 26 //------------------------------------------------------------------------------- 27 // 28 // ScriptSet - A bit set representing a set of scripts. 29 // 30 // This class was originally used exclusively with script sets appearing 31 // as part of the spoof check whole script confusable binary data. Its 32 // use has since become more general, but the continued use to wrap 33 // prebuilt binary data does constrain the design. 34 // 35 //------------------------------------------------------------------------------- 36 class U_I18N_API ScriptSet: public UMemory { 37 public: 38 ScriptSet(); 39 ScriptSet(const ScriptSet &other); 40 ~ScriptSet(); 41 42 UBool operator == (const ScriptSet &other) const; 43 UBool operator != (const ScriptSet &other) const {return !(*this == other);}; 44 ScriptSet & operator = (const ScriptSet &other); 45 46 UBool test(UScriptCode script, UErrorCode &status) const; 47 ScriptSet &Union(const ScriptSet &other); 48 ScriptSet &set(UScriptCode script, UErrorCode &status); 49 ScriptSet &reset(UScriptCode script, UErrorCode &status); 50 ScriptSet &intersect(const ScriptSet &other); 51 ScriptSet &intersect(UScriptCode script, UErrorCode &status); 52 UBool intersects(const ScriptSet &other) const; // Sets contain at least one script in commmon. 53 UBool contains(const ScriptSet &other) const; // All set bits in other are also set in this. 54 55 ScriptSet &setAll(); 56 ScriptSet &resetAll(); 57 int32_t countMembers() const; 58 int32_t hashCode() const; 59 int32_t nextSetBit(int32_t script) const; 60 61 UBool isEmpty() const; 62 63 UnicodeString &displayScripts(UnicodeString &dest) const; // append script names to dest string. 64 ScriptSet & parseScripts(const UnicodeString &scriptsString, UErrorCode &status); // Replaces ScriptSet contents. 65 66 // Wraps around UScript::getScriptExtensions() and adds the corresponding scripts to this instance. 67 void setScriptExtensions(UChar32 codePoint, UErrorCode& status); 68 69 private: 70 uint32_t bits[6]; 71 }; 72 73 U_NAMESPACE_END 74 75 U_CAPI UBool U_EXPORT2 76 uhash_compareScriptSet(const UElement key1, const UElement key2); 77 78 U_CAPI int32_t U_EXPORT2 79 uhash_hashScriptSet(const UElement key); 80 81 U_CAPI void U_EXPORT2 82 uhash_deleteScriptSet(void *obj); 83 84 #endif // __SCRIPTSET_H__ 85