xtd 0.2.0
text_reader.h
Go to the documentation of this file.
1 #pragma once
5 #include "../core_export.h"
6 #include "../object.h"
7 #include "../ustring.h"
8 #include <cstdio>
9 #include <istream>
10 #include <string>
11 
13 namespace xtd {
15  namespace io {
17  class null_text_reader;
18  class synchronized_text_reader;
20 
34  class core_export_ text_reader : public xtd::object {
35  public:
37 
44  static null_text_reader& null() noexcept;
46 
48 
51  virtual void close();
52 
55  virtual int32 peek() const;
56 
59  virtual int32 read();
60 
66  virtual size_t read(std::vector<char>& buffer, size_t index, size_t count);
67 
73  virtual size_t read_block(std::vector<char>& buffer, size_t index, size_t count);
74 
77  virtual xtd::ustring read_line();
78 
82  virtual xtd::ustring read_to_end();
83 
87  static synchronized_text_reader synchronised(text_reader& reader) noexcept;
89 
90  protected:
92 
95  text_reader() = default;
97  };
98 
110  class core_export_ null_text_reader : public xtd::io::text_reader {
111  public:
113 
115  int32 read() override;
117  };
118 
130  class core_export_ synchronized_text_reader : public xtd::io::text_reader {
131  public:
133 
135  int32 read() override;
137 
138  private:
139  friend class text_reader;
141  synchronized_text_reader() = delete;
142  xtd::io::text_reader& reader_;
143  };
144  }
145 }
Represents a synchronized text reader.
Definition: text_reader.h:130
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
std::nullptr_t null
Represents a null pointer value.
Represents a null text reader.
Definition: text_reader.h:110
Represents a reader that can read a sequential series of characters.
Definition: text_reader.h:34
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Read access to the file. Data can be read from the file. Combine with Write for read/write access...