HFST - Helsinki Finite-State Transducer Technology - C++ API  version 3.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
HfstOutputStream Class Reference

A stream for writing binary transducers. More...

#include <HfstOutputStream.h>

Public Member Functions

HFSTDLL void close (void)
 Close the stream. More...
 
HFSTDLL HfstOutputStreamflush ()
 Flush the stream. More...
 
HFSTDLL HfstOutputStream (ImplementationType type, bool hfst_format=true)
 Create a stream to standard output for writing binary transducers of type type. hfst_format defines whether transducers are written in hfst format or as such in their backend format. More...
 
HFSTDLL HfstOutputStream (const std::string &filename, ImplementationType type, bool hfst_format=true)
 Open a stream to file filename for writing binary transducers of type type. hfst_format defines whether transducers are written in hfst format or as such in their backend format. More...
 
HFSTDLL HfstOutputStreamoperator<< (HfstTransducer &transducer)
 Write the transducer transducer in binary format to the stream. More...
 
HFSTDLL HfstOutputStreamredirect (HfstTransducer &transducer)
 An alias for operator<<. More...
 
HFSTDLL ~HfstOutputStream (void)
 Destructor. More...
 

Detailed Description

A stream for writing binary transducers.

An example:

#include "HfstOutputStream.h"

      ...

      // Write three HFST transducers in binary format to file named "testfile"
      HfstOutputStream out("testfile", FOMA_TYPE);
      out << foma_transducer1 
          << foma_transducer2 
          << foma_transducer3;
      out.close();

For more information on HFST transducer structure, see this page.

Constructor & Destructor Documentation

HfstOutputStream ( ImplementationType  type,
bool  hfst_format = true 
)

Create a stream to standard output for writing binary transducers of type type. hfst_format defines whether transducers are written in hfst format or as such in their backend format.

HfstOutputStream ( const std::string &  filename,
ImplementationType  type,
bool  hfst_format = true 
)

Open a stream to file filename for writing binary transducers of type type. hfst_format defines whether transducers are written in hfst format or as such in their backend format.

If the file exists, it is overwritten.

~HfstOutputStream ( void  )

Destructor.

Member Function Documentation

void close ( void  )

Close the stream.

If the stream points to standard output, nothing is done.

HfstOutputStream & flush ( )

Flush the stream.

If the stream is of XFSM_TYPE, all transducers inserted with the operator<< are actually written to the stream. Else, does nothing.

HfstOutputStream & operator<< ( HfstTransducer transducer)

Write the transducer transducer in binary format to the stream.

All transducers must have the same type as the stream, else a TransducerTypeMismatchException is thrown.

If the stream is of XFSM_TYPE, transducer is stored to a list and written when flush() is called for the stream.

Exceptions
TransducerTypeMismatchException
HfstOutputStream & redirect ( HfstTransducer transducer)

An alias for operator<<.

See also
operator<<

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