00001 /************************************************************************************ 00002 * This file is part of the MynahSA streaming and archiving toolkit * 00003 * Copyright (C) 2006 Mynah-Software Ltd. All Rights Reserved. * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License, version 2 * 00007 * as published by the Free Software Foundation. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License along * 00015 * with this program; if not, write to the Free Software Foundation, Inc., * 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 00017 * * 00018 ************************************************************************************/ 00019 00020 #ifndef __o_tcp_stream_hpp 00021 #define __o_tcp_stream_hpp 00022 00023 #include <iostream> 00024 00025 #include <stdexcept> 00026 00027 #include <string> 00028 00029 #include "ostreambase.hpp" 00030 00031 00032 namespace MynahSA { 00042 class OTCPStream : public OStreamBase { 00043 public: 00045 OTCPStream(int s); 00046 00048 OTCPStream(const OTCPStream& s); 00049 00051 ~OTCPStream(); 00052 00053 00054 virtual OStreamBase& operator<<(const char); 00055 virtual OStreamBase& operator<<(const unsigned char); 00056 00057 virtual OStreamBase& operator<<(const short); 00058 virtual OStreamBase& operator<<(const unsigned short); 00059 00060 virtual OStreamBase& operator<<(const bool); 00061 00062 virtual OStreamBase& operator<<(const int); 00063 virtual OStreamBase& operator<<(const unsigned int); 00064 00065 virtual OStreamBase& operator<<(const long long); 00066 virtual OStreamBase& operator<<(const unsigned long long); 00067 00068 virtual OStreamBase& operator<<(const double); 00069 virtual OStreamBase& operator<<(const float); 00070 00072 virtual OStreamBase& operator<<(const std::string& s); 00073 00074 // using declaration to allow base method to be used. 00075 using OStreamBase::operator<<; 00076 00078 void flush(); 00079 00080 private: 00082 int _sd; 00083 00085 char* _buffer; 00086 00088 unsigned int _buffPtr; 00089 00091 int tcpWrite(const void* data, unsigned int size); 00092 00093 }; 00094 00095 }; 00096 00097 00098 #endif