Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / protocols / ace / INet / HTTP_IOStream.cpp
blobc7dabea92c69d9b35a658cfd65a7030cd728c790
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"
6 #endif
8 #include "ace/Truncate.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 namespace ACE
15 namespace HTTP
17 StreamBuffer::StreamBuffer (std::iostream& stream, StreamBuffer::policy_type* policy)
18 : ACE::IOS::BufferedStreamBuffer (BUFFER_SIZE,
19 std::ios::in | std::ios::out),
20 stream_ (stream),
21 policy_ (policy)
23 if (this->policy_)
24 this->policy_->set_stream_buffer (this);
27 StreamBuffer::~StreamBuffer ()
29 if (this->policy_)
30 delete this->policy_;
33 int StreamBuffer::read_from_stream (char* buffer, std::streamsize length)
35 if (this->policy_)
36 return this->policy_->read_from_stream (buffer, length);
37 else
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)
49 if (this->policy_)
50 return this->policy_->write_to_stream (buffer, length);
51 else
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)
64 return -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_);
74 IOS::~IOS ()
76 try
78 this->streambuf_.sync();
80 catch (...)
85 OStream::OStream(std::iostream& stream, StreamBuffer::policy_type* policy)
86 : IOS (stream, policy), std::ostream (&streambuf_)
90 OStream::~OStream()
94 IStream::IStream(std::iostream& stream, StreamBuffer::policy_type* policy)
95 : IOS (stream, policy), std::istream (&streambuf_)
99 IStream::~IStream()
106 ACE_END_VERSIONED_NAMESPACE_DECL