add character set support
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4088 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
#include <CharacterSet.h>
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
BCharacterSet::BCharacterSet(uint32 _id, uint32 _MIBenum, const char * _print_name,
|
||||||
|
const char * _iana_name, const char * _mime_name,
|
||||||
|
const char ** _aliases)
|
||||||
|
{
|
||||||
|
id = _id;
|
||||||
|
MIBenum = _MIBenum;
|
||||||
|
print_name = _print_name;
|
||||||
|
iana_name = _iana_name;
|
||||||
|
mime_name = _mime_name;
|
||||||
|
aliases_count = 0;
|
||||||
|
while (_aliases[aliases_count] != 0) {
|
||||||
|
aliases_count++;
|
||||||
|
}
|
||||||
|
aliases = _aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
BCharacterSet::GetFontID() const
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
BCharacterSet::GetConversionID() const
|
||||||
|
{
|
||||||
|
return id-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
BCharacterSet::GetMIBenum() const
|
||||||
|
{
|
||||||
|
return MIBenum;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
BCharacterSet::GetName() const
|
||||||
|
{
|
||||||
|
return iana_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
BCharacterSet::GetPrintName() const
|
||||||
|
{
|
||||||
|
return print_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
BCharacterSet::GetMIMEName() const
|
||||||
|
{
|
||||||
|
return mime_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32
|
||||||
|
BCharacterSet::CountAliases() const
|
||||||
|
{
|
||||||
|
return aliases_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
BCharacterSet::AliasAt(uint32 index) const
|
||||||
|
{
|
||||||
|
if (index >= aliases_count) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return aliases[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#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)
|
||||||
|
{
|
||||||
|
return character_sets_by_id[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
const BCharacterSet *
|
||||||
|
BCharacterSetRoster::GetCharacterSetByConversionID(uint32 id)
|
||||||
|
{
|
||||||
|
return character_sets_by_id[id+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const BCharacterSet *
|
||||||
|
BCharacterSetRoster::GetCharacterSetByMIBenum(uint32 MIBenum)
|
||||||
|
{
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
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