1 #include "ace/INet/FTP_IOStream.h"
2 #include "ace/INet/IOS_util.h"
4 #if !defined (__ACE_INLINE__)
5 #include "ace/INet/FTP_IOStream.inl"
8 #include "ace/Truncate.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 StreamBuffer::StreamBuffer (std::iostream
* stream
)
18 : ACE::IOS::BufferedStreamBuffer (BUFFER_SIZE
,
19 std::ios::in
| std::ios::out
),
24 StreamBuffer::~StreamBuffer ()
28 std::iostream
* StreamBuffer::set_stream (std::iostream
* stream
)
30 std::iostream
* old_stream
= this->stream_
;
31 this->stream_
= stream
;
32 this->reset_buffers ();
36 int StreamBuffer::read_from_stream (char* buffer
, std::streamsize length
)
38 if (this->stream_
== 0) return -1;
39 this->stream_
->read (buffer
, length
);
40 return ACE_Utils::truncate_cast
<int> (this->stream_
->gcount ());
43 int StreamBuffer::write_to_stream (const char* buffer
, std::streamsize length
)
45 if (this->stream_
== 0) return -1;
46 this->stream_
->write (buffer
, length
);
47 return this->stream_
->good () ? ACE_Utils::truncate_cast
<int> (length
) : -1;
50 int StreamBuffer::sync ()
52 if (this->stream_
== 0) return -1;
53 if (ACE::IOS::BufferedStreamBuffer::sync () == -1)
55 return this->stream_
->sync ();
58 IOS::IOS (std::iostream
* stream
)
61 ace_ios_init (&this->streambuf_
);
68 this->streambuf_
.sync();
75 std::iostream
* IOS::set_stream (std::iostream
* stream
)
77 std::iostream
* old_stream
= this->rdbuf ()->set_stream (stream
);
82 OStream::OStream(std::iostream
* stream
)
83 : IOS (stream
), std::ostream (&streambuf_
)
91 IStream::IStream(std::iostream
* stream
)
92 : IOS (stream
), std::istream (&streambuf_
)
103 ACE_END_VERSIONED_NAMESPACE_DECL