michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (C) 2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * michael@0: * scriptset.h michael@0: * michael@0: * created on: 2013 Jan 7 michael@0: * created by: Andy Heninger michael@0: */ michael@0: michael@0: #ifndef __SCRIPTSET_H__ michael@0: #define __SCRIPTSET_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/uobject.h" michael@0: #include "unicode/uscript.h" michael@0: michael@0: #include "uelement.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: //------------------------------------------------------------------------------- michael@0: // michael@0: // ScriptSet - A bit set representing a set of scripts. michael@0: // michael@0: // This class was originally used exclusively with script sets appearing michael@0: // as part of the spoof check whole script confusable binary data. Its michael@0: // use has since become more general, but the continued use to wrap michael@0: // prebuilt binary data does constrain the design. michael@0: // michael@0: //------------------------------------------------------------------------------- michael@0: class U_I18N_API ScriptSet: public UMemory { michael@0: public: michael@0: ScriptSet(); michael@0: ScriptSet(const ScriptSet &other); michael@0: ~ScriptSet(); michael@0: michael@0: UBool operator == (const ScriptSet &other) const; michael@0: ScriptSet & operator = (const ScriptSet &other); michael@0: michael@0: UBool test(UScriptCode script, UErrorCode &status) const; michael@0: ScriptSet &Union(const ScriptSet &other); michael@0: ScriptSet &set(UScriptCode script, UErrorCode &status); michael@0: ScriptSet &reset(UScriptCode script, UErrorCode &status); michael@0: ScriptSet &intersect(const ScriptSet &other); michael@0: ScriptSet &intersect(UScriptCode script, UErrorCode &status); michael@0: UBool intersects(const ScriptSet &other) const; // Sets contain at least one script in commmon. michael@0: UBool contains(const ScriptSet &other) const; // All set bits in other are also set in this. michael@0: michael@0: ScriptSet &setAll(); michael@0: ScriptSet &resetAll(); michael@0: int32_t countMembers() const; michael@0: int32_t hashCode() const; michael@0: int32_t nextSetBit(int32_t script) const; michael@0: michael@0: UnicodeString &displayScripts(UnicodeString &dest) const; // append script names to dest string. michael@0: ScriptSet & parseScripts(const UnicodeString &scriptsString, UErrorCode &status); // Replaces ScriptSet contents. michael@0: michael@0: private: michael@0: uint32_t bits[6]; michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: U_CAPI UBool U_EXPORT2 michael@0: uhash_compareScriptSet(const UElement key1, const UElement key2); michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: uhash_hashScriptSet(const UElement key); michael@0: michael@0: U_CAPI void U_EXPORT2 michael@0: uhash_deleteScriptSet(void *obj); michael@0: michael@0: #endif // __SCRIPTSET_H__