00001 /************************************************************************ 00002 * EPP RTK C++ 00003 * Copyright (C) 2001 Global Name Registry 00004 * 00005 * This library is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU Lesser General Public License as published 00007 * by the Free Software Foundation; either version 2.1 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 * Contact information: epprtk@gnr.com 00020 * 00021 * EPP RTK 00022 * GNR Ltd. 00023 * 125 High Holborn 00024 * London WC1V 6QA 00025 * United Kingdom 00026 ************************************************************************/ 00027 00028 #ifndef __EPP_TRANSPORTBASE_H 00029 #define __EPP_TRANSPORTBASE_H 00030 00031 #include <string> 00032 #include <exception> 00033 #include <cstdio> 00034 00035 namespace epptransport { 00036 00037 class epp_TransportBase { 00038 public: 00039 00040 epp_TransportBase() {}; 00041 00042 virtual ~epp_TransportBase() {}; 00043 00044 virtual void writeToServer(const string & xml_string) = 0; 00045 virtual string readFromServer() = 0; 00046 00047 virtual void connect() {}; 00048 virtual void disconnect() {}; 00049 }; 00050 00051 00052 class epp_TrException : public exception { 00053 00054 public: 00055 00056 string m_error_message; 00057 00058 epp_TrException() {}; 00059 virtual ~epp_TrException() {}; 00060 00061 epp_TrException(const string & data) throw() 00062 { 00063 m_error_message = data; 00064 }; 00065 00066 // Kept for backwords compatibility: 00067 virtual string getString() 00068 { 00069 return m_error_message; 00070 } 00071 00072 epp_TrException(const string file, const int lineno, const string & data) throw() 00073 { 00074 char buf[10]; 00075 sprintf(buf,"%d",lineno); 00076 m_error_message = file; 00077 m_error_message += ":"; 00078 m_error_message += buf; 00079 m_error_message += ": "; 00080 m_error_message = data; 00081 }; 00082 }; 00083 00084 }; 00085 00086 #endif