Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

Translator.h

00001 /*
00002  * Translate class
00003  *
00004  * Many parts of this source code were 'inspired' by the ircII4.4 translat.c source.
00005  * RIPPED FROM KVirc: http://www.kvirc.org
00006  * Original by Szymon Stefanek (kvirc@tin.it).
00007  * Modified by Andrew Frolov (dron@linuxer.net)
00008  * Further modified by Graham Roff
00009  *
00010  * 'Borrowed' from licq - thanks Barnaby
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Lesser General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2.1 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this library; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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

Generated on Sun Jul 21 10:57:32 2002 for libicq2000 by doxygen1.2.16