PLearn 0.1
|
#include <BufferedIntVecFile.h>
Public Member Functions | |
BufferedIntVecFile (int buflen_=DEFAULT_BUFLEN) | |
Default constructor, you must then call open. | |
BufferedIntVecFile (const string &the_filename, bool readwrite=false, int buflen_=DEFAULT_BUFLEN) | |
virtual void | open (const string &the_filename, bool readwrite=false) |
The copy constructor opens the file a second time in readonly mode only. | |
virtual void | close () |
virtual int | get (int i) const |
virtual void | put (int i, int value) |
virtual int | operator[] (int i) const |
virtual void | append (int value) |
virtual | ~BufferedIntVecFile () |
Protected Types | |
typedef IntVecFile | inherited |
Protected Member Functions | |
virtual void | getBuf (int bufstart_) |
virtual void | flush () |
Protected Attributes | |
int | bufstart |
const int | buflen |
int * | buf |
bool | bufmod |
Static Protected Attributes | |
static const int | DEFAULT_BUFLEN = 65536 |
Definition at line 45 of file BufferedIntVecFile.h.
typedef IntVecFile PLearn::BufferedIntVecFile::inherited [protected] |
Definition at line 51 of file BufferedIntVecFile.h.
PLearn::BufferedIntVecFile::BufferedIntVecFile | ( | int | buflen_ = DEFAULT_BUFLEN | ) | [inline] |
Default constructor, you must then call open.
Definition at line 60 of file BufferedIntVecFile.h.
PLearn::BufferedIntVecFile::BufferedIntVecFile | ( | const string & | the_filename, |
bool | readwrite = false , |
||
int | buflen_ = DEFAULT_BUFLEN |
||
) | [inline] |
Definition at line 63 of file BufferedIntVecFile.h.
PLearn::BufferedIntVecFile::~BufferedIntVecFile | ( | ) | [virtual] |
Definition at line 84 of file BufferedIntVecFile.cc.
virtual void PLearn::BufferedIntVecFile::append | ( | int | value | ) | [inline, virtual] |
Reimplemented from PLearn::IntVecFile.
Definition at line 77 of file BufferedIntVecFile.h.
void PLearn::BufferedIntVecFile::close | ( | ) | [virtual] |
Reimplemented from PLearn::IntVecFile.
Definition at line 60 of file BufferedIntVecFile.cc.
References PLearn::flush().
{ flush(); inherited::close(); }
void PLearn::BufferedIntVecFile::flush | ( | ) | [protected, virtual] |
Definition at line 98 of file BufferedIntVecFile.cc.
References PLearn::byte_order(), PLearn::TVec< T >::copyFrom(), PLearn::TVec< T >::data(), PLearn::endianswap(), PLearn::TVec< T >::length(), and PLearn::min().
{ /* if(bufmod) for(int i= 0; i < buflen && i+bufstart < length(); ++i) inherited::put(i+bufstart, buf[i]); */ if(bufmod) { int len= min(buflen, length()-bufstart); seek_to_index(bufstart); if (byte_order() != endianness_) { TVec<int> new_vec(len); new_vec.copyFrom(buf, len); endianswap(new_vec.data(), new_vec.length()); fwrite(new_vec.data(), sizeof(int), new_vec.length(), f); } else { fwrite(buf, sizeof(int), len, f); } } bufmod= false; }
Reimplemented from PLearn::IntVecFile.
Definition at line 66 of file BufferedIntVecFile.cc.
void PLearn::BufferedIntVecFile::getBuf | ( | int | bufstart_ | ) | [protected, virtual] |
void PLearn::BufferedIntVecFile::open | ( | const string & | the_filename, |
bool | readwrite = false |
||
) | [virtual] |
The copy constructor opens the file a second time in readonly mode only.
Reimplemented from PLearn::IntVecFile.
Definition at line 52 of file BufferedIntVecFile.cc.
References PLearn::flush().
{ flush(); inherited::open(the_filename, readwrite); bufstart= -1; bufmod= false; }
Reimplemented from PLearn::IntVecFile.
Definition at line 76 of file BufferedIntVecFile.h.
References i.
{ return get(i); }
int* PLearn::BufferedIntVecFile::buf [mutable, protected] |
Definition at line 55 of file BufferedIntVecFile.h.
const int PLearn::BufferedIntVecFile::buflen [protected] |
Definition at line 54 of file BufferedIntVecFile.h.
bool PLearn::BufferedIntVecFile::bufmod [mutable, protected] |
Definition at line 56 of file BufferedIntVecFile.h.
int PLearn::BufferedIntVecFile::bufstart [mutable, protected] |
Definition at line 53 of file BufferedIntVecFile.h.
const int PLearn::BufferedIntVecFile::DEFAULT_BUFLEN = 65536 [static, protected] |
Definition at line 49 of file BufferedIntVecFile.h.