2
* Copyright 2006-2008 The FLWOR Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include "passthru_streambuf.h"
23
///////////////////////////////////////////////////////////////////////////////
25
passthru_streambuf::passthru_streambuf( char const*, streambuf *orig ) :
26
proxy_streambuf( orig )
29
throw invalid_argument( "null streambuf" );
32
passthru_streambuf::~passthru_streambuf() {
33
// out-of-line since it's virtual
36
void passthru_streambuf::imbue( std::locale const &loc ) {
37
original()->pubimbue( loc );
40
bool passthru_streambuf::is_necessary( char const *cc_charset ) {
41
zstring charset( cc_charset );
42
ascii::trim_whitespace( charset );
43
ascii::to_upper( charset );
44
return charset != "ASCII"
45
&& charset != "US-ASCII"
46
&& charset != "UTF-8";
49
bool passthru_streambuf::is_supported( char const *cc_charset ) {
50
return !is_necessary( charset );
53
passthru_streambuf::pos_type
54
passthru_streambuf::seekoff( off_type o, ios_base::seekdir d,
55
ios_base::openmode m ) {
56
return original()->pubseekoff( o, d, m );
59
passthru_streambuf::pos_type
60
passthru_streambuf::seekpos( pos_type p, ios_base::openmode m ) {
61
return original()->pubseekpos( p, m );
64
streambuf* passthru_streambuf::setbuf( char_type *p, streamsize s ) {
65
original()->pubsetbuf( p, s );
69
streamsize passthru_streambuf::showmanyc() {
70
return original()->in_avail();
73
int passthru_streambuf::sync() {
74
return original()->pubsync();
77
passthru_streambuf::int_type passthru_streambuf::overflow( int_type c ) {
78
return original()->sputc( c );
81
passthru_streambuf::int_type passthru_streambuf::pbackfail( int_type c ) {
82
return original()->sputbackc( traits_type::to_char_type( c ) );
85
passthru_streambuf::int_type passthru_streambuf::uflow() {
86
return original()->sbumpc();
89
passthru_streambuf::int_type passthru_streambuf::underflow() {
90
return original()->sgetc();
93
streamsize passthru_streambuf::xsgetn( char_type *to, streamsize size ) {
94
return original()->sgetn( to, size );
97
streamsize passthru_streambuf::xsputn( char_type const *from,
99
return original()->sputn( from, size );
102
///////////////////////////////////////////////////////////////////////////////
105
/* vim:set et sw=2 ts=2: */