The Power in your Hands
Search Site:
About
Features
Documentation
Download
Community
Main
Classes
Namespaces
Modules
include
Pt
Ssl
StreamBuffer.h
1
/*
2
* Copyright (C) 2010-2012 by Marc Boris Duerner
3
* Copyright (C) 2010-2010 by Aloysius Indrayanto
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
*
10
* As a special exception, you may use this file as part of a free
11
* software library without restriction. Specifically, if other files
12
* instantiate templates or use macros or inline functions from this
13
* file, or you compile this file and link it with other files to
14
* produce an executable, this file does not by itself cause the
15
* resulting executable to be covered by the GNU General Public
16
* License. This exception does not however invalidate any other
17
* reasons why the executable file might be covered by the GNU Library
18
* General Public License.
19
*
20
* This library is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23
* Lesser General Public License for more details.
24
*
25
* You should have received a copy of the GNU Lesser General Public
26
* License along with this library; if not, write to the Free Software
27
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28
*/
29
30
#ifndef PT_SSL_StreamBuffer_H
31
#define PT_SSL_StreamBuffer_H
32
33
#include <Pt/Ssl/Api.h>
34
#include <Pt/Ssl/Context.h>
35
#include <Pt/StreamBuffer.h>
36
#include <ios>
37
#include <cstddef>
38
39
namespace
Pt {
40
41
namespace
Ssl {
42
43
class
Connection;
44
47
class
PT_SSL_API
StreamBuffer
:
public
BasicStreamBuffer
<char>
48
{
49
public
:
52
StreamBuffer
(std::size_t bufferSize = 1024);
53
56
StreamBuffer
(
Context
& ctx, std::ios& ios,
OpenMode
mode, std::size_t bufferSize = 1024);
57
60
virtual
~
StreamBuffer
();
61
64
void
open(
Context
& ctx, std::ios& ios,
OpenMode
mode);
65
68
void
setPeerName(
const
std::string& peerName);
69
72
const
char
* currentCipher()
const
;
73
76
void
close();
77
80
bool
isConnected()
const
;
81
86
bool
writeHandshake();
87
93
bool
readHandshake(std::streamsize maxRead = 0);
94
102
bool
shutdown();
103
106
bool
isShutdown()
const
;
107
110
bool
isClosed()
const
;
111
117
std::streamsize
import
(std::streamsize maxImport = 0);
118
119
protected
:
120
// inheritdoc
121
virtual
std::streamsize showmanyc();
122
123
// inheritdoc
124
virtual
std::streamsize showfull();
125
126
// inheritdoc
127
virtual
int
sync();
128
129
// inheritdoc
130
virtual
int_type underflow();
131
132
// inheritdoc
133
virtual
int_type overflow(int_type ch);
134
135
private
:
136
Connection
* _connection;
137
std::string _peerName;
138
std::size_t _ibufferSize;
139
char
* _ibuffer;
140
std::size_t _obufferSize;
141
char
* _obuffer;
142
143
static
const
int
_pbmax = 4;
144
};
145
146
}
// namespace Ssl
147
148
}
// namespace Pt
149
150
#endif // PT_SSL_StreamBuffer_H
Pt::Ssl::StreamBuffer
SSL stream buffer.
Definition:
StreamBuffer.h:47
Pt::BasicStreamBuffer
Buffer for input and output streams.
Definition:
StreamBuffer.h:51
Pt::Connection
Represents a connection between a Signal/Delegate and a slot.
Definition:
Connection.h:90
Pt::Ssl::Context
Context for SSL connections.
Definition:
Context.h:76
Pt::Ssl::OpenMode
OpenMode
Open mode for ssl I/O.
Definition:
Context.h:52