Public Attributes | List of all members
moot::TokenWriter Class Reference

Abstract class for token output.

Inheritance diagram for moot::TokenWriter:
Inheritance graph
[legend]
Collaboration diagram for moot::TokenWriter:
Collaboration graph
[legend]

Public Member Functions

Constructors etc.
 TokenWriter (int fmt=tiofWellDone, const std::string &name="TokenWriter")
 
virtual ~TokenWriter (void)
 
Output Selection
virtual void to_mstream (mootio::mostream *mostreamp)
 
virtual void to_mstream (mootio::mostream &mos)
 
virtual void to_filename (const char *filename)
 
virtual void to_file (FILE *file)
 
virtual void to_fd (int fd)
 
virtual void to_cxxstream (std::ostream &os)
 
virtual void close (void)
 
virtual bool opened (void)
 
virtual bool flush (void)
 
bool autoflush (mootio::mostream *os)
 
Output Methods: Token-level
virtual void put_token (const mootToken &token)
 
virtual void put_tokens (const mootSentence &tokens)
 
virtual void put_sentence (const mootSentence &sentence)
 
Output Methods: Comments
virtual void put_comment_block_begin (void)
 
virtual void put_comment_block_end (void)
 
virtual void put_comment_buffer (const char *buf, size_t len)
 
virtual void put_comment (const char *s)
 
virtual void put_comment_buffer (const std::string &s)
 
virtual void printf_comment (const char *fmt,...)
 
Output Methods: Raw
virtual void put_raw_buffer (const char *buf, size_t len)
 
virtual void put_raw (const char *s)
 
virtual void put_raw (const std::string &s)
 
virtual void printf_raw (const char *fmt,...)
 
Diagnostics
virtual void writer_name (const std::string &myname)
 
virtual void carp (const char *fmt,...)
 

Public Attributes

int tw_format
 
std::string tw_name
 
mootio::mostreamtw_ostream
 
bool tw_ostream_created
 
bool tw_is_comment_block
 
void * tw_data
 

Additional Inherited Members

- Static Public Member Functions inherited from moot::TokenIO
static int parse_format_string (const std::string &fmtString)
 
static int guess_filename_format (const char *filename)
 
static bool is_empty_format (int fmt)
 
static int sanitize_format (int fmt, int fmt_implied=tiofNone, int fmt_default=tiofNone)
 
static int parse_format_request (const char *request, const char *filename=__null, int fmt_implied=tiofNone, int fmt_default=tiofNone)
 
static std::string format_canonical_string (int fmt)
 
static class TokenReadernew_reader (int fmt)
 
static class TokenWriternew_writer (int fmt)
 
static class TokenReaderfile_reader (const char *filename, const char *fmt_request=__null, int fmt_implied=tiofNone, int fmt_default=tiofNone)
 
static class TokenWriterfile_writer (const char *filename, const char *fmt_request=__null, int fmt_implied=tiofNone, int fmt_default=tiofNone)
 
static size_t pipe_tokens (class TokenReader *reader, class TokenWriter *writer)
 
static size_t pipe_sentences (class TokenReader *reader, class TokenWriter *writer)
 

Constructor & Destructor Documentation

◆ TokenWriter()

moot::TokenWriter::TokenWriter ( int  fmt = tiofWellDone,
const std::string &  name = "TokenWriter" 
)
inline

Default constructor

Parameters
fmtoutput format: should be a bitmask of TokenIOFormatE flags
namename of TokenWriter subtype for diagnostics

◆ ~TokenWriter()

virtual moot::TokenWriter::~TokenWriter ( void  )
inlinevirtual

Default destructor

Member Function Documentation

◆ to_mstream() [1/2]

virtual void moot::TokenWriter::to_mstream ( mootio::mostream mostreamp)
inlinevirtual

Select output to a mootio::mostream object, pointer version. This is the basic case. Descendendant classes may override this method.

Reimplemented in moot::TokenBuffer, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, moot::wasteDecoder, and moot::wasteTrainWriter.

References moot::tiofNull, and mootio::mstream::valid().

◆ to_mstream() [2/2]

virtual void moot::TokenWriter::to_mstream ( mootio::mostream mos)
inlinevirtual

Select output to a mootio::mistream object, reference version. Default implementation just calls to_mstream(&mos).

◆ to_filename()

virtual void moot::TokenWriter::to_filename ( const char *  filename)
inlinevirtual

Select output to a named file. Descendants using named file output may override this method. The filename "-" may be used to specify stdout.

References mootio::mstream::valid().

◆ to_file()

virtual void moot::TokenWriter::to_file ( FILE *  file)
inlinevirtual

Select output to a C stream. Caller is responsible for opening and closing the stream. Descendants using C stream output may override this method. Default implementation calls to_fd().

◆ to_fd()

virtual void moot::TokenWriter::to_fd ( int  fd)
inlinevirtual

Select output to a file descriptor. Caller is responsible for opening and closing the stream. Descendants using file descriptor may override this method. No default implementation.

◆ to_cxxstream()

virtual void moot::TokenWriter::to_cxxstream ( std::ostream &  os)
inlinevirtual

Select output to a C++ stream. Caller is responsible for allocation and de-allocation. Descendants using C++ stream input may override this method. Default implementation calls to_mstream().

◆ close()

virtual void moot::TokenWriter::close ( void  )
inlinevirtual

Finish output to currently selected sink & perform any required cleanup operations. This method should always be called before selecting a new output sink. The current output stream is only closed if it was created locally.

Descendants may override this method.

Reimplemented in moot::TokenBuffer, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, moot::wasteDecoder, and moot::wasteTrainWriter.

