xtd 0.2.0
text_reader.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../array.hpp"
6#include "../core_export.hpp"
7#include "../object.hpp"
8#include "../span.hpp"
9#include "../string.hpp"
10#include <cstdio>
11#include <istream>
12#include <string>
13
15namespace xtd {
17 namespace io {
19 class null_text_reader;
22
39 public:
41
48 static null_text_reader& null() noexcept;
50
52
55 virtual void close();
56
59 virtual int32 peek() const;
60
63 virtual int32 read();
64
68 virtual size_t read(xtd::span<char>& buffer);
69
75 virtual size_t read(xtd::array<char>& buffer, size_t index, size_t count);
76
80 virtual size_t read_block(xtd::span<char>& buffer);
81
87 virtual size_t read_block(xtd::array<char>& buffer, size_t index, size_t count);
88
91 virtual xtd::string read_line();
92
96 virtual xtd::string read_to_end();
98
100
107
108 protected:
110
113 text_reader() = default;
115 };
116
129 public:
131
133 int32 read() override;
135 };
136
148 class core_export_ synchronized_text_reader : public xtd::io::text_reader {
149 public:
151
153 int32 read() override;
155
156 private:
157 friend class text_reader;
158 explicit synchronized_text_reader(xtd::io::text_reader& reader);
159 synchronized_text_reader() = delete;
160 xtd::io::text_reader& reader_;
161 };
162 }
163}
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents a null text reader.
Definition text_reader.hpp:128
int32 read() override
Reads the next character from the input stream and advances the character position by one character.
Represents a synchronized text reader.
Definition text_reader.hpp:148
int32 read() override
Reads the next character from the input stream and advances the character position by one character.
Represents a reader that can read a sequential series of characters.
Definition text_reader.hpp:38
virtual int32 read()
Reads the next character from the input stream and advances the character position by one character.
virtual xtd::string read_to_end()
Reads all characters from the current position to the end of the text_reader and returns them as one ...
virtual void close()
Closes the xtd::io::text_reader and releases any system resources associated with the text_reader.
virtual int32 peek() const
Reads the next character without changing the state of the reader or the character source....
virtual size_t read_block(xtd::span< char > &buffer)
Reads the characters from the current stream and writes the data to a buffer.
virtual xtd::string read_line()
Reads a line of characters from the current stream and returns the data as a string.
static null_text_reader & null() noexcept
Provides a text_reader with no data to read from.
text_reader()=default
Initializes a new instance of the xtd::io::text_reader class.
static synchronized_text_reader synchronised(text_reader &reader) noexcept
Creates a thread-safe (synchronized) wrapper around the specified text_reader object.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents a non-owning view over a contiguous sequence of objects.
Definition span.hpp:58
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::object class.
Contains xtd::span class.
Contains xtd::string alias.