Пример #1
0
int main()
{
  StreamPtr inp = StringStream::Open("hello world!");

  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;

  cout << "Entire stream from pointer: " << (char*)inp->getPtr() << endl;
  
  return 0;
}
Пример #2
0
 // For fixed-size strings where you already know the size
 const char *getString(int size)
   { return (const char*)inp->getPtr(size); }
Пример #3
0
 Misc::SliceArray<X> getArrayLen(int num)
   { return Misc::SliceArray<X>((const X*)inp->getPtr(num*sizeof(X)),num); }
Пример #4
0
template<class X> const X* getPtr() { return (const X*)inp->getPtr(sizeof(X)); }
Пример #5
0
 void skip(size_t size) { inp->getPtr(size); }