WaveHolder Class Reference

#include <wave-reader.h>

Collaboration diagram for WaveHolder:

Public Types

typedef WaveData T
 

Public Member Functions

void Copy (const T &t)
 
void Clear ()
 
TValue ()
 
WaveHolderoperator= (const WaveHolder &other)
 
 WaveHolder (const WaveHolder &other)
 
 WaveHolder ()
 
bool Read (std::istream &is)
 
void Swap (WaveHolder *other)
 
bool ExtractRange (const WaveHolder &other, const std::string &range)
 

Static Public Member Functions

static bool Write (std::ostream &os, bool binary, const T &t)
 
static bool IsReadInBinary ()
 

Private Attributes

T t_
 

Detailed Description

Definition at line 158 of file wave-reader.h.

Member Typedef Documentation

◆ T

typedef WaveData T

Definition at line 160 of file wave-reader.h.

Constructor & Destructor Documentation

◆ WaveHolder() [1/2]

WaveHolder ( const WaveHolder other)
inline

Definition at line 187 of file wave-reader.h.

187 : t_(other.t_) {}

◆ WaveHolder() [2/2]

WaveHolder ( )
inline

Definition at line 189 of file wave-reader.h.

189 {}

Member Function Documentation

◆ Clear()

void Clear ( )
inline

Definition at line 179 of file wave-reader.h.

179 { t_.Clear(); }

◆ Copy()

void Copy ( const T t)
inline

Definition at line 175 of file wave-reader.h.

175 { t_.CopyFrom(t); }
void CopyFrom(const WaveData &other)
Definition: wave-reader.h:131

◆ ExtractRange()

bool ExtractRange ( const WaveHolder other,
const std::string &  range 
)
inline

Definition at line 206 of file wave-reader.h.

References KALDI_ERR.

206  {
207  KALDI_ERR << "ExtractRange is not defined for this type of holder.";
208  return false;
209  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ IsReadInBinary()

static bool IsReadInBinary ( )
inlinestatic

Definition at line 177 of file wave-reader.h.

177 { return true; }

◆ operator=()

WaveHolder& operator= ( const WaveHolder other)
inline

Definition at line 183 of file wave-reader.h.

References WaveHolder::t_.

183  {
184  t_.CopyFrom(other.t_);
185  return *this;
186  }
void CopyFrom(const WaveData &other)
Definition: wave-reader.h:131

◆ Read()

bool Read ( std::istream &  is)
inline

Definition at line 191 of file wave-reader.h.

References KALDI_WARN.

Referenced by main().

191  {
192  // We don't look for the binary-mode header here [always binary]
193  try {
194  t_.Read(is); // Throws exception on failure.
195  return true;
196  } catch (const std::exception &e) {
197  KALDI_WARN << "Exception caught in WaveHolder::Read(). " << e.what();
198  return false;
199  }
200  }
void Read(std::istream &is)
Read() will throw on error.
Definition: wave-reader.cc:272
#define KALDI_WARN
Definition: kaldi-error.h:150

◆ Swap()

void Swap ( WaveHolder other)
inline

Definition at line 202 of file wave-reader.h.

References WaveHolder::t_.

202  {
203  t_.Swap(&(other->t_));
204  }
void Swap(WaveData *other)
Definition: wave-reader.h:141

◆ Value()

T& Value ( )
inline

Definition at line 181 of file wave-reader.h.

Referenced by main().

181 { return t_; }

◆ Write()

static bool Write ( std::ostream &  os,
bool  binary,
const T t 
)
inlinestatic

Definition at line 162 of file wave-reader.h.

References KALDI_ERR, KALDI_WARN, and WaveData::Write().

Referenced by main().

162  {
163  // We don't write the binary-mode header here [always binary].
164  if (!binary)
165  KALDI_ERR << "Wave data can only be written in binary mode.";
166  try {
167  t.Write(os); // throws exception on failure.
168  return true;
169  } catch (const std::exception &e) {
170  KALDI_WARN << "Exception caught in WaveHolder object (writing). "
171  << e.what();
172  return false; // write failure.
173  }
174  }
#define KALDI_ERR
Definition: kaldi-error.h:147
#define KALDI_WARN
Definition: kaldi-error.h:150

Member Data Documentation

◆ t_

T t_
private

Definition at line 212 of file wave-reader.h.

Referenced by WaveHolder::operator=(), and WaveHolder::Swap().


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