xtd - Reference Guide 0.2.0
text_reader.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <cstdio>
7 #include <istream>
8 #include <mutex>
9 #include <string>
10 #include "../core_export.h"
11 #include "../object.h"
12 #include "../ustring.h"
13 
15 namespace xtd {
17  namespace io {
19  class null_text_reader;
20  class synchronized_text_reader;
22 
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_t peek() const;
56 
59  virtual int32_t 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 
109  class core_export_ null_text_reader : public xtd::io::text_reader {
110  public:
112 
114  int32_t read() override;
116  };
117 
129  class core_export_ synchronized_text_reader : public xtd::io::text_reader {
130  public:
132 
134  int32_t read() override;
136 
137  private:
138  friend class text_reader;
140  synchronized_text_reader() = delete;
141  xtd::io::text_reader& reader_;
142  std::mutex mutex_;
143  };
144  }
145 }
Represents a synchronized text reader.
Definition: text_reader.h:129
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:50
std::nullptr_t null
Represents a null pointer value.
Definition: text_reader.h:109
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:30
Read access to the file. Data can be read from the file. Combine with Write for read/write access...