14#include "arcane/std/internal/TextWriter2.h"
16#include "arcane/utils/ArrayView.h"
17#include "arcane/utils/CheckedConvert.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/Ref.h"
21#include "arcane/utils/IDataCompressor.h"
23#include "arcane/core/ArcaneException.h"
41 std::ofstream m_ostream;
49TextWriter2(
const String& filename)
68_open(
const String& filename)
70 m_p->m_filename = filename;
71 std::ios::openmode mode = std::ios::out | std::ios::binary;
72 m_p->m_ostream.open(filename.
localstr(), mode);
82write(Span<const std::byte> values)
93 return m_p->m_filename;
97setDataCompressor(Ref<IDataCompressor> dc)
99 m_p->m_data_compressor = dc;
102Ref<IDataCompressor> TextWriter2::
103dataCompressor()
const
105 return m_p->m_data_compressor;
111 return m_p->m_ostream.tellp();
118_binaryWrite(Span<const std::byte> values)
120 std::ostream& o = m_p->m_ostream;
122 IDataCompressor* d = m_p->m_data_compressor.get();
123 if (d && values.size() > d->minCompressSize()) {
124 UniqueArray<std::byte> compressed_values;
125 m_p->m_data_compressor->compress(values, compressed_values);
126 Int64 compressed_size = compressed_values.largeSize();
138std::ostream& TextWriter2::
141 return m_p->m_ostream;
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
Information about the floating-point type.
Exception in a reader or writer.
Reference to an instance.
Unicode character string.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
std::int64_t Int64
Signed integer type of 64 bits.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of non-modifiable bytes.
void binaryWrite(std::ostream &ostr, const Span< const std::byte > &bytes)
Writes the content of bytes to the stream ostr in binary format.