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;
18 class synchronized_text_writer;
20
37 public:
39
44 static null_text_writer& null() noexcept;
46
48
51 const xtd::string& new_line() const noexcept;
53 void new_line(const xtd::string& new_line) noexcept;
55
57
60 virtual void close();
61
64 virtual void flush();
65
69 virtual void write(const xtd::string& value);
70
74 void write(bool value);
75
79 void write(double value);
80
84 void write(float value);
85
89 void write(sbyte value);
90
94 void write(int16 value);
95
99 void write(int32 value);
100
104 void write(int64 value);
105
109 void write(xtd::byte value);
110
114 void write(uint16 value);
115
119 void write(uint32 value);
120
124 void write(uint64 value);
125
130 template<typename value_t>
131 void write(value_t value) {write(xtd::string::format("{}", value));}
132
137 template<typename ... args_t>
138 void write(const xtd::string& fmt, args_t&& ... args) noexcept {write(xtd::string::format(fmt, std::forward<args_t>(args)...));}
139
143
147 void write_line(const xtd::string& value);
148
152 void write_line(bool value);
153
157 void write_line(double value);
158
162 void write_line(float value);
163
167 void write_line(sbyte value);
168
172 void write_line(int16 value);
173
177 void write_line(int32 value);
178
182 void write_line(int64 value);
183
188
192 void write_line(uint16 value);
193
197 void write_line(uint32 value);
198
202 void write_line(uint64 value);
203
208 template<typename value_t>
209 void write_line(value_t value) {write_line(xtd::string::format("{}", value));}
210
215 template<typename ... args_t>
216 void write_line(const xtd::string& fmt, args_t&& ... args) noexcept {write_line(xtd::string::format(fmt, std::forward<args_t>(args)...));}
218
220
227
228 protected:
230
233 text_writer() = default;
235
236 private:
237 xtd::string new_line_ = "\n";
238 };
239
252 public:
253 void write(const xtd::string&) override;
254 };
255
268 public:
269 void write(const xtd::string& value) override ;
270
271 private:
272 friend class text_writer;
274 synchronized_text_writer() = delete;
275 xtd::io::text_writer& writer_;
276 };
277 }
278}
Represents text as a sequence of character units.
Definition basic_string.hpp:79
Represents a null text writer.
Definition text_writer.hpp:251
void write(const xtd::string &) override
Writes the specified string value to the text stream.
Represents a synchronized text writer.
Definition text_writer.hpp:267
void write(const xtd::string &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.hpp:36
void write(value_t value)
Writes the specified value_t value to the text stream.
Definition text_writer.hpp:131
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(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(const xtd::string &value)
Writes the specified string 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.
void write(const xtd::string &fmt, args_t &&... args) noexcept
Writes the specified arguments with specified format to the text stream.
Definition text_writer.hpp:138
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.hpp:209
void write_line(const xtd::string &fmt, args_t &&... args) noexcept
Writes the specified arguments with specified format to the text stream.
Definition text_writer.hpp:216
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.hpp:42
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
#define core_export_
Define shared library export.
Definition core_export.hpp:13
int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10