Public Member Functions | Protected Attributes

CBinaryStream< T > Class Template Reference


Detailed Description

template<class T>
class shogun::CBinaryStream< T >

memory mapped emulation via binary streams (files)

Implements memory mapped file emulation (

See also:
CMemoryMappedFile) via standard file operations like fseek, fread etc

Definition at line 27 of file BinaryStream.h.

Inheritance diagram for CBinaryStream< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CBinaryStream ()
 CBinaryStream (const char *fname, const char *flag="r")
 CBinaryStream (const CBinaryStream &bs)
virtual ~CBinaryStream ()
void open_stream (const char *fname, const char *flag="r")
void close_stream ()
uint64_t get_length ()
uint64_t get_size ()
char * get_line (uint64_t &len, uint64_t &offs)
int32_t get_num_lines ()
void pre_buffer (T *buffer, long index, long num) const
read_next () const
operator[] (int32_t index) const
virtual const char * get_name () const

Protected Attributes

FILE * fd
uint64_t length
char * rw
char * m_fname

Constructor & Destructor Documentation

CBinaryStream (  ) 

default constructor

Definition at line 32 of file BinaryStream.h.

CBinaryStream ( const char *  fname,
const char *  flag = "r" 
)

constructor

open a file for read mode

Parameters:
fname name of file, zero terminated string
flag determines read or read write mode (currently only 'r' is supported)

Definition at line 47 of file BinaryStream.h.

CBinaryStream ( const CBinaryStream< T > &  bs  ) 

copy constructor

Parameters:
bs binary stream to copy from

Definition at line 59 of file BinaryStream.h.

virtual ~CBinaryStream (  )  [virtual]

destructor

Definition at line 67 of file BinaryStream.h.


Member Function Documentation

void close_stream (  ) 

close a file stream

Definition at line 95 of file BinaryStream.h.

uint64_t get_length (  ) 

get the number of objects of type T cointained in the file

Returns:
length of file

Definition at line 112 of file BinaryStream.h.

char* get_line ( uint64_t &  len,
uint64_t &  offs 
)

get next line from file

The returned line may be modfied in case the file was opened read/write. It is otherwise read-only.

Parameters:
len length of line (returned via reference)
offs offset to be passed for reading next line, should be 0 initially (returned via reference)
Returns:
line (NOT ZERO TERMINATED)

Definition at line 137 of file BinaryStream.h.

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

Implements CSGObject.

Definition at line 207 of file BinaryStream.h.

int32_t get_num_lines (  ) 

count the number of lines in a file

Returns:
number of lines

Definition at line 146 of file BinaryStream.h.

uint64_t get_size (  ) 

get the size of the file in bytes

Returns:
size of file in bytes

Definition at line 121 of file BinaryStream.h.

void open_stream ( const char *  fname,
const char *  flag = "r" 
)

open file stream

Parameters:
fname file name
flag flags "r" for reading etc

Definition at line 77 of file BinaryStream.h.

T operator[] ( int32_t  index  )  const

operator overload for file read only access

Parameters:
index index
Returns:
element at index

Definition at line 192 of file BinaryStream.h.

void pre_buffer ( T *  buffer,
long  index,
long  num 
) const

read num elements starting from index into buffer

Parameters:
buffer buffer that has to be at least num elements long
index index into file starting from which elements are read
num number of elements to be read

Definition at line 157 of file BinaryStream.h.

T read_next (  )  const

read next

Returns:
next element

Definition at line 176 of file BinaryStream.h.


Member Data Documentation

FILE* fd [protected]

file descriptor

Definition at line 211 of file BinaryStream.h.

uint64_t length [protected]

size of file

Definition at line 213 of file BinaryStream.h.

char* m_fname [protected]

fname

Definition at line 217 of file BinaryStream.h.

char* rw [protected]

mode

Definition at line 215 of file BinaryStream.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation