Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ACE_IOS_STRING_IOSTREAM_H
00010 #define ACE_IOS_STRING_IOSTREAM_H
00011
00012 #include "ace/pre.h"
00013
00014 #include "ace/INet/INet_Export.h"
00015 #include "ace/INet/BufferedStreamBuffer.h"
00016 #include "ace/SString.h"
00017 #include <istream>
00018 #include <ostream>
00019
00020 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00021
00022 namespace ACE
00023 {
00024 namespace IOS
00025 {
00026
00027
00028
00029
00030
00031
00032 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
00033 class String_StreamBufferBase
00034 : public BasicBufferedStreamBuffer<ACE_CHAR_T, TR>
00035 {
00036 public:
00037 typedef BasicBufferedStreamBuffer<ACE_CHAR_T, TR> super;
00038 typedef typename super::char_type char_type;
00039 typedef typename super::openmode openmode;
00040 typedef ACE_String_Base<ACE_CHAR_T> string_type;
00041 typedef typename string_type::size_type size_type;
00042 typedef typename super::pos_type pos_type;
00043 typedef typename super::off_type off_type;
00044 typedef typename super::seekdir seekdir;
00045
00046 String_StreamBufferBase (openmode mode);
00047 String_StreamBufferBase (string_type& string, openmode mode);
00048 virtual ~String_StreamBufferBase ();
00049
00050 const string_type& str () const;
00051
00052 void close_string ();
00053
00054 void clear_string ();
00055
00056 protected:
00057 virtual int read_from_stream (char_type* buffer, std::streamsize length);
00058
00059 virtual int write_to_stream (const char_type* buffer, std::streamsize length);
00060
00061 virtual pos_type seekoff (off_type off,
00062 seekdir way,
00063 openmode which);
00064
00065 virtual pos_type seekpos (pos_type pos,
00066 openmode which);
00067
00068 private:
00069 enum
00070 {
00071 BUFFER_SIZE = 1024
00072 };
00073
00074 string_type string_;
00075 string_type * string_ref_;
00076 size_type rd_ptr_;
00077 };
00078
00079
00080
00081
00082
00083
00084
00085 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
00086 class String_IOSBase
00087 : public virtual std::basic_ios<ACE_CHAR_T, TR>
00088 {
00089 public:
00090 typedef std::basic_ios<ACE_CHAR_T, TR> ios_base;
00091 typedef String_StreamBufferBase<ACE_CHAR_T, TR> buffer_type;
00092 typedef typename buffer_type::string_type string_type;
00093 typedef typename buffer_type::openmode openmode;
00094
00095 String_IOSBase (openmode mode);
00096 String_IOSBase (string_type& string, openmode mode);
00097 ~String_IOSBase ();
00098
00099 buffer_type* rdbuf ();
00100
00101 void close ();
00102
00103 const buffer_type& stream () const;
00104
00105 protected:
00106 buffer_type streambuf_;
00107 };
00108
00109
00110
00111
00112
00113
00114
00115 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
00116 class String_OStreamBase
00117 : public String_IOSBase<ACE_CHAR_T, TR>,
00118 public std::basic_ostream<ACE_CHAR_T, TR>
00119 {
00120 public:
00121 typedef String_IOSBase<ACE_CHAR_T, TR> ios_base;
00122 typedef typename ios_base::string_type string_type;
00123
00124 explicit String_OStreamBase();
00125 explicit String_OStreamBase(string_type& string);
00126 ~String_OStreamBase();
00127
00128 const string_type& str () const;
00129
00130 void clear ();
00131 };
00132
00133
00134
00135
00136
00137
00138
00139 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
00140 class String_IStreamBase
00141 : public String_IOSBase<ACE_CHAR_T, TR>,
00142 public std::basic_istream<ACE_CHAR_T, TR>
00143 {
00144 public:
00145 typedef String_IOSBase<ACE_CHAR_T, TR> ios_base;
00146 typedef typename ios_base::string_type string_type;
00147 typedef typename ios_base::buffer_type::pos_type pos_type;
00148
00149 explicit String_IStreamBase();
00150 explicit String_IStreamBase(const string_type& string);
00151 ~String_IStreamBase();
00152
00153 String_IStreamBase& rewind ();
00154 };
00155
00156 typedef String_StreamBufferBase<char> CString_StreamBuffer;
00157 typedef String_IOSBase<char> CString_IOS;
00158 typedef String_OStreamBase<char> CString_OStream;
00159 typedef String_IStreamBase<char> CString_IStream;
00160
00161 }
00162 }
00163
00164 ACE_END_VERSIONED_NAMESPACE_DECL
00165
00166 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00167 #include "ace/INet/String_IOStream.cpp"
00168 #endif
00169
00170 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00171 #pragma implementation ("String_IOStream.cpp")
00172 #endif
00173
00174 #include "ace/post.h"
00175 #endif