CFile Class Reference

Inheritance diagram for CFile:

Inheritance graph
[legend]

List of all members.


Detailed Description

A file consists of a header then an alternation of a type header and data

or just raw data (simplefile=true)

the more complex stuff is currently not implemented

Definition at line 32 of file File.h.


Public Member Functions

 CFile (FILE *f)
 CFile (CHAR *fname, CHAR rw, EFeatureType type, CHAR fourcc[4]=NULL)
 ~CFile ()
INT parse_first_header (EFeatureType &type)
INT parse_next_header (EFeatureType &type)
INTload_int_data (INT *target, LONG &num)
DREALload_real_data (DREAL *target, LONG &num)
SHORTREALload_shortreal_data (SHORTREAL *target, LONG &num)
CHARload_char_data (CHAR *target, LONG &num)
BYTEload_byte_data (BYTE *target, LONG &num)
WORDload_word_data (WORD *target, LONG &num)
SHORTload_short_data (SHORT *target, LONG &num)
bool save_int_data (INT *src, LONG num)
bool save_real_data (DREAL *src, LONG num)
bool save_shortreal_data (SHORTREAL *src, LONG num)
bool save_char_data (CHAR *src, LONG num)
bool save_byte_data (BYTE *src, LONG num)
bool save_word_data (WORD *src, LONG num)
bool save_short_data (SHORT *src, LONG num)
bool is_ok ()
bool read_real_valued_sparse (TSparse< DREAL > *&matrix, INT &num_feat, INT &num_vec)
bool write_real_valued_sparse (const TSparse< DREAL > *matrix, INT num_feat, INT num_vec)
bool read_real_valued_dense (DREAL *&matrix, INT &num_feat, INT &num_vec)
bool write_real_valued_dense (const DREAL *matrix, INT num_feat, INT num_vec)
bool read_char_valued_strings (T_STRING< CHAR > *&strings, INT &num_str, INT &max_string_len)
bool write_char_valued_strings (const T_STRING< CHAR > *strings, INT num_str)

Static Public Attributes

static CParallel parallel
static CIO io
static CVersion version

Protected Member Functions

bool read_header ()
bool write_header ()

Protected Attributes

FILE * file
bool status
CHAR task
CHARfilename
EFeatureType expected_type
INT num_header
CHAR fourcc [4]

Constructor & Destructor Documentation

CFile::CFile ( FILE *  f  ) 

constructor

Parameters:
f already opened file

Definition at line 24 of file File.cpp.

CFile::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 32 of file File.cpp.

CFile::~CFile (  ) 

Definition at line 69 of file File.cpp.


Member Function Documentation

INT CFile::parse_first_header ( EFeatureType type  ) 

parse first header - defunct!

Parameters:
type feature type
Returns:
-1

Definition at line 197 of file File.cpp.

INT CFile::parse_next_header ( EFeatureType type  ) 

parse next header - defunct!

Parameters:
type feature type
Returns:
-1

Definition at line 202 of file File.cpp.

INT * CFile::load_int_data ( INT target,
LONG num 
)

load integer data

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

Definition at line 78 of file File.cpp.

DREAL * CFile::load_real_data ( DREAL target,
LONG num 
)

load real data

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

Definition at line 95 of file File.cpp.

SHORTREAL * CFile::load_shortreal_data ( SHORTREAL target,
LONG num 
)

load shortreal data

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

Definition at line 104 of file File.cpp.

CHAR * CFile::load_char_data ( CHAR target,
LONG num 
)

load char data

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

Definition at line 129 of file File.cpp.

BYTE * CFile::load_byte_data ( BYTE target,
LONG num 
)

load byte data

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

Definition at line 146 of file File.cpp.

WORD * CFile::load_word_data ( WORD target,
LONG num 
)

load word data

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

Definition at line 163 of file File.cpp.

SHORT * CFile::load_short_data ( SHORT target,
LONG num 
)

load short data

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

Definition at line 180 of file File.cpp.

bool CFile::save_int_data ( INT src,
LONG  num 
)

save integer data

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

Definition at line 87 of file File.cpp.

bool CFile::save_real_data ( DREAL src,
LONG  num 
)

save real data

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

Definition at line 113 of file File.cpp.

bool CFile::save_shortreal_data ( SHORTREAL src,
LONG  num 
)

save shortreal data

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

Definition at line 121 of file File.cpp.

bool CFile::save_char_data ( CHAR src,
LONG  num 
)

save char data

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

Definition at line 138 of file File.cpp.

bool CFile::save_byte_data ( BYTE src,
LONG  num 
)

save byte data

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

Definition at line 155 of file File.cpp.

bool CFile::save_word_data ( WORD src,
LONG  num 
)

save word data

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

Definition at line 172 of file File.cpp.

bool CFile::save_short_data ( SHORT src,
LONG  num 
)

save short data

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

Definition at line 189 of file File.cpp.

bool CFile::is_ok (  ) 

check if status is ok

Returns:
whether status is ok

Definition at line 188 of file File.h.

bool CFile::read_real_valued_sparse ( TSparse< DREAL > *&  matrix,
INT num_feat,
INT 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 345 of file File.cpp.

bool CFile::write_real_valued_sparse ( const TSparse< DREAL > *  matrix,
INT  num_feat,
INT  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 508 of file File.cpp.

bool CFile::read_real_valued_dense ( DREAL *&  matrix,
INT num_feat,
INT 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 251 of file File.cpp.

bool CFile::write_real_valued_dense ( const DREAL matrix,
INT  num_feat,
INT  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 325 of file File.cpp.

bool CFile::read_char_valued_strings ( T_STRING< CHAR > *&  strings,
INT num_str,
INT 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 531 of file File.cpp.

bool CFile::write_char_valued_strings ( const T_STRING< CHAR > *  strings,
INT  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 631 of file File.cpp.

bool CFile::read_header (  )  [protected]

read header

Returns:
whether operation was successful

Definition at line 208 of file File.cpp.

bool CFile::write_header (  )  [protected]

write header

Returns:
whether operation was successful

Definition at line 225 of file File.cpp.


Member Data Documentation

FILE* CFile::file [protected]

file object

Definition at line 278 of file File.h.

bool CFile::status [protected]

status

Definition at line 280 of file File.h.

CHAR CFile::task [protected]

task

Definition at line 282 of file File.h.

CHAR* CFile::filename [protected]

name of the handled file

Definition at line 284 of file File.h.

expected feature type

Definition at line 286 of file File.h.

INT CFile::num_header [protected]

number of headers

Definition at line 288 of file File.h.

CHAR CFile::fourcc[4] [protected]

fourcc

Definition at line 290 of file File.h.

CParallel CSGObject::parallel [static, inherited]

Definition at line 105 of file SGObject.h.

CIO CSGObject::io [static, inherited]

Definition at line 106 of file SGObject.h.

CVersion CSGObject::version [static, inherited]

Definition at line 107 of file SGObject.h.


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

SHOGUN Machine Learning Toolbox - Documentation