14#include "arcane/std/internal/BasicWriter.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/IDataCompressor.h"
18#include "arcane/utils/JSONWriter.h"
19#include "arcane/utils/Ref.h"
21#include "arcane/core/IXmlDocumentHolder.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/IIOMng.h"
24#include "arcane/core/IApplication.h"
25#include "arcane/core/ISerializedData.h"
26#include "arcane/core/IRessourceMng.h"
27#include "arcane/core/ItemGroup.h"
39BasicGenericWriter(IApplication* app,
Int32 version,
40 Ref<KeyValueTextWriter> text_writer)
41: TraceAccessor(app->traceMng())
44, m_text_writer(text_writer)
51void BasicGenericWriter::
52initialize(
const String& path,
Int32 rank)
63void BasicGenericWriter::
73 <<
" dim=" <<
sdata->nbDimension() <<
" datatype=" <<
sdata->baseDataType()
74 <<
" nb_basic_element=" <<
sdata->nbBaseElement()
75 <<
" is_multi=" <<
sdata->isMultiSize()
76 <<
" dimensions_size=" <<
sdata->extents().size()
77 <<
" memory_size=" <<
sdata->memorySize()
78 <<
" bytes_size=" <<
sdata->constBytes().size();
81 const void*
ptr =
sdata->constBytes().data();
99void BasicGenericWriter::
103 if (m_version >= 3) {
120 String filename = BasicReaderWriterCommon::_getBasicGroupFile(m_path, group_full_name, m_rank);
121 ofstream writer(filename.localstr(),std::ios::out | std::ios::binary);
125 Integer nb_unique_id = written_unique_ids.size();
132 Integer nb_unique_id = wanted_unique_ids.size();
141void BasicGenericWriter::
144 IApplication* app = m_application;
145 ScopedPtrT<IXmlDocumentHolder> xdoc(app->ressourceMng()->createXmlDocument());
146 XmlNode doc = xdoc->documentNode();
147 XmlElement root(doc,
"variables-data");
148 const IDataCompressor* dc = m_text_writer->dataCompressor().get();
150 root.setAttrValue(
"deflater-service", dc->name());
151 root.setAttrValue(
"min-compress-size", String::fromNumber(dc->minCompressSize()));
153 root.setAttrValue(
"version", String::fromNumber(m_version));
156 JSONWriter::Object main_object(jsw);
157 JSONWriter::Object json_vars(jsw,
"Variables");
158 for (
const auto& i : m_variables_data_info) {
159 Ref<VariableDataInfo> vdi = i.second;
160 XmlNode e = root.createAndAppendElement(
"variable-data");
161 e.setAttrValue(
"full-name", vdi->fullName());
165 if (m_version >= 3) {
167 XmlElement json_var(root,
"variables-data-json", jsw.getBuffer());
170 UniqueArray<Byte> bytes;
172 Int64 length = bytes.length();
173 String key_name =
"Global:OwnMetadata";
175 m_text_writer->write(key_name,
asBytes(bytes.span()));
178 String filename = BasicReaderWriterCommon::_getOwnMetatadaFile(m_path, m_rank);
179 app->ioMng()->writeXmlFile(xdoc.get(), filename);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'une donnée sérialisée.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Vue constante d'un tableau de type T.
Chaîne de caractères unicode.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Int32 Integer
Type représentant un entier.
detail::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets non modifiables.
void binaryWrite(std::ostream &ostr, const Span< const std::byte > &bytes)
Ecrit en binaire le contenu de bytes sur le flot ostr.