11 #ifndef __SIMPLEFILE_H__ 12 #define __SIMPLEFILE_H__ 14 #include <shogun/lib/config.h> 73 T*
load(T* target, int64_t& num)
81 bool seek_status=
true;
82 int64_t cur_pos=ftell(
file);
86 if (!fseek(
file, 0, SEEK_END))
88 if ((num=(int64_t) ftell(
file)) != -1)
90 SG_INFO(
"file of size %ld bytes == %ld entries detected\n", num,num/
sizeof(T))
100 if ((fseek(
file,cur_pos, SEEK_SET)) == -1)
105 SG_ERROR(
"filesize autodetection failed\n")
114 target=SG_MALLOC(T, num);
118 size_t num_read=fread((
void*) target,
sizeof(T), num,
file);
119 status=((int64_t) num_read == num);
122 SG_ERROR(
"only %ld of %ld entries read. io error\n", (int64_t) num_read, num)
125 SG_ERROR(
"failed to allocate memory while trying to read %ld entries from file \"s\"\n", (int64_t) num,
filename)
142 bool save(T* target, int64_t num)
150 target=SG_MALLOC(T, num);
154 status=(fwrite((
void*) target,
sizeof(T), num,
file)==
217 virtual const char*
get_name()
const {
return "SimpleFile"; }
Template class SimpleFile to read and write from files.
virtual const char * get_name() const
void set_line_buffer_size(int32_t bufsize)
Class SGObject is the base class of all shogun objects.
bool save(T *target, int64_t num)
void get_buffered_line(char *line, uint64_t len)
CSimpleFile(char *fname, FILE *f)
all of classes and functions are contained in the shogun namespace
T * load(T *target, int64_t &num)
#define SG_UNSTABLE(func,...)