00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #ifndef TRANSLATOR_H
00029 #define TRANSLATOR_H
00030 
00031 #include <string>
00032 #include <exception>
00033 
00034 using std::exception;
00035 using std::string;
00036 
00037 namespace ICQ2000 {
00038   class TranslatorException : exception {
00039    private:
00040     string m_errortext;
00041     
00042    public:
00043     TranslatorException(const string& text);
00044     ~TranslatorException() throw() { }
00045     
00046     const char* what() const throw();
00047   };
00048 
00049   class Translator{
00050    public:
00051     Translator();
00052     void setDefaultTranslationMap();
00053     void setTranslationMap(const string& szMapFileName);
00054     void ServerToClient(string& szString);
00055     void ClientToServer(string& szString);
00056     void ServerToClient(char &_cChar);
00057     void ClientToServer(char &_cChar);
00058     static void CRLFtoLF(string& s);
00059     static void LFtoCRLF(string& s);
00060     bool usingDefaultMap() const { return m_bDefault; }
00061     const string& getMapFileName() const { return m_szMapFileName; }
00062     const string& getMapName() const { return m_szMapName; }
00063 
00064    protected:
00065     unsigned char serverToClientTab[256];
00066     unsigned char clientToServerTab[256];
00067     string m_szMapFileName, m_szMapName;
00068     bool m_bDefault;
00069   };
00070 }
00071 
00072 #endif