BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface 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 }
istream & read(char *buf, size_t len)
Definition: iostream.cpp:274
fc::istream & getline(fc::istream &, std::string &, char delim= '\n')
Definition: iostream.cpp:78
auto operator<<(U &u, const fwd< T, S, A > &f) -> typename detail::insert_op< U, T >::type
Definition: fwd_impl.hpp:50
void put(char c)
Definition: iostream.hpp:50
auto operator>>(U &u, fwd< T, S, A > &f) -> typename detail::extract_op< U, T >::type
Definition: fwd_impl.hpp:53
Definition: api.hpp:15
size_t write(AsyncWriteStream &s, const ConstBufferSequence &buf)
wraps boost::asio::async_write
Definition: asio.hpp:181
virtual ~istream()
Definition: iostream.hpp:14
ostream & write(const char *buf, size_t len)
Definition: iostream.cpp:290
virtual size_t readsome(char *buf, size_t len)=0
virtual ~ostream()
Definition: iostream.hpp:44
std::shared_ptr< istream > istream_ptr
Definition: iostream.hpp:35
std::shared_ptr< ostream > ostream_ptr
Definition: iostream.hpp:59