11 #ifndef __BINARYSTREAM_H__
12 #define __BINARYSTREAM_H__
86 rw = get_strdup(flag);
89 fd = fopen(fname, flag);
94 if (stat(fname, &sb) == -1)
123 return length /
sizeof(T);
176 if (fseek(
fd, ((
long)
sizeof(T)) * ((
long) index), SEEK_SET) != 0)
177 SG_ERROR(
"Error seeking to %ld (file '%s')\n",
sizeof(T) * ((int64_t) index),
m_fname)
179 if (fread(buffer,
sizeof(T), num,
fd) != num)
190 if (fread(&ptr,
sizeof(T), 1,
fd) != 1)
192 fprintf(stderr,
"Error calling fread (file '%s')\n",
m_fname);
206 if (fseek(
fd, ((
long)
sizeof(T)) * ((
long) index), SEEK_SET) != 0)
207 SG_ERROR(
"Error seeking to %ld (file '%s')\n",
sizeof(T) * ((int64_t) index),
m_fname)
211 if (fread(&ptr,
sizeof(T), 1,
fd) != 1)
220 return "BinaryStream";
234 #endif // BINARY_STREAM
CBinaryStream(const char *fname, const char *flag="r")
char * get_line(uint64_t &len, uint64_t &offs)
#define SG_NOTIMPLEMENTED
void open_stream(const char *fname, const char *flag="r")
Class SGObject is the base class of all shogun objects.
T operator[](int32_t index) const
memory mapped emulation via binary streams (files)
all of classes and functions are contained in the shogun namespace
CBinaryStream(const CBinaryStream &bs)
void pre_buffer(T *buffer, long index, long num) const
virtual const char * get_name() const