Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / protocols / ace / INet / String_IOStream.h
blobf1be7ffa2da88c19cf796186877d6eeab3425bf7
1 /**
2 * @file String_IOStream.h
4 * @author Martin Corino <mcorino@remedy.nl>
5 */
7 #ifndef ACE_IOS_STRING_IOSTREAM_H
8 #define ACE_IOS_STRING_IOSTREAM_H
10 #include /**/ "ace/pre.h"
12 #include "ace/INet/INet_Export.h"
13 #include "ace/INet/BufferedStreamBuffer.h"
14 #include "ace/SString.h"
15 #include <istream>
16 #include <ostream>
18 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
20 namespace ACE
22 namespace IOS
24 /**
25 * @class ACE_IOS_String_StreamBuffer
27 * @brief
30 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
31 class String_StreamBufferBase
32 : public BasicBufferedStreamBuffer<ACE_CHAR_T, TR>
34 public:
35 typedef BasicBufferedStreamBuffer<ACE_CHAR_T, TR> super;
36 typedef typename super::char_type char_type;
37 typedef typename super::openmode openmode;
38 typedef ACE_String_Base<ACE_CHAR_T> string_type;
39 typedef typename string_type::size_type size_type;
40 typedef typename super::pos_type pos_type;
41 typedef typename super::off_type off_type;
42 typedef typename super::seekdir seekdir;
44 String_StreamBufferBase (openmode mode);
45 String_StreamBufferBase (string_type& string, openmode mode);
46 virtual ~String_StreamBufferBase ();
48 const string_type& str () const;
50 void close_string ();
52 void clear_string ();
54 protected:
55 virtual int read_from_stream (char_type* buffer, std::streamsize length);
57 virtual int write_to_stream (const char_type* buffer, std::streamsize length);
59 virtual pos_type seekoff (off_type off,
60 seekdir way,
61 openmode which);
63 virtual pos_type seekpos (pos_type pos,
64 openmode which);
66 private:
67 enum
69 BUFFER_SIZE = 1024
72 string_type string_;
73 string_type * string_ref_;
74 size_type rd_ptr_;
77 /**
78 * @class ACE_IOS_String_IOS
80 * @brief
83 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
84 class String_IOSBase
85 : public virtual std::basic_ios<ACE_CHAR_T, TR>
87 public:
88 typedef std::basic_ios<ACE_CHAR_T, TR> ios_base;
89 typedef String_StreamBufferBase<ACE_CHAR_T, TR> buffer_type;
90 typedef typename buffer_type::string_type string_type;
91 typedef typename buffer_type::openmode openmode;
93 String_IOSBase (openmode mode);
94 String_IOSBase (string_type& string, openmode mode);
95 ~String_IOSBase ();
97 buffer_type* rdbuf ();
99 void close ();
101 const buffer_type& stream () const;
103 protected:
104 buffer_type streambuf_;
108 * @class ACE_IOS_Sock_OStream
110 * @brief
113 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
114 class String_OStreamBase
115 : public String_IOSBase<ACE_CHAR_T, TR>,
116 public std::basic_ostream<ACE_CHAR_T, TR>
118 public:
119 typedef String_IOSBase<ACE_CHAR_T, TR> ios_base;
120 typedef typename ios_base::string_type string_type;
122 explicit String_OStreamBase();
123 explicit String_OStreamBase(string_type& string);
124 ~String_OStreamBase();
126 const string_type& str () const;
128 void clear ();
132 * @class ACE_IOS_Sock_IStream
134 * @brief
137 template <class ACE_CHAR_T, class TR = std::char_traits<ACE_CHAR_T> >
138 class String_IStreamBase
139 : public String_IOSBase<ACE_CHAR_T, TR>,
140 public std::basic_istream<ACE_CHAR_T, TR>
142 public:
143 typedef String_IOSBase<ACE_CHAR_T, TR> ios_base;
144 typedef typename ios_base::string_type string_type;
145 typedef typename ios_base::buffer_type::pos_type pos_type;
147 explicit String_IStreamBase();
148 explicit String_IStreamBase(const string_type& string);
149 ~String_IStreamBase();
151 String_IStreamBase& rewind ();
154 typedef String_StreamBufferBase<char> CString_StreamBuffer;
155 typedef String_IOSBase<char> CString_IOS;
156 typedef String_OStreamBase<char> CString_OStream;
157 typedef String_IStreamBase<char> CString_IStream;
161 ACE_END_VERSIONED_NAMESPACE_DECL
163 #include "ace/INet/String_IOStream.cpp"
165 #include /**/ "ace/post.h"
166 #endif /* ACE_IOS_STRING_IOSTREAM_H */