peerplays-fc/src/sstream.cpp

73 lines
2.3 KiB
C++
Raw Normal View History

#include <fc/sstream.hpp>
#include <fc/fwd_impl.hpp>
2012-10-22 00:54:52 +00:00
#include <fc/log.hpp>
#include <sstream>
namespace fc {
class stringstream::impl {
public:
impl( fc::string&s )
:ss( s )
{ }
impl( const fc::string&s )
:ss( s )
{ }
impl(){}
std::stringstream ss;
};
stringstream::stringstream( fc::string& s )
:my(s) {
}
stringstream::stringstream( const fc::string& s )
:my(s) {
}
stringstream::stringstream(){}
stringstream::~stringstream(){}
fc::string stringstream::str(){
return my->ss.str();//.c_str();//*reinterpret_cast<fc::string*>(&st);
}
bool stringstream::eof()const {
return my->ss.eof();
}
ostream& stringstream::write( const char* buf, size_t len ) {
my->ss.write(buf,len);
return *this;
}
size_t stringstream::readsome( char* buf, size_t len ) {
2012-12-18 19:37:14 +00:00
return static_cast<size_t>(my->ss.readsome(buf,len));
}
istream& stringstream::read( char* buf, size_t len ) {
my->ss.read(buf,len);
return *this;
}
2012-10-22 00:54:52 +00:00
void stringstream::close(){ my->ss.flush(); };
void stringstream::flush(){ my->ss.flush(); };
istream& stringstream::read( int64_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( uint64_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( int32_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( uint32_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( int16_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( uint16_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( int8_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( uint8_t& v ) { my->ss >> v; return *this; }
istream& stringstream::read( float& v ) { my->ss >> v; return *this; }
istream& stringstream::read( double& v ) { my->ss >> v; return *this; }
istream& stringstream::read( bool& v ) { my->ss >> v; return *this; }
istream& stringstream::read( char& v ) { my->ss >> v; return *this; }
istream& stringstream::read( fc::string& v ) { my->ss >> *reinterpret_cast<std::string*>(&v); return *this; }
ostream& stringstream::write( const fc::string& s) {
2012-10-22 00:54:52 +00:00
my->ss.write( s.c_str(), s.size() );
return *this;
}
}