Skip to content
Snippets Groups Projects
Select Git revision
  • 90e06ab8a0c7cde8f9200ac4a4d01c927a6960b5
  • main default protected
  • change_data_model
  • feature/add_auth_asr_service
  • fix/incorrect_import
  • feature/change_registry_clarin
  • feature/add_base_asr_service
  • feature/add_poetry
  • feature/add_word_ids
  • feature/add_sziszapangma
10 results

configure_dvc.md

Blame
  • pathwriter.h 1.15 KiB
    #ifndef LIBSORPUS2_IO_PATHWRITER_H
    #define LIBCORPUS2_IO_PATHWRITER_H
    
    #include <libcorpus2/io/writer.h>
    #include <boost/scoped_ptr.hpp>
    
    namespace Corpus2 {
    
    /**
     * A wrapper class for the output stream Writers that holds an open stream
     * and closes it on destruction. All write calls are passed to the
     * wrapped Writer.
     */
    class PathWriter : public TokenWriter
    {
    public:
    	/**
    	 * The constructor. It is assumed that the underlying writer operates
    	 * on the same ostream as the pointer passed.
    	 */
    	PathWriter(const boost::shared_ptr<TokenWriter>& underlying,
    			const boost::shared_ptr<std::ostream>& os);
    
    	~PathWriter();
    
    	void write_token(const Token& t);
    
    	virtual void write_sentence(const Sentence& s);
    
    	virtual void write_chunk(const Chunk& p);
    
    	boost::shared_ptr<TokenWriter> get_underlying() {
    		return underlying_;
    	}
    
    	boost::shared_ptr<std::ostream> get_ostream_pointer() {
    		return os_;
    	}
    
    protected:
    	/// The owned ostream pointer
    	boost::shared_ptr<std::ostream> os_;
    	/// The wrapped Writer (Note: must come after the ostream ptr in the class!)
    	boost::shared_ptr<TokenWriter> underlying_;
    };
    
    } /* end ns Corpus2 */
    
    #endif // LIBCORPUS2_IO_PATHWRITER_H