![]() |
StreamWriter.cppGo to the documentation of this file.00001 00006 /* 00007 Copyright (C) 2008-2011 Anders Hedstrom 00008 00009 This library is made available under the terms of the GNU GPL, with 00010 the additional exemption that compiling, linking, and/or using OpenSSL 00011 is allowed. 00012 00013 If you would like to use this library in a closed-source application, 00014 a separate license agreement is available. For information about 00015 the closed-source license agreement for the C++ sockets library, 00016 please visit http://www.alhem.net/Sockets/license.html and/or 00017 email license@alhem.net. 00018 00019 This program is free software; you can redistribute it and/or 00020 modify it under the terms of the GNU General Public License 00021 as published by the Free Software Foundation; either version 2 00022 of the License, or (at your option) any later version. 00023 00024 This program is distributed in the hope that it will be useful, 00025 but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00027 GNU General Public License for more details. 00028 00029 You should have received a copy of the GNU General Public License 00030 along with this program; if not, write to the Free Software 00031 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00032 */ 00033 #include "StreamWriter.h" 00034 #include "IStream.h" 00035 #include "Utility.h" 00036 00037 00038 #ifdef SOCKETS_NAMESPACE 00039 namespace SOCKETS_NAMESPACE { 00040 #endif 00041 00042 00043 StreamWriter::StreamWriter(IStream& stream) : m_stream(stream) 00044 { 00045 } 00046 00047 00048 StreamWriter& StreamWriter::operator<<(const char *buf) 00049 { 00050 m_stream.IStreamWrite(buf, strlen(buf)); 00051 return *this; 00052 } 00053 00054 00055 StreamWriter& StreamWriter::operator<<(const std::string& str) 00056 { 00057 m_stream.IStreamWrite(str.c_str(), str.size()); 00058 return *this; 00059 } 00060 00061 00062 StreamWriter& StreamWriter::operator<<(short x) 00063 { 00064 *this << Utility::l2string(x); 00065 return *this; 00066 } 00067 00068 00069 StreamWriter& StreamWriter::operator<<(int x) 00070 { 00071 *this << Utility::l2string(x); 00072 return *this; 00073 } 00074 00075 00076 StreamWriter& StreamWriter::operator<<(long x) 00077 { 00078 *this << Utility::l2string(x); 00079 return *this; 00080 } 00081 00082 00083 StreamWriter& StreamWriter::operator<<(double x) 00084 { 00085 *this << Utility::ToString(x); 00086 return *this; 00087 } 00088 00089 00090 #ifdef SOCKETS_NAMESPACE 00091 } // namespace SOCKETS_NAMESPACE { 00092 #endif |