Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

Stream helpers

 

Function List

 

String LoadStream(Stream& in)

Reads the stream starting with the current position till the end is reached and returns data in String.

in

Stream.

Return value

Content of stream.

 


 

bool SaveStream(Stream& out, const String& data)

Writes data to stream.

out

Output stream.

data

Data to write.

Return value

True if all data were successfully written to the stream.

 


 

int64 CopyStream(Stream& dest, Stream& src, int64 count = INT64_MAX)

Copies at most count bytes from source to destination stream. Returns the actual number of bytes copied. With default count value it copies all data from src until EOF.

 


 

void CoutUTF8()

In Win32, setups console output for UTF8. NOP in POSIX.

 


 

Stream& Cout()

Returns special output stream representing console output. Data written to this stream are displayed as characters in console. In Win32, encoding is converted to default console encoding, or is not convereted at all if CoutUTF8 was called.

Return value

Console stream.

 


 

Stream& Cerr()

Returns special output stream representing console error output. Data written to this stream are displayed as characters in console.

 


 

String ReadStdIn()

Reads one line of input data from the console.

Return value

Console input.

 


 

String ReadSecret()

Reads one line of input data from the console without echoing. This function is useful for reading passwords, secret phrases, etc. from the console.

Return value

Console input.

 


 

Stream& NilStream()

Returns special stream that is always in IsEof state and simply discards all data written to it.

Return value

"Black hole" stream.

 


 

String LoadFile(const char *filename)

Loads the content of specified file.

filename

File name.

Return value

Content of file.

 


 

bool SaveFile(const char *filename, const String& data)

Saves data as the file (overwrites existing).

filename

File name.

data

Data to write.

Return value

true if file was successfully written.

 


 

template <class T> Stream& operator%(Stream& s, T& x)

Serialization operator. Simply invokes x.Serialize(s);

T

Type of variable to be serialized.

s

Stream.

x

Variable to be serialized.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, const char *x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - all characters are written to the stream.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, char *x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - all characters are written to the stream.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, const String &x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - all characters are written to the stream.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, char x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - it is written as single character.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, const void *x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - pointer is formatted as hexadecimal value.

Return value

s for chaining.

 


 

Stream& operator<<(Stream& s, void *x)

Overload of stream insertion operator to get simple case work. Insertion operator uses formatted stream output (Putf).

s

Output stream.

x

Data to write - pointer is formatted as hexadecimal value.

Return value

s for chaining.

 


 

template <class T> Stream& operator<<(Stream& s, const T& x)

Global stream insertion operator. Calls AsString for x and stores the result to the stream. Global AsString version in turn calls ToString method of x.

T

Type of data to write to the stream.

s

Output stream.

x

Data to write.

Return value

s for chaining.

 

 

Last edit by cxl on 12/02/2017. Do you want to contribute?. T++