SpectMorph
|
Class to read SpectMorph binary data. More...
#include <sminfile.hh>
Public Types | |
enum | Event { NONE, END_OF_FILE, READ_ERROR, BEGIN_SECTION, END_SECTION, BOOL, INT, STRING, FLOAT, FLOAT_BLOCK, UINT16_BLOCK, BLOB, BLOB_REF } |
Public Member Functions | |
InFile (const std::string &filename) | |
InFile (GenericIn *file) | |
bool | open_ok () |
Event | event () |
std::string | event_name () |
float | event_float () |
int | event_int () |
bool | event_bool () |
std::string | event_data () |
const std::vector< float > & | event_float_block () |
const std::vector< uint16_t > & | event_uint16_block () |
std::string | event_blob_sum () |
void | next_event () |
void | add_skip_event (const std::string &event) |
std::string | file_type () |
int | file_version () |
GenericIn * | open_blob () |
Protected Attributes | |
GenericIn * | file |
bool | file_delete |
Event | current_event |
std::string | current_event_str |
bool | current_event_bool |
int | current_event_int |
std::string | current_event_data |
float | current_event_float |
std::vector< float > | current_event_float_block |
std::vector< uint16_t > | current_event_uint16_block |
size_t | current_event_blob_pos |
size_t | current_event_blob_size |
std::string | current_event_blob_sum |
std::string | m_file_type |
int | m_file_version |
std::set< std::string > | skip_events |
Class to read SpectMorph binary data.
This class allows reading SpectMorph binary data from a file (with name) or from a GenericIn object; the files consist of events, which are read one by one until an error occurs or until EOF. The events are typed, end the event data should be queried according to the current event type.
InFile::InFile | ( | const std::string & | filename | ) |
Create InFile object for reading a file.
filename | name of the file |
InFile::InFile | ( | GenericIn * | file | ) |
Create InFile object for reading an input stream.
file | the input stream object to read data from |
void InFile::add_skip_event | ( | const std::string & | event | ) |
Add event names to skip (currently only implemented for FLOAT_BLOCK events); this speeds up reading files, while ignoring certain events.
skip_event | name of the event to skip |
InFile::Event InFile::event | ( | ) |
Get current event type.
string InFile::event_blob_sum | ( | ) |
Get blob's checksum. This works for both: BLOB objects and BLOB_REF objects. During writing files, the first occurence of a BLOB is stored completely, whereas after that, only the blob sum is stored as BLOB_REF event. During loading, code for handling both needs to be supplied.
bool InFile::event_bool | ( | ) |
Get bool data of the current event (only if the event is BOOL).
string InFile::event_data | ( | ) |
Get string data of the current event (only if the event is STRING).
float InFile::event_float | ( | ) |
Get float data of the current event (only if the event is a FLOAT).
const vector< float > & InFile::event_float_block | ( | ) |
Get float block data of the current event (only if the event is FLOAT_BLOCK).
int InFile::event_int | ( | ) |
Get int data of the current event (only if the event is an INT).
string InFile::event_name | ( | ) |
Get name of the current event.
const vector< uint16_t > & InFile::event_uint16_block | ( | ) |
Get uint16 block data of the current event (only if the event is UINT16_BLOCK).
string InFile::file_type | ( | ) |
Get file type (usually a class name, like "SpectMorph::WavSet").
int InFile::file_version | ( | ) |
Get file version, an integer.
void InFile::next_event | ( | ) |
Reads next event from file. Call event() to get event type, and event_*() to get event data.
GenericIn * InFile::open_blob | ( | ) |
|
inline |
Check if file open succeeded.