xtd 0.2.0
Loading...
Searching...
No Matches
text_writer.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.hpp"
6#include "../object.hpp"
7#include "../string.hpp"
8#include <cstdio>
9#include <istream>
10#include <string>
11
13namespace xtd {
15 namespace io {
17 class null_text_writer;
20
37 public:
39
44 [[nodiscard]] static auto null() noexcept -> null_text_writer&;
46
48
51 [[nodiscard]] auto new_line() const noexcept -> const xtd::string&;
53 auto new_line(const xtd::string& new_line) noexcept -> void;
55
57
60 virtual auto close() -> void;
61
64 virtual auto flush() -> void;
65
69 virtual auto write(const xtd::string& value) -> void;
70
74 auto write(bool value) -> void;
75
79 auto write(double value) -> void;
80
84 auto write(float value) -> void;
85
89 auto write(sbyte value) -> void;
90
94 auto write(int16 value) -> void;
95
99 auto write(int32 value) -> void;
100
104 auto write(int64 value) -> void;
105
109 auto write(xtd::byte value) -> void;
110
114 auto write(uint16 value) -> void;
115
119 auto write(uint32 value) -> void;
120
124 auto write(uint64 value) -> void;
125
130 template<class value_t>
131 auto write(value_t value) -> void {write(xtd::string::format("{}", value));}
132
137 template<class ...args_t>
138 auto write(const xtd::string& fmt, args_t&& ... args) noexcept -> void {write(xtd::string::format(fmt, std::forward<args_t>(args)...));}
139
142 auto write_line() -> void;
143
147 auto write_line(const xtd::string& value) -> void;
148
152 auto write_line(bool value) -> void;
153
157 auto write_line(double value) -> void;
158
162 auto write_line(float value) -> void;
163
167 auto write_line(sbyte value) -> void;
168
172 auto write_line(int16 value) -> void;
173
177 auto write_line(int32 value) -> void;
178
182 auto write_line(int64 value) -> void;
183
187 auto write_line(xtd::byte value) -> void;
188
192 auto write_line(uint16 value) -> void;
193
197 auto write_line(uint32 value) -> void;
198
202 auto write_line(uint64 value) -> void;
203
208 template<class value_t>
209 auto write_line(value_t value) -> void {write_line(xtd::string::format("{}", value));}
210
215 template<class ...args_t>
216 auto write_line(const xtd::string& fmt, args_t&& ... args) noexcept -> void {write_line(xtd::string::format(fmt, std::forward<args_t>(args)...));}
218
220
225 [[nodiscard]] static auto synchronised(text_writer& writer) noexcept -> synchronized_text_writer;
227
228 protected:
230
233 text_writer() = default;
235
236 private:
237 xtd::string new_line_ = "\n";
238 };
239
252 public:
253 auto write(const xtd::string&) -> void override;
254 };
255
267 class core_export_ synchronized_text_writer : public xtd::io::text_writer {
268 public:
269 auto write(const xtd::string& value) -> void override ;
270
271 private:
272 friend class text_writer;
273 explicit synchronized_text_writer(xtd::io::text_writer& writer);
274 synchronized_text_writer() = delete;
275 xtd::io::text_writer& writer_;
276 };
277 }
278}
Represents a null text writer.
Definition text_writer.hpp:251
auto write(const xtd::string &) -> void override
Writes the specified string value to the text stream.
Represents a synchronized text writer.
Definition text_writer.hpp:267
auto write(const xtd::string &value) -> void override
Writes the specified string value to the text stream.
Represents a writer that can write a sequential series of characters.
Definition text_writer.hpp:36
auto write_line(int16 value) -> void
Writes the specified int16 value and new line to the text stream.
auto write(const xtd::string &fmt, args_t &&... args) noexcept -> void
Writes the specified arguments with specified format to the text stream.
Definition text_writer.hpp:138
auto write_line(uint64 value) -> void
Writes the specified uint64 value and new line to the text stream.
auto write_line(value_t value) -> void
Writes the specified value_t value and new line to the text stream.
Definition text_writer.hpp:209
auto write_line(xtd::byte value) -> void
Writes the specified xtd::byte value and new line to the text stream.
auto write_line(const xtd::string &value) -> void
Writes the specified string value and new line to the text stream.
virtual auto flush() -> void
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
auto write_line(const xtd::string &fmt, args_t &&... args) noexcept -> void
Writes the specified arguments with specified format to the text stream.
Definition text_writer.hpp:216
auto write_line(int32 value) -> void
Writes the specified int32 value and new line to the text stream.
static auto synchronised(text_writer &writer) noexcept -> synchronized_text_writer
Creates a thread-safe (synchronized) wrapper around the specified text_writer object.
auto write_line(int64 value) -> void
Writes the specified int64 value and new line to the text stream.
auto write_line(uint32 value) -> void
Writes the specified uint32 value and new line to the text stream.
virtual auto close() -> void
Closes the xtd::io::text_reader and releases any system resources associated with the text_reader.
virtual auto write(const xtd::string &value) -> void
Writes the specified string value to the text stream.
static auto null() noexcept -> null_text_writer &
Provides a text_writer with no backing store that can be written to, but not read from.
text_writer()=default
Initializes a new instance of the xtd::io::text_writer class.
auto write_line(double value) -> void
Writes the specified double value and new line to the text stream.
auto write_line(uint16 value) -> void
Writes the specified uint16 value and new line to the text stream.
auto new_line() const noexcept -> const xtd::string &
Gets the line terminator string used by the current text_writer.
auto write_line(sbyte value) -> void
Writes the specified sbyte value and new line to the text stream.
auto write_line(bool value) -> void
Writes the specified bool value and new line to the text stream.
auto write(value_t value) -> void
Writes the specified value_t value to the text stream.
Definition text_writer.hpp:131
auto write_line(float value) -> void
Writes the specified float value and new line to the text stream.
auto write_line() -> void
Writes new line to the text stream.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.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::string alias.