UCommon
Main Page
Namespaces
Data Structures
Files
Examples
File List
Globals
ucommon
buffer.h
Go to the documentation of this file.
1
// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
2
//
3
// This file is part of GNU uCommon C++.
4
//
5
// GNU uCommon C++ is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published
7
// by the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// GNU uCommon C++ is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17
23
#ifndef _UCOMMON_BUFFER_H_
24
#define _UCOMMON_BUFFER_H_
25
26
#ifndef _UCOMMON_CONFIG_H_
27
#include <
ucommon/platform.h
>
28
#endif
29
30
#ifndef _UCOMMON_PROTOCOLS_H_
31
#include <
ucommon/protocols.h
>
32
#endif
33
34
#ifndef _UCOMMON_SOCKET_H_
35
#include <
ucommon/socket.h
>
36
#endif
37
38
#ifndef _UCOMMON_STRING_H_
39
#include <
ucommon/string.h
>
40
#endif
41
42
#ifndef _UCOMMON_FSYS_H_
43
#include <
ucommon/fsys.h
>
44
#endif
45
46
#ifndef _UCOMMON_SHELL_H_
47
#include <
ucommon/shell.h
>
48
#endif
49
50
NAMESPACE_UCOMMON
51
58
class
fbuf
:
public
BufferProtocol
,
private
fsys
59
{
60
private
:
61
offset_t inpos, outpos;
62
shell::pid_t pid;
63
64
protected
:
65
size_t
_push(
const
char
*address,
size_t
size);
66
size_t
_pull(
char
*address,
size_t
size);
67
int
_err(
void
)
const
;
68
void
_clear(
void
);
69
70
inline
fd_t getfile(
void
)
71
{
return
fd;};
72
73
public
:
77
fbuf
();
78
82
~
fbuf
();
83
91
fbuf
(
const
char
*path,
fsys::access_t
access
,
unsigned
permissions,
size_t
size);
92
100
fbuf
(
const
char
*path,
fsys::access_t
access,
char
**argv,
size_t
size,
char
**envp = NULL);
101
108
fbuf
(
const
char
*path,
fsys::access_t
access,
size_t
size);
109
118
void
create(
const
char
*path,
fsys::access_t
access = fsys::ACCESS_APPEND,
unsigned
permissions = 0640,
size_t
size = 512);
119
126
void
open(
const
char
*path,
fsys::access_t
access = fsys::ACCESS_RDWR,
size_t
size = 512);
127
135
void
open(
const
char
*path,
fsys::access_t
access,
char
**argv,
size_t
size = 512,
char
**envp = NULL);
136
140
void
close(
void
);
141
145
void
terminate(
void
);
146
147
inline
void
cancel(
void
)
148
{terminate();}
149
157
bool
seek(offset_t offset);
158
165
bool
trunc(offset_t offset);
166
173
offset_t tell(
void
);
174
};
175
182
class
__EXPORT
TCPBuffer
:
public
BufferProtocol
,
protected
Socket
183
{
184
protected
:
185
void
_buffer(
size_t
size);
186
187
virtual
size_t
_push
(
const
char
*
address
,
size_t
size);
188
virtual
size_t
_pull
(
char
*address,
size_t
size);
189
int
_err
(
void
)
const
;
190
void
_clear
(
void
);
191
bool
_blocking
(
void
);
192
197
inline
socket_t getsocket(
void
)
const
198
{
return
so;};
199
200
public
:
204
TCPBuffer
();
205
211
TCPBuffer
(
const
TCPServer
*server,
size_t
size = 536);
212
219
TCPBuffer
(
const
char
*host,
const
char
*service,
size_t
size = 536);
220
224
virtual
~
TCPBuffer
();
225
232
void
open(
const
TCPServer
*server,
size_t
size = 536);
233
241
void
open(
const
char
*host,
const
char
*service,
size_t
size = 536);
242
246
void
close(
void
);
247
248
protected
:
253
virtual
bool
_pending
(
void
);
254
};
255
259
typedef
fbuf
file_t
;
260
264
typedef
TCPBuffer
tcp_t
;
265
266
END_NAMESPACE
267
268
#endif
Generated by
1.8.1.2