\hypertarget{class_qore_1_1_string_output_stream}{}\section{Qore\+:\+:String\+Output\+Stream Class Reference}
\label{class_qore_1_1_string_output_stream}\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}


This class implements the \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} interface for writing bytes to a \mbox{\hyperlink{basic_data_types_string}{String}} buffer.  




Inheritance diagram for Qore\+:\+:String\+Output\+Stream\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=222pt]{class_qore_1_1_string_output_stream__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
nothing \mbox{\hyperlink{class_qore_1_1_string_output_stream_a9e72b18135630529612c2a1ab88a9706}{close}} ()
\begin{DoxyCompactList}\small\item\em Closes the output stream and releases any resources. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_string_output_stream_a6ab01cef4c8993f15fd3f33ff673f93d}{constructor}} ()
\begin{DoxyCompactList}\small\item\em Creates the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_string_output_stream_a7350dd527d6b743ced0d9f11ba403ec1}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} encoding)
\begin{DoxyCompactList}\small\item\em Creates the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}{get\+Data}} ()
\begin{DoxyCompactList}\small\item\em Returns the data written to the stream, clearing the internal buffer. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_string_output_stream_af3adfd7eb6cf48de3d2007e9484ad032}{get\+Encoding}} ()
\begin{DoxyCompactList}\small\item\em Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. \end{DoxyCompactList}\item 
nothing \mbox{\hyperlink{class_qore_1_1_string_output_stream_ab7ac16ba46cae914c70145b8fcb3f0b4}{write}} (\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}} data)
\begin{DoxyCompactList}\small\item\em Writes bytes to the output stream. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class implements the \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}} interface for writing bytes to a \mbox{\hyperlink{basic_data_types_string}{String}} buffer. 

\begin{DoxyParagraph}{Example\+: String\+Output\+Stream basic usage}

\begin{DoxyCode}
StringOutputStream sos();
sos.write(<41>);
sos.write(<42>);
sos.write(<43>);
sos.getData();      \textcolor{comment}{# returns "ABC"}
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}
stream classes are not designed to be accessed from multiple threads; they have been implemented without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause a {\ttfamily S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} to be thrown, unless the stream is handed off to another thread using the \mbox{\hyperlink{class_qore_1_1_stream_base_a017fc847a42d5c670cb9640a94522666}{Stream\+Base\+:\+:unassign\+Thread()}} method in the thread that currently owns the stream, and the \mbox{\hyperlink{class_qore_1_1_stream_base_ab6b33cb1944c46aca8e9984ddfd65452}{Stream\+Base\+:\+:reassign\+Thread()}} method in the new thread.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{class_qore_1_1_stream_writer}{Stream\+Writer}} for a class that can be used to \mbox{\hyperlink{class_qore_1_1_string_output_stream_ab7ac16ba46cae914c70145b8fcb3f0b4}{write}} various kinds of data to an \mbox{\hyperlink{class_qore_1_1_output_stream}{Output\+Stream}}
\end{DoxySeeAlso}
\begin{DoxySince}{Since}
Qore 0.\+8.\+13 
\end{DoxySince}


\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_string_output_stream_a9e72b18135630529612c2a1ab88a9706}\label{class_qore_1_1_string_output_stream_a9e72b18135630529612c2a1ab88a9706}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!close@{close}}
\index{close@{close}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{close()}{close()}}
{\footnotesize\ttfamily nothing Qore\+::\+String\+Output\+Stream\+::close (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Closes the output stream and releases any resources. 

Any methods called on a closed output stream will throw an exception.


\begin{DoxyExceptions}{Exceptions}
{\em O\+U\+T\+P\+U\+T-\/\+S\+T\+R\+E\+A\+M-\/\+C\+L\+O\+S\+E\+D-\/\+E\+R\+R\+OR} & the output stream has already been closed \\
\hline
{\em S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}


Implements \mbox{\hyperlink{class_qore_1_1_output_stream_a2125e17612767b9636554b282638e883}{Qore\+::\+Output\+Stream}}.

\mbox{\Hypertarget{class_qore_1_1_string_output_stream_a6ab01cef4c8993f15fd3f33ff673f93d}\label{class_qore_1_1_string_output_stream_a6ab01cef4c8993f15fd3f33ff673f93d}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!constructor@{constructor}}
\index{constructor@{constructor}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily Qore\+::\+String\+Output\+Stream\+::constructor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. 

This variant assumes the \mbox{\hyperlink{character_encoding_default_encoding}{Default Character Encoding}} for the string

\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}} object, otherwise a string with invalid character data will be returned by \mbox{\hyperlink{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}{get\+Data()}} 
\end{DoxyNote}
\mbox{\Hypertarget{class_qore_1_1_string_output_stream_a7350dd527d6b743ced0d9f11ba403ec1}\label{class_qore_1_1_string_output_stream_a7350dd527d6b743ced0d9f11ba403ec1}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!constructor@{constructor}}
\index{constructor@{constructor}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Qore\+::\+String\+Output\+Stream\+::constructor (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}}}]{encoding }\end{DoxyParamCaption})}



