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

isslstream.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 __i_ssl_stream_hpp
00021 #define __i_ssl_stream_hpp
00022 
00023 #include <iostream>
00024 
00025 #include <stdexcept>
00026 
00027 #include <string>
00028 
00029 #include <openssl/ssl.h>
00030 
00031 
00032 #include "istreambase.hpp"
00033 
00034 namespace MynahSA { 
00035 
00046   class ISSLStream : public IStreamBase {
00047   public:
00049     ISSLStream(SSL* s);
00050   
00056     ISSLStream(const ISSLStream& i);
00057   
00058   
00060     ~ISSLStream();
00061   
00062   
00063     virtual IStreamBase& operator>>(char&);
00064     virtual IStreamBase& operator>>(unsigned char&);
00065     
00066     virtual IStreamBase& operator>>(short&);
00067     virtual IStreamBase& operator>>(unsigned short&);
00068     
00069     virtual IStreamBase& operator>>(bool&);
00070     
00071     virtual IStreamBase& operator>>(int&);
00072     virtual IStreamBase& operator>>(unsigned int&);
00073     
00074     virtual IStreamBase& operator>>(long long&);
00075     virtual IStreamBase& operator>>(unsigned long long&);
00076     
00077     virtual IStreamBase& operator>>(double&);
00078     virtual IStreamBase& operator>>(float&);
00079     
00081     virtual IStreamBase& operator>>(std::string& s);
00082       
00083       
00084     using IStreamBase::operator>>;
00085       
00086     bool is_open() const { return _open; }
00087       
00088     // get a single char off of the stream
00089     virtual void get(char& );
00090       
00091   private:
00093     int sslRead(void* buf, int num);
00094   
00095     SSL* _ssl;
00096     bool _open;
00097     
00098   };
00099 };
00100 
00101 #endif