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.
stream_reader.h
Go to the documentation of this file.
1 #pragma once
5 
6 #include <fstream>
7 #include <optional>
8 #include "text_reader.h"
9 
11 namespace xtd {
13  namespace io {
25  class core_export_ stream_reader : public xtd::io::text_reader {
26  public:
28 
33  explicit stream_reader(const xtd::ustring& path);
36  explicit stream_reader(std::istream& stream);
39  stream_reader(const stream_reader&) = delete;
40  stream_reader& operator=(const stream_reader&) = delete;
41  ~stream_reader();
43 
45 
49  std::optional<std::reference_wrapper<std::istream>> base_stream() const;
50 
53  bool end_of_stream() const;
55 
57 
60  void close() override;
61 
64  int32_t peek() const override;
65 
68  int32_t read() override;
70 
71  private:
72  std::istream* stream_ = nullptr;
73  bool delete_when_destroy_ = false;
74  };
75  }
76 }
Contains xtd::io::text_reader class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Implements a xtd::io::text_reader that reads characters from a byte stream.
Definition: stream_reader.h:25
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
Performs operations on std::basic_string instances that contain file or directory path information...
Definition: path.h:32
Represents a reader that can read a sequential series of characters.
Definition: text_reader.h:34
Read access to the file. Data can be read from the file. Combine with Write for read/write access...