From 1b0ac0c0eec51c729b5343d1b624cc036c005775 Mon Sep 17 00:00:00 2001 From: shatty Date: Sat, 26 Jul 2003 21:24:40 +0000 Subject: [PATCH] yummy character set support git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4087 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/support/CharacterSet.h | 85 ++++++++++++++++++ headers/private/support/CharacterSetRoster.h | 91 ++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 headers/private/support/CharacterSet.h create mode 100644 headers/private/support/CharacterSetRoster.h diff --git a/headers/private/support/CharacterSet.h b/headers/private/support/CharacterSet.h new file mode 100644 index 0000000000..c1b290aecb --- /dev/null +++ b/headers/private/support/CharacterSet.h @@ -0,0 +1,85 @@ +#ifndef CHARACTER_SET_H +#define CHARACTER_SET_H + +#include + +namespace BPrivate { + +/** + * @file CharacterSet.h + * @author Andrew Bachmann + * @brief Defines BCharacterSet + * + * @see http://www.iana.org/assignments/character-sets + **/ + +class BCharacterSet { + /** + * @class BCharacterSet + * @brief An object holding a variety of useful information about a character set. + * + * This information has been derived from the IANA standards organization. + * Since IANA provides several names for some encodings, this object also + * provides for aliases. + **/ +public: + /** + * @brief constructor, for internal use only + **/ + BCharacterSet(uint32 id, uint32 MIBenum, const char * print_name, + const char * iana_name, const char * mime_name, + const char ** aliases); + /** + * @brief returns an id for use in BFont::SetEncoding + * @return an id for use in BFont::SetEncoding + **/ + uint32 GetFontID(void) const; + /** + * @brief returns an id for use in convert_to/from_utf8 + * @return an id for use in convert_to/from_utf8 + **/ + uint32 GetConversionID(void) const; + /** + * @brief returns an id for use in MIBs to identify coded character sets + * @return an id for use in MIBs to identify coded character sets + **/ + uint32 GetMIBenum(void) const; + /** + * @brief returns the IANA standard name for this character set + * @return the IANA standard name for this character set + **/ + const char * GetName(void) const; + /** + * @brief returns a user interface friendly name for this character set + * @return a user interface friendly name for this character set + **/ + const char * GetPrintName(void) const; + /** + * @brief returns the MIME preferred name for this character set, or null if none exists + * @return the MIME preferred name for this character set, or null if none exists + **/ + const char * GetMIMEName(void) const; + /** + * @brief returns the number of aliases for this character set + * @return the number of aliases for this character set + **/ + int32 CountAliases(void) const; + /** + * @brief returns the index'th alias, or NULL if out of range + * @return the index'th alias, or NULL if out of range + **/ + const char * AliasAt(uint32 index) const; + +private: + uint32 id; //! id from convert_to_utf8/convert_from_utf8 + uint32 MIBenum; //! for use in MIBs to identify coded character sets + const char * print_name; //! user interface friendly name + const char * iana_name; //! standard IANA name + const char * mime_name; //! the preferred mime name + const char ** aliases; //! aliases for this character set + uint32 aliases_count; //! how many aliases are available +}; + +} + +#endif CHARACTER_SET_H diff --git a/headers/private/support/CharacterSetRoster.h b/headers/private/support/CharacterSetRoster.h new file mode 100644 index 0000000000..bfe100b89b --- /dev/null +++ b/headers/private/support/CharacterSetRoster.h @@ -0,0 +1,91 @@ +#ifndef CHARACTER_SET_ROSTER_H +#define CHARACTER_SET_ROSTER_H + +#include +#include + +namespace BPrivate { + +/** + * @file BCharacterSetRoster.h + * @author Andrew Bachmann + * @brief Defines BCharacterSetRoster + * + * @see BCharacterSet.h + **/ + +class BCharacterSet; + +class BCharacterSetRoster { + /** + * @class BCharacterSetRoster + * @brief An object for finding or enumerating character sets + **/ +public: + /** + * @brief initialize the roster to the first character set + **/ + BCharacterSetRoster(); + virtual ~BCharacterSetRoster(); + + /** + * @brief get the next available character set + * @return B_NO_ERROR if it's valid, B_BAD_VALUE if it is not + **/ + status_t GetNextCharacterSet(BCharacterSet * charset); + /** + * @brief resets the iterator to the first character set + * @return B_NO_ERROR if it's valid, B_BAD_VALUE if it is not + **/ + status_t RewindCharacterSets(); + + /** + * @brief register BMessenger to receive notifications of character set events + * @return B_NO_ERROR if watching was okay, B_BAD_VALUE if poorly formed BMessenger + **/ + static status_t StartWatching(BMessenger target); + /** + * @brief stop sending notifications to BMessenger + * @return B_NO_ERROR if stopping went okay, B_BAD_VALUE if poorly formed BMessenger + **/ + static status_t StopWatching(BMessenger target); + + /** + * @brief return the character set with the given font id, or NULL if none exists + * This function executes in constant time. + * @return the character set with the given font id, or NULL if none exists + **/ + static const BCharacterSet * GetCharacterSetByFontID(uint32 id); + /** + * @brief return the character set with the given conversion id, or NULL if none exists + * This function executes in constant time. + * @return the character set with the given conversion id, or NULL if none exists + **/ + static const BCharacterSet * GetCharacterSetByConversionID(uint32 id); + /** + * @brief return the character set with the given MIB enum, or NULL if none exists + * This function executes in constant time. + * @return the character set with the given MIB enum, or NULL if none exists + **/ + static const BCharacterSet * GetCharacterSetByMIBenum(uint32 MIBenum); + + /** + * @brief return the character set with the given print name, or NULL if none exists + * This function executes in linear time. + * @return the character set with the given print name, or NULL if none exists + **/ + static const BCharacterSet * FindCharacterSetByPrintName(char * name); + /** + * @brief return the character set with the given name, or NULL if none exists + * This function will match aliases as well. + * This function executes in linear time. + * @return the character set with the given name, or NULL if none exists + **/ + static const BCharacterSet * FindCharacterSetByName(char * name); +private: + uint32 index; //! the state variable for iteration +}; + +} + +#endif CHARACTER_SET_ROSTER_H