19 #ifndef INCLUDE_RCF_MEMSTREAM_HPP 20 #define INCLUDE_RCF_MEMSTREAM_HPP 26 #include <RCF/Config.hpp> 27 #include <RCF/ByteBuffer.hpp> 28 #include <RCF/ReallocBuffer.hpp> 29 #include <RCF/Tools.hpp> 38 public std::streambuf,
42 MemIstreamBuf(
char * buffer = NULL, std::size_t bufferLen = 0);
44 void reset(
char * buffer, std::size_t bufferLen);
47 std::streambuf::int_type underflow();
51 std::ios_base::seekdir dir,
52 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
55 std::size_t mBufferLen;
60 class RCF_EXPORT MemIstream :
61 public std::basic_istream<char>
64 MemIstream(
const char * buffer = NULL, std::size_t bufferLen = 0);
66 void reset(
const char * buffer, std::size_t bufferLen);
70 MemIstreamBuf * mpBuf;
74 std::istream::pos_type getReadPos();
77 void read(
char *_Str, std::streamsize _Count);
78 std::streamsize readsome(
char *_Str, std::streamsize _Count);
79 std::streamsize gcount();
80 void putback(
char _Ch);
81 std::istream::pos_type moveReadPos(std::istream::pos_type newPos);
85 RCF_EXPORT MemIstream & operator>>(MemIstream & is, std::string & s);
86 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
char & ch);
87 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
signed char & ch);
88 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned char & ch);
89 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
bool & b);
90 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
short & b);
91 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned short & b);
92 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
int & n);
93 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned int & n);
94 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
long & n);
95 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned long & n);
96 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
float & d);
97 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
double & d);
98 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
long double & d);
101 RCF_EXPORT MemIstream & operator>>(MemIstream & is, __int64 & n);
102 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned __int64 & n);
104 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
long long & n);
105 RCF_EXPORT MemIstream & operator>>(MemIstream & is,
unsigned long long & n);
110 class MemOstreamBuf :
111 public std::streambuf,
119 std::streambuf::int_type overflow(std::streambuf::int_type ch);
123 std::ios_base::seekdir dir,
124 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
126 friend class MemOstream;
127 ReallocBuffer mWriteBuffer;
132 class RCF_EXPORT MemOstream :
133 public std::basic_ostream<char>
140 std::size_t length();
141 std::string string();
143 std::size_t capacity();
147 rdbuf()->pubseekoff(0, std::ios::beg, std::ios::out);
153 MemOstreamBuf * mpBuf;
183 typedef std::shared_ptr<MemOstream> MemOstreamPtr;
188 inline MemOstream & operator<<(MemOstream & os,
const T * pt)
190 static_cast<std::ostream&
>(os) << pt;
195 inline MemOstream & operator<<(MemOstream & os, const std::shared_ptr<T> & pt)
197 static_cast<std::ostream&
>(os) << pt.get();
201 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
const std::string & s);
202 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
const char * sz);
203 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
char ch);
204 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
signed char ch);
205 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned char ch);
206 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
bool b);
207 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
short b);
208 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned short b);
209 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
int n);
210 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned int n);
211 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
long n);
212 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned long n);
213 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
float d);
214 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
double d);
215 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
long double d);
218 RCF_EXPORT MemOstream & operator<<(MemOstream & os, __int64 n);
219 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned __int64 n);
221 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
long long n);
222 RCF_EXPORT MemOstream & operator<<(MemOstream & os,
unsigned long long n);
225 typedef std::ostream& (*Pfn)(std::ostream&);
226 RCF_EXPORT MemOstream & operator<<(MemOstream & os, Pfn pfn);
Definition: AmiIoHandler.hpp:24