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)
 
const TValue () const
 
 ~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 636 of file kaldi-holder-inl.h.

Member Typedef Documentation

typedef std::string T

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

Constructor & Destructor Documentation

TokenHolder ( )
inline

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

640 {}
~TokenHolder ( )
inline

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

673 { }

Member Function Documentation

void Clear ( )
inline

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

References TokenHolder::t_.

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

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

References KALDI_ERR.

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

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

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

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

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

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

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

References TokenHolder::t_.

675  {
676  t_.swap(other->t_);
677  }
const T& Value ( ) const
inline

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

References TokenHolder::t_.

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

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

References kaldi::IsToken(), and KALDI_ASSERT.

642  { // ignore binary-mode
643  KALDI_ASSERT(IsToken(t));
644  os << t << '\n';
645  return os.good();
646  }
bool IsToken(const std::string &token)
Returns true if "token" is nonempty, and all characters are printable and whitespace-free.
Definition: text-utils.cc:103
#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: