StandardOutputImpl Class Reference
Inheritance diagram for StandardOutputImpl:
Collaboration diagram for StandardOutputImpl:

Public Member Functions

 StandardOutputImpl ()
 
virtual bool Open (const std::string &filename, bool binary)
 
virtual std::ostream & Stream ()
 
virtual bool Close ()
 
virtual ~StandardOutputImpl ()
 
- Public Member Functions inherited from OutputImplBase
virtual ~OutputImplBase ()
 

Private Attributes

bool is_open_
 

Detailed Description

Definition at line 237 of file kaldi-io.cc.

Constructor & Destructor Documentation

◆ StandardOutputImpl()

StandardOutputImpl ( )
inline

Definition at line 239 of file kaldi-io.cc.

239 : is_open_(false) { }

◆ ~StandardOutputImpl()

virtual ~StandardOutputImpl ( )
inlinevirtual

Definition at line 265 of file kaldi-io.cc.

References KALDI_ERR.

265  {
266  if (is_open_) {
267  std::cout << std::flush;
268  if (std::cout.fail())
269  KALDI_ERR << "Error writing to standard output";
270  }
271  }
#define KALDI_ERR
Definition: kaldi-error.h:147

Member Function Documentation

◆ Close()

virtual bool Close ( )
inlinevirtual

Implements OutputImplBase.

Definition at line 258 of file kaldi-io.cc.

References KALDI_ERR.

258  {
259  if (!is_open_)
260  KALDI_ERR << "StandardOutputImpl::Close(), file is not open.";
261  is_open_ = false;
262  std::cout << std::flush;
263  return !(std::cout.fail());
264  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ Open()

virtual bool Open ( const std::string &  filename,
bool  binary 
)
inlinevirtual

Implements OutputImplBase.

Definition at line 241 of file kaldi-io.cc.

References KALDI_ERR.

241  {
242  if (is_open_) KALDI_ERR << "StandardOutputImpl::Open(), "
243  "open called on already open file.";
244 #ifdef _MSC_VER
245  _setmode(_fileno(stdout), binary ? _O_BINARY : _O_TEXT);
246 #endif
247  is_open_ = std::cout.good();
248  return is_open_;
249  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ Stream()

virtual std::ostream& Stream ( )
inlinevirtual

Implements OutputImplBase.

Definition at line 251 of file kaldi-io.cc.

References KALDI_ERR.

251  {
252  if (!is_open_)
253  KALDI_ERR << "StandardOutputImpl::Stream(), object not initialized.";
254  // I believe this error can only arise from coding error.
255  return std::cout;
256  }
#define KALDI_ERR
Definition: kaldi-error.h:147

Member Data Documentation

◆ is_open_

bool is_open_
private

Definition at line 273 of file kaldi-io.cc.


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