Base Framework
Public Member Functions | Static Public Attributes | List of all members
StringOutputStream Class Reference

String output stream. More...

#include <base/string/StringOutputStream.h>

Inherits StringOutputStreamImpl, and FormatOutputStream.

Inherited by ObjectModel::NiceFormat.

Public Member Functions

 StringOutputStream ()
 
 StringOutputStream (MemorySize capacity)
 
void ensureCapacity (MemorySize capacity)
 
void flush ()
 
const StringgetString () const
 
String toString ()
 
void restart ()
 
 operator const String & () const
 
 ~StringOutputStream ()
 
- Public Member Functions inherited from FormatOutputStream
 FormatOutputStream (OutputStream &out, unsigned int size=DEFAULT_BUFFER_SIZE)
 
 FormatOutputStream (const FormatOutputStream &copy)=delete
 
void reset () noexcept
 
bool isANSITerminal ()
 
FormatOutputStreamsetRadixPosition (unsigned int position) noexcept
 
FormatOutputStreamsetJustification (Symbols::Justification justification) noexcept
 
FormatOutputStreamsetWidth (unsigned int width) noexcept
 
FormatOutputStreamsetPrecision (unsigned int precision) noexcept
 
FormatOutputStreamsetDateFormat (const String &format)
 
void setLocale (const Locale &locale) noexcept
 
unsigned int getFlags () const noexcept
 
void setFlags (unsigned int flags) noexcept
 
Symbols::Base getBase () const noexcept
 
Symbols::Base getRealBase () const noexcept
 
unsigned int getWidth () const noexcept
 
unsigned int getPrecision () const noexcept
 
FormatOutputStreamoperator<< (Action action)
 
FormatOutputStreamoperator<< (Indent indent)
 
FormatOutputStreamoperator<< (TabIndent indent)
 
void indent (unsigned int size, bool useTab=false)
 
void addCharacterField (const char *buffer, MemorySize size)
 
void addCharacterField (const wchar *buffer, MemorySize size)
 
void addCharacterField (const char16_t *buffer, MemorySize size)
 
void addCharacterField (const char32_t *buffer, MemorySize size)
 
void addIntegerField (const char *buffer, MemorySize size, bool isSigned)
 
void addDateField (const Date &date)
 
void writeFloatingPointType (unsigned int significant, unsigned int *mantissa, unsigned int mantissaSize, int base2Exponent, unsigned int valueFlags)
 
FormatOutputStreamgetContext (Context &context) noexcept
 
FormatOutputStreamsetContext (const Context &context) noexcept
 
FormatOutputStreamoperator<< (const SourceCodeLocation &location)
 
template<MemorySize SIZE>
FormatOutputStreamoperator<< (const char(&literal)[SIZE])
 
FormatOutputStreamoperator<< (bool value)
 
FormatOutputStreamoperator<< (char value)
 
FormatOutputStreamoperator<< (wchar value)
 
FormatOutputStreamoperator<< (short int value)
 
FormatOutputStreamoperator<< (unsigned short int value)
 
FormatOutputStreamoperator<< (int value)
 
FormatOutputStreamoperator<< (unsigned int value)
 
FormatOutputStreamoperator<< (long value)
 
FormatOutputStreamoperator<< (unsigned long value)
 
FormatOutputStreamoperator<< (long long value)
 
FormatOutputStreamoperator<< (unsigned long long value)
 
FormatOutputStreamoperator<< (int128 value)
 
FormatOutputStreamoperator<< (uint128 value)
 
FormatOutputStreamoperator<< (float value)
 
FormatOutputStreamoperator<< (double value)
 
FormatOutputStreamoperator<< (long double value)
 
FormatOutputStreamoperator<< (float128 value)
 
FormatOutputStreamoperator<< (const NativeString &value)
 
FormatOutputStreamoperator<< (const NativeWideString &value)
 
FormatOutputStreamoperator<< (const char *value)
 
FormatOutputStreamoperator<< (const wchar *value)
 
FormatOutputStreamoperator<< (const char16_t *value)
 
FormatOutputStreamoperator<< (const char32_t *value)
 
FormatOutputStreamoperator<< (const MemorySpan &span)
 
FormatOutputStreamoperator<< (const void *value)
 
template<class TYPE >
FormatOutputStreamoperator<< (Reference< TYPE > value)
 
FormatOutputStreamoperator<< (const Literal &literal)
 
FormatOutputStreamoperator<< (const WideLiteral &literal)
 
FormatOutputStreamoperator<< (const Exception &e)
 
 ~FormatOutputStream ()
 
- Public Member Functions inherited from BufferedOutputStream
 BufferedOutputStream (OutputStream &out, unsigned int size=DEFAULT_BUFFER_SIZE)
 
unsigned int write (const uint8 *buffer, unsigned int size, bool nonblocking=false)
 
void unfoldValue (char value, unsigned int count)
 
 ~BufferedOutputStream ()
 
- Public Member Functions inherited from FilterOutputStream
 FilterOutputStream (OutputStream &out)
 
OutputStreamgetOutputStream () noexcept
 
void close ()
 
