00001 #ifndef __CENCODING_H
00002 #define __CENCODING_H
00003
00004 #include "CExpander.h"
00005
00006 #define MAX_ENCODING 6
00007
00008 class CEncoding : public CCharacterSource
00009 {
00010 friend class CFilterChain;
00011 protected:
00012 CExpander_Interface* parent;
00013 linkType hyperlink(unsigned int n, unsigned int noff, QString& t, QString& nm) { return parent->hyperlink(n, noff, t, nm); }
00014 public:
00015 virtual QString getTableAsHtml(unsigned long loc)
00016 {
00017 qDebug("CEncoding::getTableAsHtml()");
00018 return parent->getTableAsHtml(loc);
00019 }
00020 CEncoding() : parent(NULL) {}
00021 void setparent(CExpander_Interface* p) { parent = p; }
00022 virtual ~CEncoding() {};
00023 void locate(unsigned int n) { parent->locate(n); }
00024 bool findanchor(const QString& nm)
00025 {
00026 return parent->findanchor(nm);
00027 }
00028 void saveposn(const QString& f, size_t posn) { parent->saveposn(posn); }
00029 void writeposn(const QString& f, size_t posn) { parent->writeposn(posn); }
00030 linkType forward(QString& f, size_t& loc) { return parent->forward(loc); }
00031 linkType back(QString& f, size_t& loc) { return parent->back(loc); }
00032 bool hasnavigation() { return parent->hasnavigation(); }
00033 virtual int getwidth() { return parent->getwidth(); }
00034 QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); }
00035 QImage* getPicture(const QString& href) { return parent->getPicture(href); }
00036 bool getFile(const QString& href, const QString& nm) { qDebug("Encoding Get File"); return parent->getFile(href, nm);}
00037 unsigned long startSection() { return parent->startSection(); }
00038 };
00039
00040 class CUtf8 : public CEncoding
00041 {
00042 public:
00043 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00044 QString about() { return QString("UTF8 decoder (c) Tim Wentford\n")+parent->about(); }
00045 };
00046
00047 class CUcs16be : public CEncoding
00048 {
00049 public:
00050 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00051 QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); }
00052 };
00053
00054 class CUcs16le : public CEncoding
00055 {
00056 public:
00057 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00058 QString about() { return QString("UCS16 decoder (c) Tim Wentford\n")+parent->about(); }
00059 };
00060
00061 class Ccp1252 : public CEncoding
00062 {
00063 public:
00064 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00065 QString about() { return QString("Codepage 1252 decoder (c) Tim Wentford\n")+parent->about(); }
00066 };
00067
00068 class CPalm : public Ccp1252
00069 {
00070 public:
00071 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00072 QString about() { return QString("Palm decoder (c) Tim Wentford\n")+parent->about(); }
00073 };
00074
00075 class CAscii : public CEncoding
00076 {
00077 public:
00078 void getch(tchar& ch, CStyle& sty, unsigned long& pos);
00079 QString about() { return QString("Vanilla Ascii decoder (c) Tim Wentford\n")+parent->about(); }
00080 };
00081
00082 #include "CEncoding_tables.h"
00083
00084 class CGeneral8Bit : public CEncoding
00085 {
00086 int m_index;
00087 public:
00088 CGeneral8Bit(int _i) : m_index(_i)
00089 {
00090
00091
00092 }
00093 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
00094 {
00095 parent->getch(ch, sty, pos);
00096 ch = unicodetable::unicodevalue(m_index, ch);
00097 }
00098 QString about() { return QString("8-bit decoder (c) Tim Wentford - based on QT code\n")+parent->about(); }
00099 };
00100
00101 #endif