mrfioc2  2.3.0
Public Member Functions | List of all members
mrf::CFIStreamBuf Class Reference

Adapt CFIFlash for use with std::istream. More...

#include <flash.h>

Inheritance diagram for mrf::CFIStreamBuf:
Inheritance graph
[legend]
Collaboration diagram for mrf::CFIStreamBuf:
Collaboration graph
[legend]

Public Member Functions

 CFIStreamBuf (CFIFlash &flash)
 
virtual int_type underflow () OVERRIDE FINAL
 
virtual pos_type seekoff (off_type off, std::ios_base::seekdir dir, std::ios_base::openmode mode) OVERRIDE FINAL
 
virtual pos_type seekpos (pos_type pos, std::ios_base::openmode mode) OVERRIDE FINAL
 

Detailed Description

Adapt CFIFlash for use with std::istream.

Definition at line 89 of file flash.h.

Constructor & Destructor Documentation

◆ CFIStreamBuf()

mrf::CFIStreamBuf::CFIStreamBuf ( CFIFlash flash)

Definition at line 371 of file flash.cpp.

372  :flash(flash)
373  ,pos(0u)
374 {}

Member Function Documentation

◆ seekoff()

CFIStreamBuf::pos_type mrf::CFIStreamBuf::seekoff ( off_type  off,
std::ios_base::seekdir  dir,
std::ios_base::openmode  mode 
)
virtual

Definition at line 388 of file flash.cpp.

389 {
390  if(dir==std::ios_base::cur)
391  off += pos;
392  else if(dir==std::ios_base::end)
393  return pos_type(-1); // error
394  return seekpos(off, mode);
395 }
virtual pos_type seekpos(pos_type pos, std::ios_base::openmode mode) OVERRIDE FINAL
Definition: flash.cpp:398

◆ seekpos()

CFIStreamBuf::pos_type mrf::CFIStreamBuf::seekpos ( pos_type  pos,
std::ios_base::openmode  mode 
)
virtual

Definition at line 398 of file flash.cpp.

399 {
400  pos = off;
401  setg(&buf[0], &buf[0], &buf[0]); // empty buffer
402  return pos;
403 }

◆ underflow()

CFIStreamBuf::int_type mrf::CFIStreamBuf::underflow ( )
virtual

Definition at line 376 of file flash.cpp.

377 {
378  // read-ahead is only one page
379  buf.resize(flash.pageSize());
380  flash.read(pos, buf.size(), (epicsUInt8*)&buf[0]);
381  setg(&buf[0], &buf[0], &buf[buf.size()]);
382  pos += buf.size();
383 
384  return buf[0];
385 }
void read(epicsUInt32 start, epicsUInt32 count, epicsUInt8 *in)
Definition: flash.cpp:124
epicsUInt32 pageSize()
Definition: flash.h:53

The documentation for this class was generated from the following files: