00001 // $Id: Sock_IOStream.cpp 90789 2010-06-23 10:30:53Z mcorino $ 00002 00003 #ifndef ACE_IOS_SOCK_IOSTREAM_CPP 00004 #define ACE_IOS_SOCK_IOSTREAM_CPP 00005 00006 #include "ace/INet/Sock_IOStream.h" 00007 #include "ace/INet/IOS_util.h" 00008 00009 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00010 00011 namespace ACE 00012 { 00013 namespace IOS 00014 { 00015 00016 template <ACE_SYNCH_DECL> 00017 Sock_StreamBufferBase<ACE_SYNCH_USE>::Sock_StreamBufferBase (stream_type* stream) 00018 : BidirStreamBuffer<StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> > ( 00019 stream, 00020 BUFFER_SIZE, 00021 std::ios::in | std::ios::out) 00022 { 00023 } 00024 00025 template <ACE_SYNCH_DECL> 00026 Sock_StreamBufferBase<ACE_SYNCH_USE>::~Sock_StreamBufferBase () 00027 { 00028 } 00029 00030 template <ACE_SYNCH_DECL> 00031 Sock_IOSBase<ACE_SYNCH_USE>::Sock_IOSBase (stream_type* stream) 00032 : streambuf_ (stream) 00033 { 00034 ace_ios_init (&this->streambuf_); 00035 } 00036 00037 template <ACE_SYNCH_DECL> 00038 Sock_IOSBase<ACE_SYNCH_USE>::~Sock_IOSBase () 00039 { 00040 try 00041 { 00042 this->streambuf_.sync(); 00043 } 00044 catch (...) 00045 { 00046 } 00047 } 00048 00049 template <ACE_SYNCH_DECL> 00050 typename Sock_IOSBase<ACE_SYNCH_USE>::buffer_type* 00051 Sock_IOSBase<ACE_SYNCH_USE>::rdbuf () 00052 { 00053 return &this->streambuf_; 00054 } 00055 00056 template <ACE_SYNCH_DECL> 00057 void Sock_IOSBase<ACE_SYNCH_USE>::close () 00058 { 00059 this->streambuf_.sync (); 00060 this->streambuf_.close_stream (); 00061 } 00062 00063 template <ACE_SYNCH_DECL> 00064 const typename Sock_IOSBase<ACE_SYNCH_USE>::stream_type& 00065 Sock_IOSBase<ACE_SYNCH_USE>::stream () const 00066 { 00067 return this->streambuf_.stream (); 00068 } 00069 00070 00071 template <ACE_SYNCH_DECL> 00072 Sock_OStreamBase<ACE_SYNCH_USE>::Sock_OStreamBase(stream_type* stream) 00073 : Sock_IOSBase<ACE_SYNCH_USE> (stream), std::ostream (Sock_IOSBase<ACE_SYNCH_USE>::rdbuf ()) 00074 { 00075 } 00076 00077 template <ACE_SYNCH_DECL> 00078 Sock_OStreamBase<ACE_SYNCH_USE>::~Sock_OStreamBase() 00079 { 00080 } 00081 00082 template <ACE_SYNCH_DECL> 00083 void Sock_OStreamBase<ACE_SYNCH_USE>::set_interceptor ( 00084 typename buffer_type::interceptor_type& interceptor) 00085 { 00086 this->rdbuf ()->set_interceptor (interceptor); 00087 } 00088 00089 template <ACE_SYNCH_DECL> 00090 Sock_IStreamBase<ACE_SYNCH_USE>::Sock_IStreamBase(stream_type* stream) 00091 : Sock_IOSBase<ACE_SYNCH_USE> (stream), std::istream (Sock_IOSBase<ACE_SYNCH_USE>::rdbuf ()) 00092 { 00093 } 00094 00095 template <ACE_SYNCH_DECL> 00096 Sock_IStreamBase<ACE_SYNCH_USE>::~Sock_IStreamBase () 00097 { 00098 } 00099 00100 template <ACE_SYNCH_DECL> 00101 void Sock_IStreamBase<ACE_SYNCH_USE>::set_interceptor ( 00102 typename buffer_type::interceptor_type& interceptor) 00103 { 00104 this->rdbuf ()->set_interceptor (interceptor); 00105 } 00106 00107 template <ACE_SYNCH_DECL> 00108 Sock_IOStreamBase<ACE_SYNCH_USE>::Sock_IOStreamBase(stream_type* stream) 00109 : Sock_IOSBase<ACE_SYNCH_USE> (stream), std::iostream (Sock_IOSBase<ACE_SYNCH_USE>::rdbuf ()) 00110 { 00111 } 00112 00113 template <ACE_SYNCH_DECL> 00114 Sock_IOStreamBase<ACE_SYNCH_USE>::~Sock_IOStreamBase () 00115 { 00116 } 00117 00118 template <ACE_SYNCH_DECL> 00119 void Sock_IOStreamBase<ACE_SYNCH_USE>::set_interceptor ( 00120 typename buffer_type::interceptor_type& interceptor) 00121 { 00122 this->rdbuf ()->set_interceptor (interceptor); 00123 } 00124 00125 } 00126 } 00127 00128 ACE_END_VERSIONED_NAMESPACE_DECL 00129 00130 #endif /* ACE_IOS_SOCK_IOSTREAM_CPP */