7#include "system/iformatprovider.h"
8#include "system/exceptions.h"
9#include "system/reflection.h"
10#include "system/globalization/culture_info.h"
11#include "system/io/text_writer.h"
12#include "system/text/string_builder.h"
13#include "system/text/unicode_encoding.h"
15namespace System {
namespace IO {
31 throw ArgumentNullException(u
"StringBuilder");
38 :
StringWriter(sb, Globalization::CultureInfo::get_CurrentCulture()) {}
52 if (m_Encoding ==
nullptr)
53 m_Encoding = MakeObject<Text::UnicodeEncoding>(
false,
false);
65 virtual void Write(char_t value)
override {
74 if (buffer ==
nullptr)
75 throw ArgumentNullException(u
"buffer");
77 throw ArgumentOutOfRangeException(u
"index");
79 throw ArgumentOutOfRangeException(u
"count");
80 if (buffer->get_Length() - index < count)
81 throw ArgumentException(u
"insufficient buffer length");
83 _sb->Append(buffer, index, count);
89 if (!value.
IsNull()) _sb->Append(value);
Implements a TextWriter that writes information to a string. Objects of this class should only be all...
Definition: string_writer.h:21
StringWriter(const IFormatProviderPtr &formatProvider)
Constructs a new instance of StringWriter using the specified IFormatProvider.
Definition: string_writer.h:42
virtual void Write(char_t value) override
Writes the specified character to the stream.
Definition: string_writer.h:65
StringWriter(const System::SharedPtr< Text::StringBuilder > &sb, const IFormatProviderPtr &formatProvider)
Constructs a new instance of StringWriter using the specified StringBuilder and IFormatProvider.
Definition: string_writer.h:28
virtual SharedPtr< Text::Encoding > get_Encoding() override
Returns the currently used encoding.
Definition: string_writer.h:50
virtual SharedPtr< Text::StringBuilder > GetStringBuilder()
Returns the currently used StringBuilder.
Definition: string_writer.h:58
virtual void Write(const String &value) override
Writes the specified string to the stream.
Definition: string_writer.h:88
StringWriter(const System::SharedPtr< Text::StringBuilder > &sb)
Constructs a new instance of StringWriter using the specified StringBuilder and IFormatProvider from ...
Definition: string_writer.h:37
StringWriter()
Constructs a new instance of StringWriter using IFormatProvider from the current culture.
Definition: string_writer.h:46
virtual String ToString() const override
Returns the underlying string.
Definition: string_writer.h:93
virtual void Write(const ArrayPtr< char_t > &buffer, int32_t index, int32_t count) override
Writes the specified subrange of characters from the specified character array to the stream.
Definition: string_writer.h:73
A base class for classes that represent writers that writes sequences of characters to different dest...
Definition: text_writer.h:21
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
String ToString() const
Wrapper for handling String class in contexts where ToString() is being called on value type objects.
Definition: string.h:494
bool IsNull() const
Checks if string is considered null. String is null and only if it is constructed via String() constr...
Definition: string.h:280
Definition: db_command.h:9
std::enable_if<!IsSmartPtr< T >::value, SmartPtr< T > >::type MakeObject(Args &&... args)
Creates object on heap and returns shared pointer to it.
Definition: smart_ptr.h:1506