List of all members
moot::TokenIO Class Reference

Abstract class for token I/O.

Inheritance diagram for moot::TokenIO:
Inheritance graph
[legend]

Static Public Member Functions

Format String <-> Bitmask Utilities
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)
 
Format-Based Reader/Writer Creation
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)
 
Token-Stream Pipeline Utilities
static size_t pipe_tokens (class TokenReader *reader, class TokenWriter *writer)
 
static size_t pipe_sentences (class TokenReader *reader, class TokenWriter *writer)
 

Member Function Documentation

◆ parse_format_string()

static int moot::TokenIO::parse_format_string ( const std::string &  fmtString)
static

Parse a format string, which should be a comma-separated list of moot::TokenIOFormat flag-names (without the 'tiof' prefix, matching is case-insensitive). A prefix of '!' indicates negation of the given flag. Returns the corresponding bitmask.

See also
parse_format_request

◆ guess_filename_format()

static int moot::TokenIO::guess_filename_format ( const char *  filename)
static

Guess basic format flags from a filename based on dot-separated extension substrings. Returns a bitmask suitable for passing to sanitize_format(). Recognizes filename extensions as documented in mootfiles(5).

See also
parse_format_request

◆ is_empty_format()

static bool moot::TokenIO::is_empty_format ( int  fmt)
static

Returns true iff no information content is requested by fmt.

See also
parse_format_request

◆ sanitize_format()

static int moot::TokenIO::sanitize_format ( int  fmt,
int  fmt_implied = tiofNone,
int  fmt_default = tiofNone 
)
static

Sanity check for format bitmasks.

See also
parse_format_request

◆ parse_format_request()

static int moot::TokenIO::parse_format_request ( const char *  request,
const char *  filename = __null,
int  fmt_implied = tiofNone,
int  fmt_default = tiofNone 
)
static

Top-level format-instantiation utility.

Parameters
requestuser-requested format string, has highest priority
filenamefilename used to guess basic format flags (only used if request is NULL or empty)
fmt_impliedimplied format bitmask (required information content)
fmt_defaultdefault format bitmask (for empty formats)

◆ format_canonical_string()

static std::string moot::TokenIO::format_canonical_string ( int  fmt)
static

Convert a format bitmask to a canonical string form.

◆ new_reader()

static class TokenReader* moot::TokenIO::new_reader ( int  fmt)
static

Create a new TokenReader object suitable for reading the format fmt.

Parameters
fmta bitmask composed of moot::TokenIOFormat flags.
Warning
Caller is responsible for deleting the object returned.

◆ new_writer()

static class TokenWriter* moot::TokenIO::new_writer ( int  fmt)
static

Create a new moot::TokenWriter object suitable for writing the format fmt.

Parameters
fmta bitmask composed of moot::TokenIOFormat flags.
Warning
caller is responsible for delting the object returned.

◆ file_reader()

static class TokenReader* moot::TokenIO::file_reader ( const char *  filename,
const char *  fmt_request = __null,
int  fmt_implied = tiofNone,
int  fmt_default = tiofNone 
)
static

Create a new TokenReader object for reading from the file filename. Wrapper for new_reader(parse_format_request(request,filename,fmt_implied,fmt_default)).from_filename(filename)

Parameters
filenamefilename from which to read, will be opened with TokenReader::from_filename()
fmt_requestformat request (overrides filename heuristics)
fmt_impliedimplied format flags
fmt_defaultdefault format flags
Returns
new TokenReader for filename, or NULL if something went wrong.
Warning
Caller is responsible for deleting the object returned.

◆ file_writer()

static class TokenWriter* moot::TokenIO::file_writer ( const char *  filename,
const char *  fmt_request = __null,
int  fmt_implied = tiofNone,
int  fmt_default = tiofNone 
)
static

Create a new TokenWriter object for writing to the file filename. Wrapper for new_writer(parse_format_request(request,filename,fmt_implied,fmt_default)).to_filename(filename)

Parameters
filenamefile to be written, will be opened with TokenWriter::to_filename()
fmt_requestformat request (overrides filename heuristics)
fmt_impliedimplied format flags
fmt_defaultdefault format flags
Returns
new TokenWriter for filename, or NULL if something went wrong.
Warning
Caller is responsible for deleting the object returned.

◆ pipe_tokens()

static size_t moot::TokenIO::pipe_tokens ( class TokenReader reader,
class TokenWriter writer 
)
static

Pipes tokens from reader to writer using reader->get_token() and writer->put_token().

Returns
number of tokens copied.

◆ pipe_sentences()

static size_t moot::TokenIO::pipe_sentences ( class TokenReader reader,
class TokenWriter writer 
)
static

Pipes sentences from reader to writer using reader->get_sentence() and writer->put_sentence()

Returns
number of sentences copied.

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