References mootio::mstream::close().

◆ opened()

virtual bool moot::TokenWriter::opened ( void  )
inlinevirtual

Test whether this writer is currently opened. Default just checks tr_istream && tr_istream->valid()

Reimplemented in moot::TokenBuffer.

References mootio::mstream::valid().

◆ flush()

virtual bool moot::TokenWriter::flush ( void  )
inlinevirtual

Flush currently selected output stream (wrapper for tw_ostream->flush()) .

References mootio::mostream::flush().

◆ autoflush()

bool moot::TokenWriter::autoflush ( mootio::mostream os)
inline

Flush stream os just in case moot::tiofFlush flag is set; os should be valid and non-NULL

References mootio::mostream::flush(), and moot::tiofFlush.

◆ put_token()

virtual void moot::TokenWriter::put_token ( const mootToken token)
inlinevirtual

Write a single token to the currently selected output sink. Descendants must override this method.

Reimplemented in moot::TokenBuffer, moot::TokenWriterNative, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, moot::wasteDecoder, and moot::wasteTrainWriter.

◆ put_tokens()

virtual void moot::TokenWriter::put_tokens ( const mootSentence tokens)
inlinevirtual

Write a single (partial) sentence to the currently selected output sink. Descendants may override this method. Default implementation just calls put_token() for every element of sentence.

Reimplemented in moot::TokenBuffer, moot::TokenWriterNative, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, and moot::wasteDecoder.

Referenced by moot::wasteTrainWriter::put_sentence().

◆ put_sentence()

virtual void moot::TokenWriter::put_sentence ( const mootSentence sentence)
inlinevirtual

Write a single sentence to the currently selected output sink. Descendants may override this method. Default implementation just calls put_sentence().

Reimplemented in moot::TokenBuffer, moot::TokenWriterNative, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, moot::wasteDecoder, and moot::wasteTrainWriter.

◆ put_comment_block_begin()

virtual void moot::TokenWriter::put_comment_block_begin ( void  )
inlinevirtual

Begin a comment block. This may effect behavior of subsequent put_raw_*() calls. Descendants using comments should override this method.

Reimplemented in moot::TokenWriterExpat.

◆ put_comment_block_end()

virtual void moot::TokenWriter::put_comment_block_end ( void  )
inlinevirtual

End a comment block. This may effect behavior of subsequent put_raw() calls. Descendants using comments should override this method.

Reimplemented in moot::TokenWriterExpat.

◆ put_comment_buffer() [1/2]

virtual void moot::TokenWriter::put_comment_buffer ( const char *  buf,
size_t  len 
)
inlinevirtual

Write a single comment to the currently selected output sink Descendants may override this method.

◆ put_comment()

virtual void moot::TokenWriter::put_comment ( const char *  s)
inlinevirtual

Write a single comment to the currently selected output sink Descendants may override this method.

◆ put_comment_buffer() [2/2]

virtual void moot::TokenWriter::put_comment_buffer ( const std::string &  s)
inlinevirtual

Write a single comment to the currently selected output sink Descendants may override this method.

◆ printf_comment()

virtual void moot::TokenWriter::printf_comment ( const char *  fmt,
  ... 
)
virtual

Write a comment to the currently selected output sink, printf() style. Descendants may override this method.

◆ put_raw_buffer()

virtual void moot::TokenWriter::put_raw_buffer ( const char *  buf,
size_t  len 
)
inlinevirtual

Write some data to the currently selected output sink Descendants may override this method.

Reimplemented in moot::TokenBuffer, moot::TokenWriterNative, moot::TokenWriterExpat, moot::wasteAnnotatorWriter, moot::wasteDecoder, and moot::wasteTrainWriter.

◆ put_raw() [1/2]

virtual void moot::TokenWriter::put_raw ( const char *  s)
inlinevirtual

Write some data to the currently selected output sink Descendants may override this method.

◆ put_raw() [2/2]

virtual void moot::TokenWriter::put_raw ( const std::string &  s)
inlinevirtual

Write some data to the currently selected output sink Descendants may override this method.

◆ printf_raw()

virtual void moot::TokenWriter::printf_raw ( const char *  fmt,
  ... 
)
virtual

Write some data to the currently selected output sink, printf() style. Descendants may override this method.

Referenced by moot::mootMIParser::tw_put_info(), moot::mootDynHMM::tw_put_info(), and moot::mootDynLexHMM_Boltzmann::tw_put_info().

◆ writer_name()

virtual void moot::TokenWriter::writer_name ( const std::string &  myname)
inlinevirtual

Set writer subtype name to use for diagnostics. Descendants may override this method.

◆ carp()

virtual void moot::TokenWriter::carp ( const char *  fmt,
  ... 
)
virtual

Complain

Member Data Documentation

◆ tw_format

int moot::TokenWriter::tw_format

Format flags: bitmask of moot::TokenIOFormat flags

◆ tw_name

std::string moot::TokenWriter::tw_name

Name of TokenWriter subtype for diagnostics

◆ tw_ostream

mootio::mostream* moot::TokenWriter::tw_ostream

Pointer to underlying mootio::mostream used for output

◆ tw_ostream_created

bool moot::TokenWriter::tw_ostream_created

Whether we created tw_ostream ourselves

◆ tw_is_comment_block

bool moot::TokenWriter::tw_is_comment_block

Whether we're in a comment-block

◆ tw_data

void* moot::TokenWriter::tw_data

User data associated with this writer object. Guaranteed to be unused by internal library routines. Useful e.g. for perl wrappers etc


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