libdap
Updated for version 3.21.0
libdap4 is an implementation of OPeNDAP's DAP protocol.
fdiostream.h
1
// -*- mode: c++; c-basic-offset:4 -*-
2
3
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4
// Access Protocol.
5
6
// Copyright (c) 2009 OPeNDAP, Inc.
7
// Author: James Gallagher <jgallagher@opendap.org>
8
//
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
13
//
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
//
23
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
//
25
// Portions of this code were taken verbatim from Josuttis,
26
// "The C++ Standard Library," p.672
27
28
#ifndef _fdiostream_h
29
#define _fdiostream_h
30
31
#ifdef HAVE_UNISTD_H
32
#include <unistd.h>
33
#endif
34
35
#include <iostream>
36
#include <streambuf>
37
#include <algorithm>
38
#include <cstdio>
39
40
namespace
libdap
{
41
50
class
fdoutbuf
:
public
std::streambuf {
51
protected
:
52
int
fd;
// file descriptor
53
bool
close;
54
static
const
int
bufferSize = 4096;
// Size of the data buffer
55
char
buffer[bufferSize];
// data buffer
56
57
public
:
58
fdoutbuf
(
int
_fd,
bool
_close);
59
virtual
~fdoutbuf
();
60
61
protected
:
62
int
flushBuffer();
63
64
virtual
int
overflow
(
int
c);
65
virtual
int
sync
();
66
virtual
std::streamsize
xsputn
(
const
char
*s, std::streamsize num);
67
};
68
77
class
fdostream
:
public
std::ostream {
78
protected
:
79
fdoutbuf
buf;
80
public
:
87
fdostream
(
int
_fd,
bool
_close =
false
) :
88
std::ostream(&buf), buf(_fd, _close)
89
{
90
}
91
};
92
101
class
fdinbuf
:
public
std::streambuf {
102
protected
:
103
int
fd;
// file descriptor
104
bool
close;
105
static
const
int
bufferSize = 4096;
// Size of the data buffer
106
static
const
int
putBack = 128;
107
char
buffer[bufferSize];
// data buffer
108
109
public
:
110
fdinbuf
(
int
_fd,
bool
close);
111
virtual
~fdinbuf
();
112
113
protected
:
114
virtual
int
underflow
();
115
};
116
126
class
fdistream
:
public
std::istream {
127
protected
:
128
fdinbuf
buf;
129
public
:
130
fdistream
(
int
fd,
bool
close =
false
) :
131
std::istream(&buf), buf(fd, close)
132
{
133
}
134
};
135
144
class
fpinbuf
:
public
std::streambuf {
145
protected
:
146
FILE *fp;
// FILE *
147
bool
close;
148
static
const
int
bufferSize = 4096;
// Size of the data buffer
149
static
const
int
putBack = 128;
150
char
buffer[bufferSize];
// data buffer
151
152
public
:
153
fpinbuf
(FILE *_fp,
bool
_close);
154
virtual
~fpinbuf
();
155
156
protected
:
157
virtual
int
underflow
();
158
};
159
170
class
fpistream
:
public
std::istream {
171
protected
:
172
fpinbuf
buf;
173
public
:
174
fpistream
(FILE *fp,
bool
close =
false
) :
175
std::istream(&buf), buf(fp, close)
176
{
177
}
178
};
179
180
}
181
182
#endif
libdap::fdinbuf
Definition
fdiostream.h:101
libdap::fdinbuf::underflow
virtual int underflow()
Definition
fdiostream.cc:172
libdap::fdinbuf::~fdinbuf
virtual ~fdinbuf()
Definition
fdiostream.cc:166
libdap::fdistream
Definition
fdiostream.h:126
libdap::fdostream
Definition
fdiostream.h:77
libdap::fdostream::fdostream
fdostream(int _fd, bool _close=false)
Definition
fdiostream.h:87
libdap::fdoutbuf
Definition
fdiostream.h:50
libdap::fdoutbuf::sync
virtual int sync()
Definition
fdiostream.cc:85
libdap::fdoutbuf::overflow
virtual int overflow(int c)
Definition
fdiostream.cc:69
libdap::fdoutbuf::xsputn
virtual std::streamsize xsputn(const char *s, std::streamsize num)
Definition
fdiostream.cc:95
libdap::fdoutbuf::~fdoutbuf
virtual ~fdoutbuf()
Definition
fdiostream.cc:51
libdap::fpinbuf
Definition
fdiostream.h:144
libdap::fpinbuf::~fpinbuf
virtual ~fpinbuf()
Definition
fdiostream.cc:228
libdap::fpinbuf::underflow
virtual int underflow()
Definition
fdiostream.cc:234
libdap::fpistream
Definition
fdiostream.h:170
libdap
top level DAP object to house generic methods
Definition
AISConnect.cc:30
fdiostream.h
Generated by
1.9.8