<commit_before>#ifndef AFT_MTP_PTP_MEMORYOBJECTSTREAM_H
#define AFT_MTP_PTP_MEMORYOBJECTSTREAM_H

#include <mtp/ByteArray.h>
#include <mtp/ptp/IObjectStream.h>

namespace mtp
{
	class MemoryObjectOutputStream :
		public IObjectOutputStream,
		public CancellableStream
	{
		ByteArray _data;

		size_t Write(const u8 *data, size_t size) override
		{
			auto offset = _data.size();
			_data.resize(offset + size);
			std::copy(data, data + size, _data.data() + offset);
			return size;
		}

		const ByteArray & GetData() const
		{ return _data; }
	};
}

#endif<commit_msg>use shared pointer to bytearray in outputstream<commit_after>#ifndef AFT_MTP_PTP_MEMORYOBJECTSTREAM_H
#define AFT_MTP_PTP_MEMORYOBJECTSTREAM_H

#include <mtp/ByteArray.h>
#include <mtp/ptp/IObjectStream.h>

namespace mtp
{
	class MemoryObjectOutputStream :
		public IObjectOutputStream,
		public CancellableStream
	{
		ByteArrayPtr _data;

	public:
		MemoryObjectOutputStream(): _data(new ByteArray()) { }

		size_t Write(const u8 *data, size_t size) override
		{
			auto & storage = *_data;
			auto offset = storage.size();
			storage.resize(offset + size);
			std::copy(data, data + size, storage.data() + offset);
			return size;
		}

		const ByteArrayPtr & GetData() const
		{ return _data; }
	};
}

#endif
{'fraction_non_alphanumeric': 0.10476935105551212, 'fraction_numerical': 0.001563721657544957, 'mean_word_length': 4.638766519823789, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5899882', 'n_tokens_mistral': 493, 'n_tokens_neox': 447, 'n_words': 100}