Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sstream.cpp
Go to the documentation of this file.
1#include <fc/io/sstream.hpp>
2#include <fc/fwd_impl.hpp>
4#include <fc/log/logger.hpp>
5#include <sstream>
6
7namespace fc {
9 public:
11 :ss( s )
12 { ss.exceptions( std::stringstream::badbit ); }
13
14 impl( const fc::string&s )
15 :ss( s )
16 { ss.exceptions( std::stringstream::badbit ); }
17
18 impl(){ss.exceptions( std::stringstream::badbit ); }
19
20 std::stringstream ss;
21 };
22
23 stringstream::stringstream( fc::string& s )
24 :my(s) {
25 }
26 stringstream::stringstream( const fc::string& s )
27 :my(s) {
28 }
29 stringstream::stringstream(){}
30 stringstream::~stringstream(){}
31
32
33 fc::string stringstream::str(){
34 return my->ss.str();//.c_str();//*reinterpret_cast<fc::string*>(&st);
35 }
36
37 void stringstream::str(const fc::string& s) {
38 my->ss.str(s);
39 }
40
41 void stringstream::clear() {
42 my->ss.clear();
43 }
44
45
46 bool stringstream::eof()const {
47 return my->ss.eof();
48 }
49 size_t stringstream::writesome( const char* buf, size_t len ) {
50 my->ss.write(buf,len);
51 if( my->ss.eof() )
52 {
53 FC_THROW_EXCEPTION( eof_exception, "stringstream" );
54 }
55 return len;
56 }
57 size_t stringstream::writesome( const std::shared_ptr<const char>& buf, size_t len, size_t offset )
58 {
59 return writesome(buf.get() + offset, len);
60 }
61
62 size_t stringstream::readsome( char* buf, size_t len ) {
63 size_t r = static_cast<size_t>(my->ss.readsome(buf,len));
64 if( my->ss.eof() || r == 0 )
65 {
66 FC_THROW_EXCEPTION( eof_exception, "stringstream" );
67 }
68 return r;
69 }
70 size_t stringstream::readsome( const std::shared_ptr<char>& buf, size_t len, size_t offset )
71 {
72 return readsome(buf.get() + offset, len);
73 }
74
75
76 void stringstream::close(){ my->ss.flush(); };
77 void stringstream::flush(){ my->ss.flush(); };
78
79 /*
80 istream& stringstream::read( char* buf, size_t len ) {
81 my->ss.read(buf,len);
82 return *this;
83 }
84 istream& stringstream::read( int64_t& v ) { my->ss >> v; return *this; }
85 istream& stringstream::read( uint64_t& v ) { my->ss >> v; return *this; }
86 istream& stringstream::read( int32_t& v ) { my->ss >> v; return *this; }
87 istream& stringstream::read( uint32_t& v ) { my->ss >> v; return *this; }
88 istream& stringstream::read( int16_t& v ) { my->ss >> v; return *this; }
89 istream& stringstream::read( uint16_t& v ) { my->ss >> v; return *this; }
90 istream& stringstream::read( int8_t& v ) { my->ss >> v; return *this; }
91 istream& stringstream::read( uint8_t& v ) { my->ss >> v; return *this; }
92 istream& stringstream::read( float& v ) { my->ss >> v; return *this; }
93 istream& stringstream::read( double& v ) { my->ss >> v; return *this; }
94 istream& stringstream::read( bool& v ) { my->ss >> v; return *this; }
95 istream& stringstream::read( char& v ) { my->ss >> v; return *this; }
96 istream& stringstream::read( fc::string& v ) { my->ss >> *reinterpret_cast<std::string*>(&v); return *this; }
97
98 ostream& stringstream::write( const fc::string& s) {
99 my->ss.write( s.c_str(), s.size() );
100 return *this;
101 }
102 */
103
104 char stringstream::peek()
105 {
106 char c = my->ss.peek();
107 if( my->ss.eof() )
108 {
109 FC_THROW_EXCEPTION( eof_exception, "stringstream" );
110 }
111 return c;
112 }
113}
114
115
const mie::Vuint & r
Definition bn.cpp:28
impl(const fc::string &s)
Definition sstream.cpp:14
impl(fc::string &s)
Definition sstream.cpp:10
std::stringstream ss
Definition sstream.cpp:20
Defines exception's used by fc.
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
namespace sysio::chain
Definition authority.cpp:3
std::string string
Definition string.hpp:10
char * s
size_t len
uint8_t buf[2048]