xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
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 
29  class core_export_ text_reader : public object {
30  public:
36  static null_text_reader& null() noexcept;
37 
39  virtual void close();
40 
43  virtual int32_t peek() const;
44 
47  virtual int32_t read();
48 
54  virtual size_t read(std::vector<char>& buffer, size_t index, size_t count);
55 
61  virtual size_t read_block(std::vector<char>& buffer, size_t index, size_t count);
62 
65  virtual xtd::ustring read_line();
66 
70  virtual xtd::ustring read_to_end();
71 
75  static synchronized_text_reader synchronised(text_reader& reader) noexcept;
76 
77  protected:
79  text_reader() = default;
80  };
81 
86  class null_text_reader : public text_reader {
87  public:
88  int32_t read() override;
89  };
90 
96  public:
97  int32_t read() override;
98 
99  private:
100  friend class text_reader;
102  synchronized_text_reader() = delete;
103  xtd::io::text_reader& reader_;
104  std::mutex mutex_;
105  };
106  }
107 }
Represents a synchronized text reader.
Definition: text_reader.h:95
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:48
std::nullptr_t null
Represents a null pointer value.
Represents a null text reader.
Definition: text_reader.h:86
Represents a reader that can read a sequential series of characters.
Definition: text_reader.h:29
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
Read access to the file. Data can be read from the file. Combine with Write for read/write access...