All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TokenHolder Class Reference

#include <kaldi-holder-inl.h>

Collaboration diagram for TokenHolder:

Public Types

typedef std::string T
 

Public Member Functions

 TokenHolder ()
 
void Clear ()
 
bool Read (std::istream &is)
 
TValue ()
 
 ~TokenHolder ()
 
void Swap (TokenHolder *other)
 
bool ExtractRange (const TokenHolder &other, const std::string &range)
 

Static Public Member Functions

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

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (TokenHolder)
 

Private Attributes

T t_
 

Detailed Description

Definition at line 639 of file kaldi-holder-inl.h.

Member Typedef Documentation

typedef std::string T

Definition at line 641 of file kaldi-holder-inl.h.

Constructor & Destructor Documentation

TokenHolder ( )
inline

Definition at line 643 of file kaldi-holder-inl.h.

643 {}
~TokenHolder ( )
inline

Definition at line 676 of file kaldi-holder-inl.h.

676 { }

Member Function Documentation

void Clear ( )
inline

Definition at line 651 of file kaldi-holder-inl.h.

References TokenHolder::t_.

651 { t_.clear(); }
bool ExtractRange ( const TokenHolder other,
const std::string &  range 
)
inline

Definition at line 682 of file kaldi-holder-inl.h.

References KALDI_ERR.

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

Definition at line 672 of file kaldi-holder-inl.h.

672 { return false; }
KALDI_DISALLOW_COPY_AND_ASSIGN ( TokenHolder  )
private
bool Read ( std::istream &  is)
inline

Definition at line 654 of file kaldi-holder-inl.h.

References kaldi::CharToString(), KALDI_WARN, and TokenHolder::t_.

654  {
655  is >> t_;
656  if (is.fail()) return false;
657  char c;
658  while (isspace(c = is.peek()) && c!= '\n') is.get();
659  if (is.peek() != '\n') {
660  KALDI_WARN << "TokenHolder::Read, expected newline, got char "
661  << CharToString(is.peek())
662  << ", at stream pos " << is.tellg();
663  return false;
664  }
665  is.get(); // get '\n'
666  return true;
667  }
#define KALDI_WARN
Definition: kaldi-error.h:130
std::string CharToString(const char &c)
Definition: kaldi-utils.cc:36
void Swap ( TokenHolder other)
inline

Definition at line 678 of file kaldi-holder-inl.h.

References TokenHolder::t_.

678  {
679  t_.swap(other->t_);
680  }
T& Value ( )
inline

Definition at line 674 of file kaldi-holder-inl.h.

References TokenHolder::t_.

674 { return t_; }
static bool Write ( std::ostream &  os,
bool  ,
const T t 
)
inlinestatic

Definition at line 645 of file kaldi-holder-inl.h.

References kaldi::IsToken(), and KALDI_ASSERT.

645  { // ignore binary-mode
646  KALDI_ASSERT(IsToken(t));
647  os << t << '\n';
648  return os.good();
649  }
bool IsToken(const std::string &token)
Returns true if "token" is nonempty, and all characters are printable and whitespace-free.
Definition: text-utils.cc:105
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:169

Member Data Documentation

T t_
private

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