unsigned int write (const uint8 *buffer, unsigned int size, bool nonblocking=false)
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Static Public Attributes

static const MemorySize DEFAULT_CAPACITY = 1024
 
- Static Public Attributes inherited from FormatOutputStream
static const unsigned int DEFAULT_FLAGS
 
static const Symbols::EndOfLine DEFAULT_EOL = Symbols::UNIXEOL
 
static const Symbols::Base DEFAULT_INTEGER_BASE = Symbols::DECIMAL
 
static const Symbols::Base DEFAULT_REAL_BASE = Symbols::DECIMAL
 
static const Symbols::RealStyle DEFAULT_REAL_STYLE = Symbols::FIXED
 
static const int DEFAULT_RADIX_POSITION = 0
 
static const Symbols::MajorDateFormat DEFAULT_MAJOR_DATE_FORMAT
 
static const Symbols::NamedDateFormat DEFAULT_NAMED_DATE_FORMAT
 
static const Symbols::Justification DEFAULT_JUSTIFICATION
 
static const int DEFAULT_WIDTH = 0
 
static const int DEFAULT_PRECISION = 6
 
static constexpr unsigned int MAXIMUM_WIDTH = 128
 
static constexpr unsigned int MAXIMUM_PRECISION = 64
 
static constexpr unsigned int MAXIMUM_SIZE = 256
 
- Static Public Attributes inherited from BufferedOutputStream
static const unsigned int DEFAULT_BUFFER_SIZE = 4096
 
static const unsigned int MINIMUM_BUFFER_SIZE = 1024
 

Additional Inherited Members

- Public Types inherited from FormatOutputStream
typedef SpinLock Guard
 
- Protected Types inherited from FormatOutputStream
typedef SpinLock Guard
 
- Protected Member Functions inherited from FormatOutputStream
 FormatOutputStream (OutputStream &out, unsigned int size=DEFAULT_BUFFER_SIZE)
 
 FormatOutputStream (const FormatOutputStream &copy)=delete
 
void reset () noexcept
 
bool isANSITerminal ()
 
FormatOutputStreamsetRadixPosition (unsigned int position) noexcept
 
FormatOutputStreamsetJustification (Symbols::Justification justification) noexcept
 
FormatOutputStreamsetWidth (unsigned int width) noexcept
 
FormatOutputStreamsetPrecision (unsigned int precision) noexcept
 
FormatOutputStreamsetDateFormat (const String &format)
 
void setLocale (const Locale &locale) noexcept
 
unsigned int getFlags () const noexcept
 
void setFlags (unsigned int flags) noexcept
 
Symbols::Base getBase () const noexcept
 
Symbols::Base getRealBase () const noexcept
 
unsigned int getWidth () const noexcept
 
unsigned int getPrecision () const noexcept
 
FormatOutputStreamoperator<< (Action action)
 
FormatOutputStreamoperator<< (Indent indent)
 
FormatOutputStreamoperator<< (TabIndent indent)
 
void indent (unsigned int size, bool useTab=false)
 
void addCharacterField (const char *buffer, MemorySize size)
 
void addCharacterField (const wchar *buffer, MemorySize size)
 
void addCharacterField (const char16_t *buffer, MemorySize size)
 
void addCharacterField (const char32_t *buffer, MemorySize size)
 
void addIntegerField (const char *buffer, MemorySize size, bool isSigned)
 
void addDateField (const Date &date)
 
void writeFloatingPointType (unsigned int significant, unsigned int *mantissa, unsigned int mantissaSize, int base2Exponent, unsigned int valueFlags)
 
FormatOutputStreamgetContext (Context &context) noexcept
 
FormatOutputStreamsetContext (const Context &context) noexcept
 
FormatOutputStreamoperator<< (const SourceCodeLocation &location)
 
template<MemorySize SIZE>
FormatOutputStreamoperator<< (const char(&literal)[SIZE])
 
FormatOutputStreamoperator<< (bool value)
 
FormatOutputStreamoperator<< (char value)
 
FormatOutputStreamoperator<< (wchar value)
 
FormatOutputStreamoperator<< (short int value)
 
FormatOutputStreamoperator<< (unsigned short int value)
 
FormatOutputStreamoperator<< (int value)
 
FormatOutputStreamoperator<< (unsigned int value)
 
FormatOutputStreamoperator<< (long value)
 
FormatOutputStreamoperator<< (unsigned long value)
 
FormatOutputStreamoperator<< (long long value)
 
FormatOutputStreamoperator<< (unsigned long long value)
 
FormatOutputStreamoperator<< (int128 value)
 
FormatOutputStreamoperator<< (uint128 value)
 
FormatOutputStreamoperator<< (float value)
 
FormatOutputStreamoperator<< (double value)
 
FormatOutputStreamoperator<< (long double value)
 
FormatOutputStreamoperator<< (float128 value)
 
FormatOutputStreamoperator<< (const NativeString &value)
 
FormatOutputStreamoperator<< (const NativeWideString &value)
 
FormatOutputStreamoperator<< (const char *value)
 
FormatOutputStreamoperator<< (const wchar *value)
 
