rtstreams.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "fosi.h"
00039
00040 #include "rtconversions.hpp"
00041 #include "rtstreambufs.hpp"
00042
00043 #ifndef RTSTREAMS_HPP
00044 #define RTSTREAMS_HPP
00045
00046 namespace RTT
00047 {
00057 namespace rt_std
00058 {
00059
00075 class RTT_API basic_streams
00076 {
00077
00078 public:
00079 virtual ~basic_streams();
00080
00086
00087
00088
00089
00090
00091
00097
00098
00099
00100
00101
00102 };
00103
00112 class RTT_API basic_istreams
00113 : virtual public basic_streams
00114 {
00115
00116 public:
00117 typedef streambufs::streamsize streamsize;
00118
00119 basic_istreams( streambufs& s ) : buf(s) {}
00120 virtual ~basic_istreams();
00121
00122 int get();
00123 basic_istreams& get(char& c);
00124 basic_istreams& get(char* c, streamsize n, char delim);
00125 basic_istreams& get(char* c, char delim);
00126
00127 basic_istreams& read( char* c, streamsize n );
00128 streamsize readsome( char* c, streamsize n);
00129
00130
00131 basic_istreams& operator>>( int &i );
00132 basic_istreams& operator>>( char &c );
00133 basic_istreams& operator>>( double &f );
00134 basic_istreams& operator>>( std::string &s );
00135 basic_istreams& operator>>( unsigned int &u );
00136 private:
00137 streambufs& buf;
00138 };
00139
00144 class RTT_API basic_ostreams : virtual public basic_streams
00145 {
00146
00147 public:
00148 typedef streambufs::streamsize streamsize;
00149
00150 basic_ostreams( streambufs& s ) : buf(s) {}
00151 virtual ~basic_ostreams();
00152
00153 virtual basic_ostreams& put( char c );
00154 virtual basic_ostreams& write( const char * c, streamsize n );
00155
00160 basic_ostreams& operator<<( int i );
00161 basic_ostreams& operator<<( long i );
00162 basic_ostreams& operator<<( char c );
00163 basic_ostreams& operator<<( char * c );
00164 basic_ostreams& operator<<( double f );
00165 basic_ostreams& operator<<( std::string s );
00166 basic_ostreams& operator<<( unsigned int u );
00167 basic_ostreams& operator<<( basic_ostreams & ( *f ) ( basic_ostreams & ) );
00168 private:
00169 streambufs& buf;
00170 };
00171
00172
00173
00177 basic_ostreams& endl( basic_ostreams& );
00178
00179
00183 class RTT_API basic_iostreams
00184 : public basic_istreams, public basic_ostreams
00185 {
00186 public:
00187 basic_iostreams( streambufs& s)
00188 : basic_istreams(s), basic_ostreams(s) {}
00189 };
00190
00191
00192 struct RTT_API print_helper { printbufs printer; };
00193
00199 class RTT_API printstream
00200 : private print_helper, public basic_ostreams
00201 {
00202
00203 public:
00204 printstream() : basic_ostreams(printer) {}
00205 virtual ~printstream();
00206 };
00207
00211 extern printstream cout;
00212
00213 struct RTT_API string_helper { string_helper() : str() {}; string_helper(const std::string& _init) : str(_init) {}; stringbufs str; };
00214
00218 class RTT_API stringstreams
00219 : private string_helper, public basic_iostreams
00220 {
00221 public:
00222 stringstreams(const std::string& _init) : string_helper(_init), basic_iostreams(str) {}
00223 stringstreams() : string_helper(), basic_iostreams(str) {}
00224 virtual ~stringstreams();
00225 };
00226
00227 }
00228 }
00229 #endif