14#include "arcane/utils/ArcanePrecomp.h"
15#include "arcane/utils/JSONWriter.h"
16#include "arcane/utils/ArrayView.h"
17#include "arcane/utils/String.h"
18#include "arcane/utils/FatalErrorException.h"
22#define RAPIDJSON_NO_SIZETYPEDEFINE
25#define RAPIDJSON_HAS_STDSTRING 1
26#include "arcane/utils/internal/json/rapidjson/writer.h"
27#include "arcane/utils/internal/json/rapidjson/prettywriter.h"
29#include "arcane/utils/internal/json/rapidjson/stringbuffer.h"
50 m_writer.SetIndent(
' ',1);
51 m_writer.SetFormatOptions(rapidjson::kFormatSingleLineArray);
58 Int64 size = bytes.size();
62 m_writer.Key((
const char*)bytes.data(),size,
true);
67 Int64 size = bytes.size();
73 m_writer.String((
const char*)bytes.data(),size,
true);
75 void writeStringValue(
const std::string& value)
77 m_writer.String(value);
95 m_real_ostr.str(std::string());
101 for( Int64 i=0, n=view.size(); i<n; ++i ){
104 if (m_use_hex_float){
109 m_real_ostr << view[i];
111 writeStringValue(m_real_ostr.str());
115 rapidjson::StringBuffer m_buffer;
116 rapidjson::PrettyWriter<rapidjson::StringBuffer> m_writer;
117 bool m_use_hex_float;
118 std::ostringstream m_real_ostr;
141 m_p->m_writer.StartObject();
146 m_p->m_writer.EndObject();
149writeKey(StringView key)
156 m_p->m_writer.StartArray();
161 m_p->m_writer.EndArray();
165writeValue(StringView str)
167 m_p->writeStringValue(str);
170write(StringView key,
bool v)
173 m_p->m_writer.Bool(v);
176_writeInt64(StringView key,
Int64 v)
179 m_p->m_writer.Int64(v);
182_writeUInt64(StringView key,UInt64 v)
185 m_p->m_writer.Uint64(v);
188write(StringView key,
Real v)
193write(StringView key,StringView str)
196 m_p->writeStringValue(str);
199write(StringView key,
const char* v)
202 m_p->writeStringValue(StringView(v));
205write(StringView key,std::string_view v)
208 m_p->writeStringValue(v);
211writeIfNotNull(StringView key,
const String& str)
216 m_p->writeStringValue(str);
220write(StringView key,Span<const Int32> view)
223 m_p->m_writer.StartArray();
224 for(
Int64 i=0, n=view.size(); i<n; ++i )
225 m_p->m_writer.Int(view[i]);
226 m_p->m_writer.EndArray();
230write(StringView key,Span<const Int64> view)
233 m_p->m_writer.StartArray();
234 for(
Int64 i=0, n=view.size(); i<n; ++i )
235 m_p->m_writer.Int64(view[i]);
236 m_p->m_writer.EndArray();
240write(StringView key,Span<const Real> view)
242 m_p->write(key,view);
248StringView JSONWriter::
251 const Byte* buf_chars =
reinterpret_cast<const Byte*
>(m_p->m_buffer.GetString());
252 Span<const Byte> bytes(buf_chars,m_p->m_buffer.GetSize());
253 return StringView(bytes);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Informations sur le type flottant.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Vue sur une chaîne de caractères UTF-8.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Retourne la conversion de l'instance dans l'encodage UTF-8.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
unsigned char Byte
Type d'un octet.
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)