<commit_before>/*
 * Copyright (c) 2017 <NAME>
 * This code is licensed under MIT license (see LICENSE for details).
 */

#ifndef VCF2MULTIALIGN_BIT_STRING_FILE_HH
#define VCF2MULTIALIGN_BIT_STRING_FILE_HH

#include <vcf2multialign/types.hh>


namespace vcf2multialign {

	class bit_string_file
	{
	protected:
		file_ostream	*m_stream{};
	
	public:
		bit_string_file() = default;

		bit_string_file(file_ostream &stream):
			m_stream(&stream)
		{
		}

		// Just write bytes for now.
		bool is_open() const				{ return m_stream && m_stream->is_open(); }
		void write_ones(std::size_t count)	{ std::fill_n(std::ostream_iterator <char>(*m_stream), count, '1'); }
		void write_zeros(std::size_t count)	{ std::fill_n(std::ostream_iterator <char>(*m_stream), count, '0'); }
		void flush()						{ *m_stream << std::flush; }
	};
}

#endif<commit_msg>Make the file closable<commit_after>/*
 * Copyright (c) 2017 <NAME>
 * This code is licensed under MIT license (see LICENSE for details).
 */

#ifndef VCF2MULTIALIGN_BIT_STRING_FILE_HH
#define VCF2MULTIALIGN_BIT_STRING_FILE_HH

#include <vcf2multialign/types.hh>


namespace vcf2multialign {

	class bit_string_file
	{
	protected:
		file_ostream	*m_stream{};
	
	public:
		bit_string_file() = default;

		bit_string_file(file_ostream &stream):
			m_stream(&stream)
		{
		}

		// Just write bytes for now.
		bool is_open() const				{ return m_stream && m_stream->is_open(); }
		void close()						{ if (m_stream) m_stream->close(); m_stream = nullptr; }
		void write_ones(std::size_t count)	{ std::fill_n(std::ostream_iterator <char>(*m_stream), count, '1'); }
		void write_zeros(std::size_t count)	{ std::fill_n(std::ostream_iterator <char>(*m_stream), count, '0'); }
		void flush()						{ *m_stream << std::flush; }
	};
}

#endif
{'fraction_non_alphanumeric': 0.1384180790960452, 'fraction_numerical': 0.011299435028248588, 'mean_word_length': 4.75, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2222079', 'n_tokens_mistral': 715, 'n_tokens_neox': 651, 'n_words': 139}