1 #include "ace/INet/HTTP_IOStream.h"
2 #include "ace/INet/IOS_util.h"
4 #if !defined (__ACE_INLINE__)
5 #include "ace/INet/HTTP_IOStream.inl"
8 #include "ace/Truncate.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 StreamBuffer::StreamBuffer (std::iostream
& stream
, StreamBuffer::policy_type
* policy
)
18 : ACE::IOS::BufferedStreamBuffer (BUFFER_SIZE
,
19 std::ios::in
| std::ios::out
),
24 this->policy_
->set_stream_buffer (this);
27 StreamBuffer::~StreamBuffer ()
33 int StreamBuffer::read_from_stream (char* buffer
, std::streamsize length
)
36 return this->policy_
->read_from_stream (buffer
, length
);
38 return this->read_from_stream_i (buffer
, length
);
41 int StreamBuffer::read_from_stream_i (char* buffer
, std::streamsize length
)
43 this->stream_
.read (buffer
, length
);
44 return ACE_Utils::truncate_cast
<int> (this->stream_
.gcount ());
47 int StreamBuffer::write_to_stream (const char* buffer
, std::streamsize length
)
50 return this->policy_
->write_to_stream (buffer
, length
);
52 return this->write_to_stream_i (buffer
, length
);
55 int StreamBuffer::write_to_stream_i (const char* buffer
, std::streamsize length
)
57 this->stream_
.write (buffer
, length
);
58 return this->stream_
.good () ? ACE_Utils::truncate_cast
<int> (length
) : -1;
61 int StreamBuffer::sync ()
63 if (ACE::IOS::BufferedStreamBuffer::sync () == -1)
65 return this->stream_
.sync ();
68 IOS::IOS (std::iostream
& stream
, StreamBuffer::policy_type
* policy
)
69 : streambuf_ (stream
, policy
)
71 ace_ios_init (&this->streambuf_
);
78 this->streambuf_
.sync();
85 OStream::OStream(std::iostream
& stream
, StreamBuffer::policy_type
* policy
)
86 : IOS (stream
, policy
), std::ostream (&streambuf_
)
94 IStream::IStream(std::iostream
& stream
, StreamBuffer::policy_type
* policy
)
95 : IOS (stream
, policy
), std::istream (&streambuf_
)
106 ACE_END_VERSIONED_NAMESPACE_DECL