mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-18 06:06:01 -06:00
.tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@11527 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
089a7c117c
commit
3ecd8e7da4
5 changed files with 83 additions and 26 deletions
|
|
@ -3,20 +3,28 @@
|
|||
void SpecialStream()
|
||||
{
|
||||
/// .Special streams
|
||||
|
||||
/// `SizeStream` counts the number of bytes written to the stream:
|
||||
|
||||
SizeStream szs;
|
||||
szs << "1234567";
|
||||
DUMP(szs.GetSize());
|
||||
|
||||
///
|
||||
/// `CompareStream` can be used to compare the content of some stream with data written to
|
||||
/// `CompareStream`:
|
||||
|
||||
StringStream in("123456");
|
||||
CompareStream cs(in);
|
||||
cs.Put("12345");
|
||||
DUMP(cs.IsEqual());
|
||||
|
||||
///
|
||||
|
||||
cs.Put("7");
|
||||
DUMP(cs.IsEqual());
|
||||
|
||||
///
|
||||
/// `OutStream` buffers output data to bigger blocks, then outputs them via `Out` virtual
|
||||
/// method:
|
||||
|
||||
struct MyOutStream : OutStream {
|
||||
virtual void Out(const void *data, dword size) {
|
||||
|
|
@ -28,7 +36,7 @@ void SpecialStream()
|
|||
os << "This is a test " << 12345;
|
||||
os.Close();
|
||||
|
||||
///
|
||||
/// `TeeStream` send output data to two separate streams:
|
||||
|
||||
StringStream ss1;
|
||||
StringStream ss2;
|
||||
|
|
@ -38,7 +46,7 @@ void SpecialStream()
|
|||
DUMP(ss1.GetResult());
|
||||
DUMP(ss2.GetResult());
|
||||
|
||||
///
|
||||
/// `MemReadStream` can be used to convert read-only memory block to stream data:
|
||||
|
||||
static const char s[] = "Some line\nAnother line";
|
||||
MemReadStream ms(s, sizeof(os));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue