xtd 0.2.0
Loading...
Searching...
No Matches
xtd::io::string_writer Class Reference
Inheritance diagram for xtd::io::string_writer:
xtd::io::text_writer xtd::object

Definition

Implements a xtd::io::text_writer for writing characters to a string.

Implements a xtd::io::text_writer for writing characters to a string.
Definition string_writer.hpp:27
Represents a writer that can write a sequential series of characters.
Definition text_writer.hpp:36
#define core_export_
Define shared library export.
Definition core_export.hpp:13
Inheritance
xtd::io::text_writerxtd::io::string_writer
Header
#include <xtd/io/string_writer>
Namespace
xtd::io
Library
xtd.core

Public Constructors

 string_writer ()=default
 Initializes a new instance of the stream_writer class .
 
 string_writer (const xtd::string &str)
 Initializes a new instance of the stream_writer class for the specified string.
 

Public Properties

const std::ostream & base_stream () const noexcept
 Returns the underlying stream.
 
std::ostream & base_stream () noexcept
 Returns the underlying stream.
 

Public Methods

void flush () override
 Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
 
xtd::string to_string () const noexcept override
 Returns a xtd::string that represents the current object.
 
void write (const xtd::string &value) override
 Writes the specified string value to the text stream.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::io::text_writer
const xtd::stringnew_line () const noexcept
 Gets the line terminator string used by the current text_writer.
 
void new_line (const xtd::string &new_line) noexcept
 Sets the line terminator string used by the current text_writer.
 
virtual void close ()
 Closes the xtd::io::text_reader and releases any system resources associated with the text_reader.
 
void write (bool value)
 Writes the specified bool value to the text stream.
 
void write (double value)
 Writes the specified double value to the text stream.
 
void write (float value)
 Writes the specified float value to the text stream.
 
void write (sbyte value)
 Writes the specified sbyte value to the text stream.
 
void write (int16 value)
 Writes the specified int16 value to the text stream.
 
void write (int32 value)
 Writes the specified int32 value to the text stream.
 
void write (int64 value)
 Writes the specified int64 value to the text stream.
 
void write (xtd::byte value)
 Writes the specified xtd::byte value to the text stream.
 
void write (uint16 value)
 Writes the specified uint16 value to the text stream.
 
void write (uint32 value)
 Writes the specified uint32 value to the text stream.
 
void write (uint64 value)
 Writes the specified uint64 value to the text stream.
 
template<typename value_t >
void write (value_t value)
 Writes the specified value_t value to the text stream.
 
template<typename ... args_t>
void write (const xtd::string &fmt, args_t &&... args) noexcept
 Writes the specified arguments with specified format to the text stream.
 
void write_line ()
 Writes 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 (bool value)
 Writes the specified bool 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 (float value)
 Writes the specified float value and new line to the text stream.
 
void write_line (sbyte value)
 Writes the specified sbyte value and new line to the text stream.
 
void write_line (int16 value)
 Writes the specified int16 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 (int64 value)
 Writes the specified int64 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.
 
void write_line (uint16 value)
 Writes the specified uint16 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_line (uint64 value)
 Writes the specified uint64 value and new line to the text stream.
 
template<typename value_t >
void write_line (value_t value)
 Writes the specified value_t value and new line to the text stream.
 
template<typename ... args_t>
void write_line (const xtd::string &fmt, args_t &&... args) noexcept
 Writes the specified arguments with specified format to the text stream.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Static Public Member Functions inherited from xtd::io::text_writer
static null_text_writernull () noexcept
 Provides a text_writer with no backing store that can be written to, but not read from.
 
static synchronized_text_writer synchronised (text_writer &writer) noexcept
 Creates a thread-safe (synchronized) wrapper around the specified text_writer object.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
- Protected Member Functions inherited from xtd::io::text_writer
 text_writer ()=default
 Initializes a new instance of the xtd::io::text_writer class.
 

Constructor & Destructor Documentation

◆ string_writer() [1/2]

xtd::io::string_writer::string_writer ( )
default

Initializes a new instance of the stream_writer class .

◆ string_writer() [2/2]

xtd::io::string_writer::string_writer ( const xtd::string str)
explicit

Initializes a new instance of the stream_writer class for the specified string.

Parameters
strbase string.

Member Function Documentation

◆ base_stream() [1/2]

const std::ostream & xtd::io::string_writer::base_stream ( ) const
noexcept

Returns the underlying stream.

Returns
The underlying stream.

◆ base_stream() [2/2]

std::ostream & xtd::io::string_writer::base_stream ( )
noexcept

Returns the underlying stream.

Returns
The underlying stream.

◆ flush()

void xtd::io::string_writer::flush ( )
overridevirtual

Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

Remarks
This default method does nothing, but derived classes can virtual the method to provide the appropriate functionality

Reimplemented from xtd::io::text_writer.

◆ to_string()

xtd::string xtd::io::string_writer::to_string ( ) const
overridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.
#include <xtd/xtd>
using namespace xtd;
namespace examples {
namespace object_test {
class object1 : public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
console::write_line(obj1->to_string());
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
console::write_line(obj2->to_string());
ptr<object> obj3 = new_ptr<boolean_object>();
console::write_line(obj3->to_string());
}
// This code produces the following output :
//
// examples::object_test::object1
// Tue Jan 5 23:05:00 1971
// false
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10

Reimplemented from xtd::object.

◆ write()

void xtd::io::string_writer::write ( const xtd::string value)
overridevirtual

Writes the specified string value to the text stream.

Parameters
valueThe value to write
Exceptions
io::io_exceptionAn I/O error occurs.

Reimplemented from xtd::io::text_writer.


The documentation for this class was generated from the following file: