CFile Class Reference


Detailed Description

A File access class.

A file consists of a fourcc header then an alternation of a type header and data or just raw data (simplefile=true). However this implementation is not complete - the more complex stuff is currently not implemented.

Definition at line 40 of file File.h.

Inheritance diagram for CFile:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CFile (FILE *f)
 CFile (char *fname, char rw, EFeatureType type, char fourcc[4]=NULL)
virtual ~CFile ()
int32_t parse_first_header (EFeatureType &type)
int32_t parse_next_header (EFeatureType &type)
int32_t * load_int_data (int32_t *target, int64_t &num)
float64_tload_real_data (float64_t *target, int64_t &num)
float32_tload_shortreal_data (float32_t *target, int64_t &num)
char * load_char_data (char *target, int64_t &num)
uint8_t * load_byte_data (uint8_t *target, int64_t &num)
uint16_t * load_word_data (uint16_t *target, int64_t &num)
int16_t * load_short_data (int16_t *target, int64_t &num)
template<class DT >
DT * load_data (DT *target, int64_t &num)
template<class DT >
bool save_data (DT *src, int64_t num)
bool save_int_data (int32_t *src, int64_t num)
bool save_real_data (float64_t *src, int64_t num)
bool save_shortreal_data (float32_t *src, int64_t num)
bool save_char_data (char *src, int64_t num)
bool save_byte_data (uint8_t *src, int64_t num)
bool save_word_data (uint16_t *src, int64_t num)
bool save_short_data (int16_t *src, int64_t num)
bool is_ok ()
bool read_real_valued_sparse (TSparse< float64_t > *&matrix, int32_t &num_feat, int32_t &num_vec)
bool write_real_valued_sparse (const TSparse< float64_t > *matrix, int32_t num_feat, int32_t num_vec)
bool read_real_valued_dense (float64_t *&matrix, int32_t &num_feat, int32_t &num_vec)
bool write_real_valued_dense (const float64_t *matrix, int32_t num_feat, int32_t num_vec)
bool read_char_valued_strings (T_STRING< char > *&strings, int32_t &num_str, int32_t &max_string_len)
bool write_char_valued_strings (const T_STRING< char > *strings, int32_t num_str)
virtual const char * get_name () const

Protected Member Functions

bool read_header ()
bool write_header ()

Protected Attributes

FILE * file
bool status
char task
char * filename
EFeatureType expected_type
int32_t num_header
char fourcc [4]

Constructor & Destructor Documentation

CFile ( FILE *  f  ) 

constructor

Parameters:
f already opened file

Definition at line 25 of file File.cpp.

CFile ( char *  fname,
char  rw,
EFeatureType  type,
char  fourcc[4] = NULL 
)

constructor

Parameters:
fname filename to open
rw mode, 'r' or 'w'
type specifies the datatype used in the file (F_INT,...)
fourcc in the case fourcc is 0, type will be ignored and the file is treated as if it has a header/[typeheader,data]+ else the files header will be checked to contain the specified fourcc (e.g. 'RFEA')

Definition at line 33 of file File.cpp.

~CFile (  )  [virtual]

Definition at line 70 of file File.cpp.


Member Function Documentation

virtual const char* get_name (  )  const [virtual]
Returns:
object name

Implements CSGObject.

Definition at line 300 of file File.h.

bool is_ok (  ) 

check if status is ok

Returns:
whether status is ok

Definition at line 223 of file File.h.

uint8_t * load_byte_data ( uint8_t *  target,
int64_t &  num 
)

load byte data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 147 of file File.cpp.

char * load_char_data ( char *  target,
int64_t &  num 
)

load char data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 130 of file File.cpp.

DT* load_data ( DT *  target,
int64_t &  num 
)

load data (templated)

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 142 of file File.h.

int32_t * load_int_data ( int32_t *  target,
int64_t &  num 
)

load integer data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 79 of file File.cpp.

float64_t * load_real_data ( float64_t target,
int64_t &  num 
)

load real data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 96 of file File.cpp.

int16_t * load_short_data ( int16_t *  target,
int64_t &  num 
)

load short data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 181 of file File.cpp.

float32_t * load_shortreal_data ( float32_t target,
int64_t &  num 
)

load shortreal data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 105 of file File.cpp.

uint16_t * load_word_data ( uint16_t *  target,
int64_t &  num 
)

load word data

Parameters:
target loaded data
num number of data elements
Returns:
loaded data

Definition at line 164 of file File.cpp.

int32_t parse_first_header ( EFeatureType type  ) 

parse first header - defunct!

Parameters:
type feature type
Returns:
-1

Definition at line 198 of file File.cpp.

int32_t parse_next_header ( EFeatureType type  ) 

parse next header - defunct!

Parameters:
type feature type
Returns:
-1

Definition at line 203 of file File.cpp.

bool read_char_valued_strings ( T_STRING< char > *&  strings,
int32_t &  num_str,
int32_t &  max_string_len 
)

read char string features, simple ascii format e.g. foo bar ACGTACGTATCT

two strings

Parameters:
strings strings to read into
num_str number of strings
max_string_len length of longest string
Returns:
if reading was successful

Definition at line 537 of file File.cpp.

bool read_header (  )  [protected]

read header

Returns:
whether operation was successful

Definition at line 209 of file File.cpp.

bool read_real_valued_dense ( float64_t *&  matrix,
int32_t &  num_feat,
int32_t &  num_vec 
)

read dense real valued features, simple ascii format e.g. 1.0 1.1 0.2 2.3 3.5 5

a matrix that consists of 3 vectors with each of 2d

Parameters:
matrix matrix to read into
num_feat number of features for each vector
num_vec number of vectors in matrix
Returns:
if reading was successful

Definition at line 253 of file File.cpp.

bool read_real_valued_sparse ( TSparse< float64_t > *&  matrix,
int32_t &  num_feat,
int32_t &  num_vec 
)

read sparse real valued features in svm light format e.g. -1 1:10.0 2:100.2 1000:1.3 with -1 == (optional) label and dim 1 - value 10.0 dim 2 - value 100.2 dim 1000 - value 1.3

Parameters:
matrix matrix to read into
num_feat number of features for each vector
num_vec number of vectors in matrix
Returns:
if reading was successful

Definition at line 349 of file File.cpp.

bool save_byte_data ( uint8_t *  src,
int64_t  num 
)

save byte data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 156 of file File.cpp.

bool save_char_data ( char *  src,
int64_t  num 
)

save char data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 139 of file File.cpp.

bool save_data ( DT *  src,
int64_t  num 
)

save data (templated)

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 156 of file File.h.

bool save_int_data ( int32_t *  src,
int64_t  num 
)

save integer data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 88 of file File.cpp.

bool save_real_data ( float64_t src,
int64_t  num 
)

save real data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 114 of file File.cpp.

bool save_short_data ( int16_t *  src,
int64_t  num 
)

save short data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 190 of file File.cpp.

bool save_shortreal_data ( float32_t src,
int64_t  num 
)

save shortreal data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 122 of file File.cpp.

bool save_word_data ( uint16_t *  src,
int64_t  num 
)

save word data

Parameters:
src data to save
num number of data elements
Returns:
whether operation was successful

Definition at line 173 of file File.cpp.

bool write_char_valued_strings ( const T_STRING< char > *  strings,
int32_t  num_str 
)

write char string features, simple ascii format

Parameters:
strings strings to write
num_str number of strings
Returns:
if writing was successful

Definition at line 638 of file File.cpp.

bool write_header (  )  [protected]

write header

Returns:
whether operation was successful

Definition at line 226 of file File.cpp.

bool write_real_valued_dense ( const float64_t matrix,
int32_t  num_feat,
int32_t  num_vec 
)

write dense real valued features, simple ascii format

Parameters:
matrix matrix to write
num_feat number of features for each vector
num_vec number of vectros in matrix
Returns:
if writing was successful

Definition at line 328 of file File.cpp.

bool write_real_valued_sparse ( const TSparse< float64_t > *  matrix,
int32_t  num_feat,
int32_t  num_vec 
)

write sparse real valued features in svm light format

Parameters:
matrix matrix to write
num_feat number of features for each vector
num_vec number of vectros in matrix
Returns:
if writing was successful

Definition at line 513 of file File.cpp.


Member Data Documentation

expected feature type

Definition at line 328 of file File.h.

FILE* file [protected]

file object

Definition at line 320 of file File.h.

char* filename [protected]

name of the handled file

Definition at line 326 of file File.h.

char fourcc[4] [protected]

fourcc

Definition at line 332 of file File.h.

int32_t num_header [protected]

number of headers

Definition at line 330 of file File.h.

bool status [protected]

status

Definition at line 322 of file File.h.

char task [protected]

task

Definition at line 324 of file File.h.


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

SHOGUN Machine Learning Toolbox - Documentation