17 enum MODE {READ = 1, WRITE = 2, READ_WRITE = 3};
33 bool open(MODE m,
const std::string& file_name =
"");
45 bool read(
unsigned char *targetbuffer,
unsigned long num,
unsigned long *numread=NULL);
48 bool write(
const unsigned char *sourcebuffer,
unsigned long num,
unsigned long *numwrote=NULL);
52 bool read(T& v) {
return read((
unsigned char*)(&v),
sizeof(T)); }
55 bool read_array(T* a,
unsigned int n) {
return read((
unsigned char*)a,
sizeof(T)*n); }
59 bool write(
const T& v) {
return write((
const unsigned char*)(&v),
sizeof(T)); }
62 bool write_array(
const T* a,
unsigned int n) {
return write((
const unsigned char*)a,
sizeof(T)*n); }
65 bool seek(
long long index);
74 #include <cgv/config/lib_end.h>
big_binary_file(const std::string &filename="")
assosiates the new instance to the file filename
bool read(T &v)
read a typedef value
Definition: big_binary_file.h:52
bool read_array(T *a, unsigned int n)
read an array of typed values
Definition: big_binary_file.h:55
void close()
close the file
virtual ~big_binary_file()
close the file (if it is still opened)
long long size()
return the size of the file in bytes
bool is_open()
return true if the file is opened
bool write(const unsigned char *sourcebuffer, unsigned long num, unsigned long *numwrote=NULL)
write num bytes to the file from the sourcebuffer (file must be opened with write access first)
bool open(MODE m, const std::string &file_name="")
open a file in read or write mode
bool read(unsigned char *targetbuffer, unsigned long num, unsigned long *numread=NULL)
read num bytes from the file into the targetbuffer
bool write_array(const T *a, unsigned int n)
write an array of typed values
Definition: big_binary_file.h:62
the cgv namespace
Definition: vr_calib.cxx:9
bool write(const T &v)
write a typedef value
Definition: big_binary_file.h:59
Definition: big_binary_file.h:15
long long position()
return the position of the file pointer in bytes