#include <CSVFormat.h>

Public Types

enum  ModelType {
  OneDimensionalModel, TwoDimensionalModel, TwoDimensionalModelWithDuration, TwoDimensionalModelWithDurationAndPitch,
  TwoDimensionalModelWithDurationAndExtent, ThreeDimensionalModel, WaveFileModel
}
 
enum  TimingType { ExplicitTiming, ImplicitTiming }
 
enum  TimeUnits { TimeSeconds, TimeMilliseconds, TimeAudioFrames, TimeWindows }
 
enum  ColumnPurpose {
  ColumnUnknown, ColumnStartTime, ColumnEndTime, ColumnDuration,
  ColumnValue, ColumnPitch, ColumnLabel
}
 
enum  HeaderStatus { HeaderUnknown = 0, HeaderAbsent = 1, HeaderPresent = 2 }
 
enum  ColumnQuality {
  ColumnNumeric = 1, ColumnIntegral = 2, ColumnIncreasing = 4, ColumnSmall = 8,
  ColumnLarge = 16, ColumnSigned = 32, ColumnNearEmpty = 64
}
 
enum  AudioSampleRange { SampleRangeSigned1 = 0, SampleRangeUnsigned255, SampleRangeSigned32767, SampleRangeOther }
 
typedef unsigned int ColumnQualities
 

Public Member Functions

 CSVFormat ()
 
 CSVFormat (QString path)
 
bool guessFormatFor (QString path)
 Guess the format of the given CSV file, setting the fields in this object accordingly. More...
 
ModelType getModelType () const
 
TimingType getTimingType () const
 
TimeUnits getTimeUnits () const
 
sv_samplerate_t getSampleRate () const
 
int getWindowSize () const
 
int getColumnCount () const
 
AudioSampleRange getAudioSampleRange () const
 
bool getAllowQuoting () const
 
HeaderStatus getHeaderStatus () const
 
QChar getSeparator () const
 
std::set< QChar > getPlausibleSeparators () const
 
void setModelType (ModelType t)
 
void setTimingType (TimingType t)
 
void setTimeUnits (TimeUnits t)
 
void setSeparator (QChar s)
 
void setSampleRate (sv_samplerate_t r)
 
void setWindowSize (int s)
 
void setColumnCount (int c)
 
void setAudioSampleRange (AudioSampleRange r)
 
void setAllowQuoting (bool q)
 
void setHeaderStatus (HeaderStatus s)
 
QList< ColumnPurposegetColumnPurposes () const
 
void setColumnPurposes (QList< ColumnPurpose > cl)
 
ColumnPurpose getColumnPurpose (int i) const
 
void setColumnPurpose (int i, ColumnPurpose p)
 
QList< ColumnQualitiesgetColumnQualities () const
 
QList< QStringList > getExample () const
 
int getMaxExampleCols () const
 

Protected Member Functions

void guessSeparator (QString line)
 
void guessQualities (QString line, int lineno)
 
void guessPurposes ()
 
void guessAudioSampleRange ()
 

Protected Attributes

ModelType m_modelType
 
TimingType m_timingType
 
TimeUnits m_timeUnits
 
QString m_separator
 
std::set< QChar > m_plausibleSeparators
 
sv_samplerate_t m_sampleRate
 
int m_windowSize
 
HeaderStatus m_headerStatus
 
int m_columnCount
 
bool m_variableColumnCount
 
std::map< int, ColumnQualitiesm_columnQualities
 
std::map< int, ColumnPurposem_columnPurposes
 
std::map< int, QString > m_columnHeadings
 
std::map< int, float > m_prevValues
 
AudioSampleRange m_audioSampleRange
 
bool m_allowQuoting
 
QList< QStringList > m_example
 
int m_maxExampleCols
 

Detailed Description

Definition at line 27 of file CSVFormat.h.

Member Typedef Documentation

typedef unsigned int CSVFormat::ColumnQualities

Definition at line 77 of file CSVFormat.h.

Member Enumeration Documentation

Enumerator
OneDimensionalModel 
TwoDimensionalModel 
TwoDimensionalModelWithDuration 
TwoDimensionalModelWithDurationAndPitch 
TwoDimensionalModelWithDurationAndExtent 
ThreeDimensionalModel 
WaveFileModel 

Definition at line 30 of file CSVFormat.h.

Enumerator
ExplicitTiming 
ImplicitTiming 

Definition at line 40 of file CSVFormat.h.

Enumerator
TimeSeconds 
TimeMilliseconds 
TimeAudioFrames 
TimeWindows 

Definition at line 45 of file CSVFormat.h.

Enumerator
ColumnUnknown 
ColumnStartTime 
ColumnEndTime 
ColumnDuration 
ColumnValue 
ColumnPitch 
ColumnLabel 

Definition at line 52 of file CSVFormat.h.

Enumerator
HeaderUnknown 
HeaderAbsent 
HeaderPresent 

Definition at line 62 of file CSVFormat.h.

Enumerator
ColumnNumeric 
ColumnIntegral 
ColumnIncreasing 
ColumnSmall 
ColumnLarge 
ColumnSigned 
ColumnNearEmpty 

Definition at line 68 of file CSVFormat.h.

Enumerator
SampleRangeSigned1 
SampleRangeUnsigned255 
SampleRangeSigned32767 
SampleRangeOther 

Definition at line 79 of file CSVFormat.h.

Constructor & Destructor Documentation

CSVFormat::CSVFormat ( )
inline

Definition at line 86 of file CSVFormat.h.

References guessFormatFor().

CSVFormat::CSVFormat ( QString  path)

Definition at line 30 of file CSVFormat.cpp.

References guessFormatFor().

Member Function Documentation

bool CSVFormat::guessFormatFor ( QString  path)

Guess the format of the given CSV file, setting the fields in this object accordingly.

If the current separator is the empty string, the separator character will also be guessed; otherwise the current separator will be used. The other properties of this object will be set according to guesses from the file.

The properties that are guessed from the file contents are: separator, column count, variable-column-count flag, audio sample range, timing type, time units, column qualities, column purposes, and model type. The sample rate and window size cannot be guessed and will not be changed by this function. Note also that this function will never guess WaveFileModel for the model type.

Return false if there is some fundamental error, e.g. the file could not be opened at all. Return true otherwise. Note that this function returns true even if the file doesn't appear to make much sense as a data format.

Definition at line 42 of file CSVFormat.cpp.

References ExplicitTiming, guessAudioSampleRange(), guessPurposes(), guessQualities(), m_columnCount, m_columnPurposes, m_columnQualities, m_example, m_maxExampleCols, m_modelType, m_prevValues, m_timeUnits, m_timingType, m_variableColumnCount, SVCERR, SVDEBUG, TimeSeconds, and TwoDimensionalModel.

Referenced by CSVFormat().

ModelType CSVFormat::getModelType ( ) const
inline

Definition at line 125 of file CSVFormat.h.

References m_modelType.

Referenced by CSVFileReader::load().

TimingType CSVFormat::getTimingType ( ) const
inline

Definition at line 126 of file CSVFormat.h.

References m_timingType.

Referenced by CSVFileReader::load().

TimeUnits CSVFormat::getTimeUnits ( ) const
inline

Definition at line 127 of file CSVFormat.h.

References m_timeUnits.

Referenced by CSVFileReader::convertTimeValue(), and CSVFileReader::load().

sv_samplerate_t CSVFormat::getSampleRate ( ) const
inline

Definition at line 128 of file CSVFormat.h.

References m_sampleRate.

Referenced by CSVFileReader::load().

int CSVFormat::getWindowSize ( ) const
inline

Definition at line 129 of file CSVFormat.h.

References m_windowSize.

Referenced by CSVFileReader::load().

int CSVFormat::getColumnCount ( ) const
inline

Definition at line 130 of file CSVFormat.h.

References m_columnCount.

Referenced by CSVFileReader::load().

AudioSampleRange CSVFormat::getAudioSampleRange ( ) const
inline

Definition at line 131 of file CSVFormat.h.

References m_audioSampleRange.

Referenced by CSVFileReader::load().

bool CSVFormat::getAllowQuoting ( ) const
inline

Definition at line 132 of file CSVFormat.h.

References m_allowQuoting.

Referenced by CSVFileReader::load().

HeaderStatus CSVFormat::getHeaderStatus ( ) const
inline

Definition at line 133 of file CSVFormat.h.

References m_headerStatus.

Referenced by CSVFileReader::load().

QChar CSVFormat::getSeparator ( ) const
inline

Definition at line 134 of file CSVFormat.h.

References m_separator.

Referenced by guessQualities(), and CSVFileReader::load().

std::set<QChar> CSVFormat::getPlausibleSeparators ( ) const
inline

Definition at line 139 of file CSVFormat.h.

References m_plausibleSeparators.

void CSVFormat::setModelType ( ModelType  t)
inline

Definition at line 143 of file CSVFormat.h.

References m_modelType.

void CSVFormat::setTimingType ( TimingType  t)
inline

Definition at line 144 of file CSVFormat.h.

References m_timingType.

void CSVFormat::setTimeUnits ( TimeUnits  t)
inline

Definition at line 145 of file CSVFormat.h.

References m_timeUnits.

void CSVFormat::setSeparator ( QChar  s)
inline

Definition at line 146 of file CSVFormat.h.

References m_separator.

void CSVFormat::setSampleRate ( sv_samplerate_t  r)
inline

Definition at line 147 of file CSVFormat.h.

References m_sampleRate.

void CSVFormat::setWindowSize ( int  s)
inline

Definition at line 148 of file CSVFormat.h.

References m_windowSize.

void CSVFormat::setColumnCount ( int  c)
inline

Definition at line 149 of file CSVFormat.h.

References m_columnCount.

void CSVFormat::setAudioSampleRange ( AudioSampleRange  r)
inline

Definition at line 150 of file CSVFormat.h.

References m_audioSampleRange.

void CSVFormat::setAllowQuoting ( bool  q)
inline

Definition at line 151 of file CSVFormat.h.

References m_allowQuoting.

void CSVFormat::setHeaderStatus ( HeaderStatus  s)
inline
QList< CSVFormat::ColumnPurpose > CSVFormat::getColumnPurposes ( ) const

Definition at line 535 of file CSVFormat.cpp.

References getColumnPurpose(), and m_columnCount.

Referenced by setHeaderStatus().

void CSVFormat::setColumnPurposes ( QList< ColumnPurpose cl)

Definition at line 545 of file CSVFormat.cpp.

References in_range_for(), and m_columnPurposes.

Referenced by setHeaderStatus().

CSVFormat::ColumnPurpose CSVFormat::getColumnPurpose ( int  i) const

Definition at line 554 of file CSVFormat.cpp.

References ColumnUnknown, and m_columnPurposes.

Referenced by getColumnPurposes(), CSVFileReader::load(), and setHeaderStatus().

void CSVFormat::setColumnPurpose ( int  i,
ColumnPurpose  p 
)

Definition at line 564 of file CSVFormat.cpp.

References m_columnPurposes.

Referenced by guessPurposes(), and setHeaderStatus().

QList< CSVFormat::ColumnQualities > CSVFormat::getColumnQualities ( ) const

Definition at line 570 of file CSVFormat.cpp.

References m_columnCount, and m_columnQualities.

Referenced by setHeaderStatus().

QList<QStringList> CSVFormat::getExample ( ) const
inline

Definition at line 164 of file CSVFormat.h.

References m_example.

int CSVFormat::getMaxExampleCols ( ) const
inline

Definition at line 165 of file CSVFormat.h.

References m_maxExampleCols.

void CSVFormat::guessSeparator ( QString  line)
protected

Definition at line 104 of file CSVFormat.cpp.

References m_allowQuoting, m_plausibleSeparators, m_separator, StringBits::split(), and SVDEBUG.

Referenced by guessQualities().

Member Data Documentation

ModelType CSVFormat::m_modelType
protected

Definition at line 168 of file CSVFormat.h.

Referenced by getModelType(), guessFormatFor(), guessPurposes(), and setModelType().

TimingType CSVFormat::m_timingType
protected

Definition at line 169 of file CSVFormat.h.

Referenced by getTimingType(), guessFormatFor(), guessPurposes(), and setTimingType().

TimeUnits CSVFormat::m_timeUnits
protected

Definition at line 170 of file CSVFormat.h.

Referenced by getTimeUnits(), guessFormatFor(), guessPurposes(), and setTimeUnits().

QString CSVFormat::m_separator
protected

Definition at line 171 of file CSVFormat.h.

Referenced by getSeparator(), guessSeparator(), and setSeparator().

std::set<QChar> CSVFormat::m_plausibleSeparators
protected

Definition at line 172 of file CSVFormat.h.

Referenced by getPlausibleSeparators(), and guessSeparator().

sv_samplerate_t CSVFormat::m_sampleRate
protected

Definition at line 173 of file CSVFormat.h.

Referenced by getSampleRate(), and setSampleRate().

int CSVFormat::m_windowSize
protected

Definition at line 174 of file CSVFormat.h.

Referenced by getWindowSize(), and setWindowSize().

HeaderStatus CSVFormat::m_headerStatus
protected

Definition at line 175 of file CSVFormat.h.

Referenced by getHeaderStatus(), guessQualities(), and setHeaderStatus().

int CSVFormat::m_columnCount
protected
bool CSVFormat::m_variableColumnCount
protected

Definition at line 178 of file CSVFormat.h.

Referenced by guessFormatFor(), and guessQualities().

std::map<int, ColumnQualities> CSVFormat::m_columnQualities
protected
std::map<int, ColumnPurpose> CSVFormat::m_columnPurposes
protected
std::map<int, QString> CSVFormat::m_columnHeadings
protected

Definition at line 182 of file CSVFormat.h.

Referenced by guessPurposes(), and guessQualities().

std::map<int, float> CSVFormat::m_prevValues
protected

Definition at line 184 of file CSVFormat.h.

Referenced by guessFormatFor(), and guessQualities().

AudioSampleRange CSVFormat::m_audioSampleRange
protected

Definition at line 186 of file CSVFormat.h.

Referenced by getAudioSampleRange(), guessAudioSampleRange(), and setAudioSampleRange().

bool CSVFormat::m_allowQuoting
protected

Definition at line 188 of file CSVFormat.h.

Referenced by getAllowQuoting(), guessQualities(), guessSeparator(), and setAllowQuoting().

QList<QStringList> CSVFormat::m_example
protected

Definition at line 190 of file CSVFormat.h.

Referenced by getExample(), guessFormatFor(), and guessQualities().

int CSVFormat::m_maxExampleCols
protected

Definition at line 191 of file CSVFormat.h.

Referenced by getMaxExampleCols(), guessFormatFor(), and guessQualities().


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