VectorFstTplHolder< Arc > Class Template Reference

#include <kaldi-fst-io.h>

Collaboration diagram for VectorFstTplHolder< Arc >:

Public Types

typedef VectorFst< Arc > T
 

Public Member Functions

 VectorFstTplHolder ()
 
void Copy (const T &t)
 
bool Read (std::istream &is)
 
TValue ()
 
void Clear ()
 
void Swap (VectorFstTplHolder< Arc > *other)
 
bool ExtractRange (const VectorFstTplHolder< Arc > &other, const std::string &range)
 
 ~VectorFstTplHolder ()
 

Static Public Member Functions

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

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (VectorFstTplHolder)
 

Private Attributes

Tt_
 

Detailed Description

template<class Arc>
class fst::VectorFstTplHolder< Arc >

Definition at line 96 of file kaldi-fst-io.h.

Member Typedef Documentation

◆ T

typedef VectorFst<Arc> T

Definition at line 98 of file kaldi-fst-io.h.

Constructor & Destructor Documentation

◆ VectorFstTplHolder()

VectorFstTplHolder ( )
inline

Definition at line 100 of file kaldi-fst-io.h.

References VectorFstTplHolder< Arc >::Write().

100 : t_(NULL) { }

◆ ~VectorFstTplHolder()

Member Function Documentation

◆ Clear()

void Clear ( )
inline

Definition at line 125 of file kaldi-fst-io.h.

References VectorFstTplHolder< Arc >::t_.

Referenced by VectorFstTplHolder< Arc >::Copy(), and VectorFstTplHolder< Arc >::~VectorFstTplHolder().

125  {
126  if (t_) {
127  delete t_;
128  t_ = NULL;
129  }
130  }

◆ Copy()

void Copy ( const T t)
inline

Definition at line 104 of file kaldi-fst-io.h.

References VectorFstTplHolder< Arc >::Clear(), VectorFstTplHolder< Arc >::Read(), and VectorFstTplHolder< Arc >::t_.

104  { // copies it into the holder.
105  Clear();
106  t_ = new T(t);
107  }
VectorFst< Arc > T
Definition: kaldi-fst-io.h:98

◆ ExtractRange()

bool ExtractRange ( const VectorFstTplHolder< Arc > &  other,
const std::string &  range 
)
inline

Definition at line 136 of file kaldi-fst-io.h.

References KALDI_ERR.

137  {
138  KALDI_ERR << "ExtractRange is not defined for this type of holder.";
139  return false;
140  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ IsReadInBinary()

static bool IsReadInBinary ( )
inlinestatic

Definition at line 117 of file kaldi-fst-io.h.

117 { return true; }

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( VectorFstTplHolder< Arc >  )
private

◆ Read()

bool Read ( std::istream &  is)

Definition at line 180 of file kaldi-fst-io-inl.h.

References KALDI_WARN, and fst::ReadFstKaldi().

Referenced by VectorFstTplHolder< Arc >::Copy().

180  {
181  Clear();
182  int c = is.peek();
183  if (c == -1) {
184  KALDI_WARN << "End of stream detected reading Fst";
185  return false;
186  } else if (isspace(c)) { // The text form of the FST begins
187  // with space (normally, '\n'), so this means it's text (the binary form
188  // cannot begin with space because it starts with the FST Type() which is not
189  // space).
190  try {
191  t_ = new VectorFst<Arc>();
192  ReadFstKaldi(is, false, t_);
193  } catch (...) {
194  Clear();
195  return false;
196  }
197  } else { // reading a binary FST.
198  try {
199  t_ = new VectorFst<Arc>();
200  ReadFstKaldi(is, true, t_);
201  } catch (...) {
202  Clear();
203  return false;
204  }
205  }
206  return true;
207 }
#define KALDI_WARN
Definition: kaldi-error.h:150
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)

◆ Swap()

void Swap ( VectorFstTplHolder< Arc > *  other)
inline

Definition at line 132 of file kaldi-fst-io.h.

References kaldi::swap(), and VectorFstTplHolder< Arc >::t_.

132  {
133  std::swap(t_, other->t_);
134  }
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)

◆ Value()

T& Value ( )
inline

Definition at line 119 of file kaldi-fst-io.h.

References KALDI_ERR, and VectorFstTplHolder< Arc >::t_.

119  {
120  // code error if !t_.
121  if (!t_) KALDI_ERR << "VectorFstTplHolder::Value() called wrongly.";
122  return *t_;
123  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ Write()

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

Definition at line 170 of file kaldi-fst-io-inl.h.

References fst::WriteFstKaldi().

Referenced by VectorFstTplHolder< Arc >::VectorFstTplHolder().

170  {
171  try {
172  WriteFstKaldi(os, binary, t);
173  return true;
174  } catch (...) {
175  return false;
176  }
177 }
void WriteFstKaldi(std::ostream &os, bool binary, const VectorFst< Arc > &t)

Member Data Documentation

◆ t_


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