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 namespace ICQ2000 {
00035 class TranslatorException : public std::exception {
00036 private:
00037 std::string m_errortext;
00038
00039 public:
00040 TranslatorException(const std::string& text);
00041 ~TranslatorException() throw() { }
00042
00043 const char* what() const throw();
00044 };
00045
00046 class Translator{
00047 public:
00048 Translator();
00049 void setDefaultTranslationMap();
00050 void setTranslationMap(const std::string& szMapFileName);
00051 void ServerToClient(std::string& szString);
00052 void ClientToServer(std::string& szString);
00053 std::string ServerToClientCC(const std::string& szString);
00054 std::string ClientToServerCC(const std::string& szString);
00055 void ServerToClient(char &_cChar);
00056 void ClientToServer(char &_cChar);
00057 static void CRLFtoLF(std::string& s);
00058 static void LFtoCRLF(std::string& s);
00059 bool usingDefaultMap() const { return m_bDefault; }
00060 const std::string& getMapFileName() const { return m_szMapFileName; }
00061 const std::string& getMapName() const { return m_szMapName; }
00062
00063 protected:
00064 unsigned char serverToClientTab[256];
00065 unsigned char clientToServerTab[256];
00066 std::string m_szMapFileName, m_szMapName;
00067 bool m_bDefault;
00068 };
00069 }
00070
00071 #endif