FormatOutputStreamoperator<< (const char16_t *value)
 
FormatOutputStreamoperator<< (const char32_t *value)
 
FormatOutputStreamoperator<< (const MemorySpan &span)
 
FormatOutputStreamoperator<< (const void *value)
 
template<class TYPE >
FormatOutputStreamoperator<< (Reference< TYPE > value)
 
FormatOutputStreamoperator<< (const Literal &literal)
 
FormatOutputStreamoperator<< (const WideLiteral &literal)
 
FormatOutputStreamoperator<< (const Exception &e)
 
 ~FormatOutputStream ()
 
- Protected Member Functions inherited from BufferedOutputStream
 BufferedOutputStream (OutputStream &out, unsigned int size=DEFAULT_BUFFER_SIZE)
 
unsigned int write (const uint8 *buffer, unsigned int size, bool nonblocking=false)
 
void unfoldValue (char value, unsigned int count)
 
 ~BufferedOutputStream ()
 
- Protected Member Functions inherited from FilterOutputStream
 FilterOutputStream (OutputStream &out)
 
OutputStreamgetOutputStream () noexcept
 
void close ()
 
unsigned int write (const uint8 *buffer, unsigned int size, bool nonblocking=false)
 
- Protected Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Protected Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Protected Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 
- Protected Attributes inherited from StringOutputStreamImpl
StringOutputStreamWrapper stream
 
- Protected Attributes inherited from FormatOutputStream
Guard guard
 
Context defaultContext
 
Context context
 
- Protected Attributes inherited from BufferedOutputStream
Allocator< uint8 > buffer
 
unsigned int writeHead = 0
 
unsigned int readHead = 0
 
- Protected Attributes inherited from FilterOutputStream
OutputStreamout
 
- Static Protected Attributes inherited from FormatOutputStream
static const Context DEFAULT_CONTEXT
 
static const unsigned int DEFAULT_FLAGS
 
static const Symbols::EndOfLine DEFAULT_EOL = Symbols::UNIXEOL
 
static const Symbols::Base DEFAULT_INTEGER_BASE = Symbols::DECIMAL
 
static const Symbols::Base DEFAULT_REAL_BASE = Symbols::DECIMAL
 
static const Symbols::RealStyle DEFAULT_REAL_STYLE = Symbols::FIXED
 
static const int DEFAULT_RADIX_POSITION = 0
 
static const Symbols::MajorDateFormat DEFAULT_MAJOR_DATE_FORMAT
 
static const Symbols::NamedDateFormat DEFAULT_NAMED_DATE_FORMAT
 
static const Symbols::Justification DEFAULT_JUSTIFICATION
 
static const int DEFAULT_WIDTH = 0
 
static const int DEFAULT_PRECISION = 6
 
static constexpr unsigned int MAXIMUM_WIDTH = 128
 
static constexpr unsigned int MAXIMUM_PRECISION = 64
 
static constexpr unsigned int MAXIMUM_SIZE = 256
 
- Static Protected Attributes inherited from BufferedOutputStream
static const unsigned int DEFAULT_BUFFER_SIZE = 4096
 
static const unsigned int MINIMUM_BUFFER_SIZE = 1024
 

Detailed Description

String output stream.

A string output stream is a format output stream that directs the stream data into a string.

Version
1.0
Examples
testsuite/du.cpp, testsuite/ftp.cpp, testsuite/http.cpp, testsuite/ls.cpp, testsuite/ping.cpp, and testsuite/sax.cpp.

Constructor & Destructor Documentation

◆ StringOutputStream() [1/2]

StringOutputStream::StringOutputStream ( )

Initializes string output stream.

◆ StringOutputStream() [2/2]

StringOutputStream::StringOutputStream ( MemorySize  capacity)
explicit

Initializes string output stream.

Parameters
capacitySpecifies the initial capacity.

◆ ~StringOutputStream()

StringOutputStream::~StringOutputStream ( )

Destroy stream object.

Member Function Documentation

◆ ensureCapacity()

void StringOutputStream::ensureCapacity ( MemorySize  capacity)

Reserves capacity in the internal buffer.

◆ flush()

void StringOutputStream::flush ( )
virtual

Flushes stream.

Reimplemented from BufferedOutputStream.

◆ getString()

const String& StringOutputStream::getString ( ) const

Returns the string associated with the stream. Same as toString() but does NOT restart stream.

Examples
testsuite/du.cpp, testsuite/ftp.cpp, testsuite/http.cpp, testsuite/ping.cpp, and testsuite/sax.cpp.

◆ operator const String &()

StringOutputStream::operator const String & ( ) const
inline

Returns the string associated with the stream. Same as toString() but does NOT restart stream.

◆ restart()

void StringOutputStream::restart ( )

Restarts the stream.

◆ toString()

String StringOutputStream::toString ( )
virtual

Returns the string associated with the stream and restarts the stream.

Reimplemented from FormatOutputStream.

Member Data Documentation

◆ DEFAULT_CAPACITY

const MemorySize StringOutputStream::DEFAULT_CAPACITY = 1024
static

Specifies the default capacity.