2009-12-19 07:26:01 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "../servers/memory_stream.hpp"
|
2009-12-29 15:16:33 +00:00
|
|
|
|
|
|
|
using namespace Mangle::Stream;
|
2009-12-19 07:26:01 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2010-01-01 15:39:11 +00:00
|
|
|
Stream* inp = new MemoryStream("hello world\0", 12);
|
2009-12-19 07:26:01 +00:00
|
|
|
|
|
|
|
cout << "Size: " << inp->size() << endl;
|
|
|
|
cout << "Pos: " << inp->tell() << "\nSeeking...\n";
|
|
|
|
inp->seek(3);
|
|
|
|
cout << "Pos: " << inp->tell() << endl;
|
|
|
|
char data[12];
|
|
|
|
memset(data, 0, 12);
|
|
|
|
cout << "Reading: " << inp->read(data, 4) << endl;
|
|
|
|
cout << "Four bytes: " << data << endl;
|
|
|
|
cout << "Eof: " << inp->eof() << endl;
|
|
|
|
cout << "Pos: " << inp->tell() << "\nSeeking again...\n";
|
|
|
|
inp->seek(33);
|
|
|
|
cout << "Pos: " << inp->tell() << endl;
|
|
|
|
cout << "Eof: " << inp->eof() << "\nSeek to 6\n";
|
|
|
|
inp->seek(6);
|
|
|
|
cout << "Eof: " << inp->eof() << endl;
|
|
|
|
cout << "Pos: " << inp->tell() << endl;
|
|
|
|
cout << "Over-reading: " << inp->read(data, 200) << endl;
|
|
|
|
cout << "Result: " << data << endl;
|
|
|
|
cout << "Eof: " << inp->eof() << endl;
|
|
|
|
cout << "Pos: " << inp->tell() << endl;
|
|
|
|
inp->seek(0);
|
|
|
|
cout << "Finally, reading the entire string: " << inp->read(data,11) << endl;
|
|
|
|
cout << "Result: " << data << endl;
|
|
|
|
cout << "Eof: " << inp->eof() << endl;
|
|
|
|
cout << "Pos: " << inp->tell() << endl;
|
2010-01-01 15:39:11 +00:00
|
|
|
|
|
|
|
cout << "Entire stream from pointer: " << (char*)inp->getPtr() << endl;
|
2011-04-03 11:06:42 +00:00
|
|
|
|
2009-12-19 07:26:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|