3 #include <CharacterSet.h>
4 #include <CharacterSetRoster.h>
5 #include "character_sets.h"
9 BCharacterSetRoster::BCharacterSetRoster()
14 BCharacterSetRoster::~BCharacterSetRoster()
20 BCharacterSetRoster::GetNextCharacterSet(BCharacterSet
* charset
)
25 if (index
>= character_sets_by_id_count
) {
28 *charset
= *character_sets_by_id
[index
++];
33 BCharacterSetRoster::RewindCharacterSets()
36 if (index
>= character_sets_by_id_count
) {
43 BCharacterSetRoster::StartWatching(BMessenger target
)
50 BCharacterSetRoster::StopWatching(BMessenger target
)
57 BCharacterSetRoster::GetCharacterSetByFontID(uint32 id
)
59 if ((id
< 0) || (id
>= character_sets_by_id_count
)) {
62 return character_sets_by_id
[id
];
66 BCharacterSetRoster::GetCharacterSetByConversionID(uint32 id
)
68 if ((id
+1 < 0) || (id
+1 >= character_sets_by_id_count
)) {
71 return character_sets_by_id
[id
+1];
75 BCharacterSetRoster::GetCharacterSetByMIBenum(uint32 MIBenum
)
77 if ((MIBenum
< 0) || (MIBenum
> maximum_valid_MIBenum
)) {
80 return character_sets_by_MIBenum
[MIBenum
];
84 BCharacterSetRoster::FindCharacterSetByPrintName(const char * name
)
86 for (uint id
= 0 ; (id
< character_sets_by_id_count
) ; id
++) {
87 if (strcmp(character_sets_by_id
[id
]->GetPrintName(),name
) == 0) {
88 return character_sets_by_id
[id
];
95 BCharacterSetRoster::FindCharacterSetByName(const char * name
)
97 // first search standard names and mime names
98 for (uint id
= 0 ; (id
< character_sets_by_id_count
) ; id
++) {
99 if (strcasecmp(character_sets_by_id
[id
]->GetName(),name
) == 0) {
100 return character_sets_by_id
[id
];
102 const char * mime
= character_sets_by_id
[id
]->GetMIMEName();
103 if ((mime
!= NULL
) && (strcasecmp(mime
,name
) == 0)) {
104 return character_sets_by_id
[id
];
107 // only after searching all the above names do we look at aliases
108 for (uint id
= 0 ; (id
< character_sets_by_id_count
) ; id
++) {
109 for (int alias
= 0 ; (alias
< character_sets_by_id
[id
]->CountAliases()) ; alias
++) {
110 if (strcasecmp(character_sets_by_id
[id
]->AliasAt(alias
),name
) == 0) {
111 return character_sets_by_id
[id
];