BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
iostream.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 #include <string>
4 
5 namespace fc {
6 
11  class istream
12  {
13  public:
14  virtual ~istream(){};
15 
22  virtual size_t readsome( char* buf, size_t len ) = 0;
23  virtual size_t readsome( const std::shared_ptr<char>& buf, size_t len, size_t offset ) = 0;
24 
30  istream& read( char* buf, size_t len );
31  istream& read( const std::shared_ptr<char>& buf, size_t len, size_t offset = 0 );
32  virtual char get();
33  void get( char& c ) { c = get(); }
34  };
35  typedef std::shared_ptr<istream> istream_ptr;
36 
41  class ostream
42  {
43  public:
44  virtual ~ostream(){};
45  virtual size_t writesome( const char* buf, size_t len ) = 0;
46  virtual size_t writesome( const std::shared_ptr<const char>& buf, size_t len, size_t offset ) = 0;
47  virtual void close() = 0;
48  virtual void flush() = 0;
49 
50  void put( char c ) { write(&c,1); }
51 
55  ostream& write( const char* buf, size_t len );
56  ostream& write( const std::shared_ptr<const char>& buf, size_t len, size_t offset = 0 );
57  };
58 
59  typedef std::shared_ptr<ostream> ostream_ptr;
60 
61  class iostream : public virtual ostream, public virtual istream {};
62 
63  fc::istream& getline( fc::istream&, std::string&, char delim = '\n' );
64 
65  template<size_t N>
66  ostream& operator<<( ostream& o, char (&array)[N] )
67  {
68  return o.write( array, N );
69  }
70 
71  ostream& operator<<( ostream& o, char );
72  ostream& operator<<( ostream& o, const char* v );
73  ostream& operator<<( ostream& o, const std::string& v );
74  ostream& operator<<( ostream& o, const std::string& v );
75  ostream& operator<<( ostream& o, const double& v );
76  ostream& operator<<( ostream& o, const float& v );
77  ostream& operator<<( ostream& o, const int64_t& v );
78  ostream& operator<<( ostream& o, const uint64_t& v );
79  ostream& operator<<( ostream& o, const int32_t& v );
80  ostream& operator<<( ostream& o, const uint32_t& v );
81  ostream& operator<<( ostream& o, const int16_t& v );
82  ostream& operator<<( ostream& o, const uint16_t& v );
83  ostream& operator<<( ostream& o, const int8_t& v );
84  ostream& operator<<( ostream& o, const uint8_t& v );
85 #ifndef _MSC_VER
86  ostream& operator<<( ostream& o, const size_t& v );
87 #endif
88 
89  istream& operator>>( istream& o, std::string& v );
90  istream& operator>>( istream& o, std::string& v );
91  istream& operator>>( istream& o, char& v );
92  istream& operator>>( istream& o, double& v );
93  istream& operator>>( istream& o, float& v );
94  istream& operator>>( istream& o, int64_t& v );
95  istream& operator>>( istream& o, uint64_t& v );
96  istream& operator>>( istream& o, int32_t& v );
97  istream& operator>>( istream& o, uint32_t& v );
98  istream& operator>>( istream& o, int16_t& v );
99  istream& operator>>( istream& o, uint16_t& v );
100  istream& operator>>( istream& o, int8_t& v );
101  istream& operator>>( istream& o, uint8_t& v );
102 }
fc::ostream::close
virtual void close()=0
fc::operator>>
auto operator>>(U &u, fwd< T, S, A > &f) -> typename detail::extract_op< U, T >::type
Definition: fwd_impl.hpp:53
fc
Definition: api.hpp:15
fc::istream_ptr
std::shared_ptr< istream > istream_ptr
Definition: iostream.hpp:35
fc::istream::get
virtual char get()
Definition: iostream.cpp:267
fc::ostream::put
void put(char c)
Definition: iostream.hpp:50
fc::ostream::~ostream
virtual ~ostream()
Definition: iostream.hpp:44
fc::operator<<
auto operator<<(U &u, const fwd< T, S, A > &f) -> typename detail::insert_op< U, T >::type
Definition: fwd_impl.hpp:50
fc::istream::read
istream & read(char *buf, size_t len)
Definition: iostream.cpp:274
fc::istream::~istream
virtual ~istream()
Definition: iostream.hpp:14
fc::ostream
Definition: iostream.hpp:41
fc::istream
Definition: iostream.hpp:11
fc::istream::readsome
virtual size_t readsome(char *buf, size_t len)=0
fc::ostream::writesome
virtual size_t writesome(const char *buf, size_t len)=0
fc::istream::get
void get(char &c)
Definition: iostream.hpp:33
fc::ostream::flush
virtual void flush()=0
fc::ostream::write
ostream & write(const char *buf, size_t len)
Definition: iostream.cpp:290
fc::iostream
Definition: iostream.hpp:61
fc::getline
fc::istream & getline(fc::istream &, std::string &, char delim='\n')
Definition: iostream.cpp:78
fc::ostream_ptr
std::shared_ptr< ostream > ostream_ptr
Definition: iostream.hpp:59