Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osslstream.hpp

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_ssl_stream_hpp
00021 #define __o_ssl_stream_hpp
00022 
00023 #include <iostream>
00024 
00025 #include <stdexcept>
00026 
00027 #include <string>
00028 
00029 #include <openssl/ssl.h>
00030 
00031 #include "ostreambase.hpp"
00032 
00033 
00034 namespace MynahSA { 
00043   class OSSLStream : public OStreamBase {
00044   public:
00046     OSSLStream(SSL* s);
00047   
00049     OSSLStream(const OSSLStream& s);
00050   
00052     ~OSSLStream();
00053   
00054   
00055     virtual OStreamBase& operator<<(const char);
00056     virtual OStreamBase& operator<<(const unsigned char);
00057     
00058     virtual OStreamBase& operator<<(const short);
00059     virtual OStreamBase& operator<<(const unsigned short);
00060     
00061     virtual OStreamBase& operator<<(const bool);
00062     
00063     virtual OStreamBase& operator<<(const int);
00064     virtual OStreamBase& operator<<(const unsigned int);
00065     
00066     virtual OStreamBase& operator<<(const long long);
00067     virtual OStreamBase& operator<<(const unsigned long long);
00068     
00069     virtual OStreamBase& operator<<(const double);
00070     virtual OStreamBase& operator<<(const float);
00071     
00073     virtual OStreamBase& operator<<(const std::string& s);
00074       
00075     // using declaration to allow base method to be used.
00076     using OStreamBase::operator<<;
00077       
00079     void flush();
00080       
00081   private:
00083     SSL* _ssl;
00084     
00086     char* _buffer;
00087     
00089     unsigned int _buffPtr;
00090   
00092     int sslWrite(const void* data, unsigned int size);
00093     
00094   };
00095 };
00096 
00097 
00098 
00099 #endif