xtd 0.2.0
Loading...
Searching...
No Matches
text_writer.h
Go to the documentation of this file.
1
4#pragma once
5#include "../core_export.h"
6#include "../object.h"
7#include "../ustring.h"
8#include <cstdio>
9#include <istream>
10#include <string>
11
13namespace xtd {
15 namespace io {
17 class null_text_writer;
18 class synchronized_text_writer;
20
35 public:
37
42 static null_text_writer& null() noexcept;
44
46
49 const xtd::ustring& new_line() const noexcept;
51 void new_line(const xtd::ustring& new_line) noexcept;
53
55
58 virtual void close();
59
62 virtual void flush();
63
67 virtual void write(const xtd::ustring& value);
68
72 void write(bool value);
73
77 void write(double value);
78
82 void write(float value);
83
87 void write(sbyte value);
88
92 void write(int16 value);
93
97 void write(int32 value);
98
102 void write(int64 value);
103
107 void write(xtd::byte value);
108
112 void write(uint16 value);
113
117 void write(uint32 value);
118
122 void write(uint64 value);
123
128 template<typename value_t>
129 void write(value_t value) {write(xtd::ustring::format("{}", value));}
130
135 template<typename ... args_t>
136 void write(const xtd::ustring& fmt, args_t&& ... args) noexcept {write(xtd::ustring::format(fmt, std::forward<args_t>(args)...));}
137
141
145 void write_line(const xtd::ustring& value);
146
150 void write_line(bool value);
151
155 void write_line(double value);
156
160 void write_line(float value);
161
165 void write_line(sbyte value);
166
170 void write_line(int16 value);
171
175 void write_line(int32 value);
176
180 void write_line(int64 value);
181
186
190 void write_line(uint16 value);
191
195 void write_line(uint32 value);
196
200 void write_line(uint64 value);
201
206 template<typename value_t>
207 void write_line(value_t value) {write_line(xtd::ustring::format("{}", value));}
208
213 template<typename ... args_t>
214 void write_line(const xtd::ustring& fmt, args_t&& ... args) noexcept {write_line(xtd::ustring::format(fmt, std::forward<args_t>(args)...));}
216
218
225
226 protected:
228
231 text_writer() = default;
233
234 private:
235 xtd::ustring new_line_ = "\n";
236 };
237
250 public:
251 void write(const xtd::ustring&) override;
252 };
253
266 public:
267 void write(const xtd::ustring& value) override ;
268
269 private:
270 friend class text_writer;
272 synchronized_text_writer() = delete;
273 xtd::io::text_writer& writer_;
274 };
275 }
276}
Represents a null text writer.
Definition text_writer.h:249
void write(const xtd::ustring &) override
Writes the specified string value to the text stream.
Represents a synchronized text writer.
Definition text_writer.h:265
void write(const xtd::ustring &value) override
Writes the specified string value to the text stream.
Represents a writer that can write a sequential series of characters.
Definition text_writer.h:34
void write(value_t value)
Writes the specified value_t value to the text stream.
Definition text_writer.h:129
void write_line(int16 value)
Writes the specified int16 value and new line to the text stream.
void write_line(uint64 value)
Writes the specified uint64 value and new line to the text stream.
void write_line(double value)
Writes the specified double value and new line to the text stream.
void write_line(int32 value)
Writes the specified int32 value and new line to the text stream.
void write_line(const xtd::ustring &fmt, args_t &&... args) noexcept
Writes the specified arguments with specified format to the text stream.
Definition text_writer.h:214
void write_line(const xtd::ustring &value)
Writes the specified string value and new line to the text stream.
void write_line(xtd::byte value)
Writes the specified xtd::byte value and new line to the text stream.
static null_text_writer & null() noexcept
Provides a text_writer with no backing store that can be written to, but not read from.
void write_line(sbyte value)
Writes the specified sbyte value and new line to the text stream.
void write_line(uint32 value)
Writes the specified uint32 value and new line to the text stream.
text_writer()=default
Initializes a new instance of the xtd::io::text_writer class.
void write_line(value_t value)
Writes the specified value_t value and new line to the text stream.
Definition text_writer.h:207
void write(const xtd::ustring &fmt, args_t &&... args) noexcept
Writes the specified arguments with specified format to the text stream.
Definition text_writer.h:136
void write_line(float value)
Writes the specified float value and new line to the text stream.
static synchronized_text_writer synchronised(text_writer &writer) noexcept
Creates a thread-safe (synchronized) wrapper around the specified text_writer object.
void write_line(bool value)
Writes the specified bool value and new line to the text stream.
void write_line()
Writes new line to the text stream.
void write_line(int64 value)
Writes the specified int64 value and new line to the text stream.
void write_line(uint16 value)
Writes the specified uint16 value and new line to the text stream.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1131
#define core_export_
Define shared library export.
Definition core_export.h:13
int_least16_t int16
Represents a 16-bit signed integer.
Definition types.h:120
int_least8_t sbyte
Represents a 8-bit signed integer.
Definition types.h:175
int_least64_t int64
Represents a 64-bit signed integer.
Definition types.h:142
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition types.h:230
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
uint_least64_t uint64
Represents a 64-bit unsigned integer.
Definition types.h:252
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition types.h:241
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition types.h:41
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10