Creates the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. 


\begin{DoxyParams}{Parameters}
{\em encoding} & the encoding to tag the string data with\\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}} object, otherwise a string with invalid character data will be returned by \mbox{\hyperlink{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}{get\+Data()}} 
\end{DoxyNote}
\mbox{\Hypertarget{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}\label{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!get\+Data@{get\+Data}}
\index{get\+Data@{get\+Data}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{get\+Data()}{getData()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+String\+Output\+Stream\+::get\+Data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the data written to the stream, clearing the internal buffer. 

\begin{DoxyReturn}{Returns}
the data written to the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}
\end{DoxyReturn}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
StringOutputStream sos();
sos.write(<41>);
sos.write(<42>);
sos.write(<43>);
sos.getData();      \textcolor{comment}{# returns "ABC"}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em O\+U\+T\+P\+U\+T-\/\+S\+T\+R\+E\+A\+M-\/\+C\+L\+O\+S\+E\+D-\/\+E\+R\+R\+OR} & the output stream has already been closed \\
\hline
{\em S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_string_output_stream_af3adfd7eb6cf48de3d2007e9484ad032}\label{class_qore_1_1_string_output_stream_af3adfd7eb6cf48de3d2007e9484ad032}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!get\+Encoding@{get\+Encoding}}
\index{get\+Encoding@{get\+Encoding}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{get\+Encoding()}{getEncoding()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+String\+Output\+Stream\+::get\+Encoding (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
StringOutputStream sos(\textcolor{stringliteral}{"latin1"});
string encoding = sos.getEncoding();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
the \mbox{\hyperlink{character_encoding}{character encoding}} for the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}}
\end{DoxyReturn}
\begin{DoxyNote}{Note}
raw binary data is written to the output stream, so it\textquotesingle{}s up to the caller to ensure that only valid character data for the given encoding is written to the \mbox{\hyperlink{class_qore_1_1_string_output_stream}{String\+Output\+Stream}} object, otherwise a string with invalid character data will be returned by \mbox{\hyperlink{class_qore_1_1_string_output_stream_a5d2573b4fcc5bda27e098eba27418d01}{get\+Data()}} 
\end{DoxyNote}
\mbox{\Hypertarget{class_qore_1_1_string_output_stream_ab7ac16ba46cae914c70145b8fcb3f0b4}\label{class_qore_1_1_string_output_stream_ab7ac16ba46cae914c70145b8fcb3f0b4}} 
\index{Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}!write@{write}}
\index{write@{write}!Qore\+::\+String\+Output\+Stream@{Qore\+::\+String\+Output\+Stream}}
\subsubsection{\texorpdfstring{write()}{write()}}
{\footnotesize\ttfamily nothing Qore\+::\+String\+Output\+Stream\+::write (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_gaf11c7f5c43ced1e9b95bd2270ee87ed9}{binary}}}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



Writes bytes to the output stream. 


\begin{DoxyParams}{Parameters}
{\em data} & the data to write\\
\hline
\end{DoxyParams}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
StringOutputStream sos();
sos.write(<41>);
sos.write(<42>);
sos.write(<43>);
sos.getData();      \textcolor{comment}{# returns "ABC"}
\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em O\+U\+T\+P\+U\+T-\/\+S\+T\+R\+E\+A\+M-\/\+C\+L\+O\+S\+E\+D-\/\+E\+R\+R\+OR} & the output stream has already been closed \\
\hline
{\em S\+T\+R\+E\+A\+M-\/\+T\+H\+R\+E\+A\+D-\/\+E\+R\+R\+OR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}


Implements \mbox{\hyperlink{class_qore_1_1_output_stream_a9054b0475c4829d10f956d8f6df6f2ac}{Qore\+::\+Output\+Stream}}.

