All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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)
 
const 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 92 of file kaldi-fst-io.h.

Member Typedef Documentation

typedef VectorFst<Arc> T

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

Constructor & Destructor Documentation

VectorFstTplHolder ( )
inline

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

96 : t_(NULL) { }
~VectorFstTplHolder ( )
inline

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

References VectorFstTplHolder< Arc >::Clear().

138 { Clear(); }

Member Function Documentation

void Clear ( )
inline

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

References VectorFstTplHolder< Arc >::t_.

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

121  {
122  if (t_) {
123  delete t_;
124  t_ = NULL;
125  }
126  }
void Copy ( const T t)
inline

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

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

100  { // copies it into the holder.
101  Clear();
102  t_ = new T(t);
103  }
VectorFst< Arc > T
Definition: kaldi-fst-io.h:94
bool ExtractRange ( const VectorFstTplHolder< Arc > &  other,
const std::string &  range 
)
inline

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

References KALDI_ERR.

133  {
134  KALDI_ERR << "ExtractRange is not defined for this type of holder.";
135  return false;
136  }
#define KALDI_ERR
Definition: kaldi-error.h:127
static bool IsReadInBinary ( )
inlinestatic

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

113 { return true; }
KALDI_DISALLOW_COPY_AND_ASSIGN ( VectorFstTplHolder< Arc >  )
private
bool Read ( std::istream &  is)

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

References KALDI_WARN, and fst::ReadFstKaldi().

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:130
void ReadFstKaldi(std::istream &is, bool binary, VectorFst< Arc > *fst)
void Swap ( VectorFstTplHolder< Arc > *  other)
inline

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

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

128  {
129  std::swap(t_, other->t_);
130  }
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
const T& Value ( )
inline

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

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

115  {
116  // code error if !t_.
117  if (!t_) KALDI_ERR << "VectorFstTplHolder::Value() called wrongly.";
118  return *t_;
119  }
#define KALDI_ERR
Definition: kaldi-error.h:127
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().

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


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