MOVED:
--------------------------------------------------------------------------- RCS file: /cvsroot/open-beos/current/src/kits/support/CharacterSetRoster.cpp,v Working file: CharacterSetRoster.cpp head: 1.3 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 3; selected revisions: 3 description: ---------------------------- revision 1.3 date: 2003/08/13 10:12:46; author: shatty; state: Exp; lines: +9 -0 error protection for Get functions ---------------------------- revision 1.2 date: 2003/07/27 22:06:27; author: shatty; state: Exp; lines: +4 -0 added checking again MIME name ---------------------------- revision 1.1 date: 2003/07/26 21:26:36; author: shatty; state: Exp; add character set support git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5809 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
#include <CharacterSet.h>
|
||||
#include <CharacterSetRoster.h>
|
||||
#include "character_sets.h"
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
BCharacterSetRoster::BCharacterSetRoster()
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
BCharacterSetRoster::~BCharacterSetRoster()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
status_t
|
||||
BCharacterSetRoster::GetNextCharacterSet(BCharacterSet * charset)
|
||||
{
|
||||
if (charset == 0) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
if (index >= character_sets_by_id_count) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
*charset = *character_sets_by_id[index++];
|
||||
return B_NO_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
BCharacterSetRoster::RewindCharacterSets()
|
||||
{
|
||||
index = 0;
|
||||
if (index >= character_sets_by_id_count) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
return B_NO_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
BCharacterSetRoster::StartWatching(BMessenger target)
|
||||
{
|
||||
// TODO: implement it
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
BCharacterSetRoster::StopWatching(BMessenger target)
|
||||
{
|
||||
// TODO: implement it
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
const BCharacterSet *
|
||||
BCharacterSetRoster::GetCharacterSetByFontID(uint32 id)
|
||||
{
|
||||
if ((id < 0) || (id >= character_sets_by_id_count)) {
|
||||
return NULL;
|
||||
}
|
||||
return character_sets_by_id[id];
|
||||
}
|
||||
|
||||
const BCharacterSet *
|
||||
BCharacterSetRoster::GetCharacterSetByConversionID(uint32 id)
|
||||
{
|
||||
if ((id+1 < 0) || (id+1 >= character_sets_by_id_count)) {
|
||||
return NULL;
|
||||
}
|
||||
return character_sets_by_id[id+1];
|
||||
}
|
||||
|
||||
const BCharacterSet *
|
||||
BCharacterSetRoster::GetCharacterSetByMIBenum(uint32 MIBenum)
|
||||
{
|
||||
if ((MIBenum < 0) || (MIBenum > maximum_valid_MIBenum)) {
|
||||
return NULL;
|
||||
}
|
||||
return character_sets_by_MIBenum[MIBenum];
|
||||
}
|
||||
|
||||
const BCharacterSet *
|
||||
BCharacterSetRoster::FindCharacterSetByPrintName(char * name)
|
||||
{
|
||||
for (int id = 0 ; (id < character_sets_by_id_count) ; id++) {
|
||||
if (strcmp(character_sets_by_id[id]->GetPrintName(),name) == 0) {
|
||||
return character_sets_by_id[id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const BCharacterSet *
|
||||
BCharacterSetRoster::FindCharacterSetByName(char * name)
|
||||
{
|
||||
for (int id = 0 ; (id < character_sets_by_id_count) ; id++) {
|
||||
if (strcmp(character_sets_by_id[id]->GetName(),name) == 0) {
|
||||
return character_sets_by_id[id];
|
||||
}
|
||||
const char * mime = character_sets_by_id[id]->GetMIMEName();
|
||||
if ((mime != NULL) && (strcmp(mime,name) == 0)) {
|
||||
return character_sets_by_id[id];
|
||||
}
|
||||
for (int alias = 0 ; (alias < character_sets_by_id[id]->CountAliases()) ; alias++) {
|
||||
if (strcmp(character_sets_by_id[id]->AliasAt(alias),name) == 0) {
|
||||
return character_sets_by_id[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user