2017-07-21 12:44:36 +02:00
|
|
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
2010-04-20 23:35:19 +02:00
|
|
|
// Distributed under MIT license, or public domain if desired and
|
|
|
|
// recognized in your jurisdiction.
|
|
|
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
|
|
|
2007-06-13 17:51:04 +02:00
|
|
|
#ifndef JSON_WRITER_H_INCLUDED
|
2014-07-01 00:48:54 +02:00
|
|
|
#define JSON_WRITER_H_INCLUDED
|
2007-06-13 17:51:04 +02:00
|
|
|
|
2011-05-02 23:09:30 +02:00
|
|
|
#if !defined(JSON_IS_AMALGAMATION)
|
2014-07-01 00:48:54 +02:00
|
|
|
#include "value.h"
|
2011-05-02 23:09:30 +02:00
|
|
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
2015-01-26 17:35:54 +01:00
|
|
|
#include <ostream>
|
2018-05-20 22:55:27 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2007-06-13 17:51:04 +02:00
|
|
|
|
2014-07-01 00:48:54 +02:00
|
|
|
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
|
|
|
// be used by...
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
|
2014-07-01 00:48:54 +02:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4251)
|
2013-05-08 22:21:11 +02:00
|
|
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
|
|
|
|
Use default rather than hard-coded 8 for maximum aggregate member alignment (#1378)
On CHERI, and thus Arm's Morello prototype, pointers are represented as
hardware capabilities. These capabilities are comprised of not just an
integer address, as is the representation for traditional pointers, but
also bounds, permissions and other metadata, plus a tag bit used as the
validity bit, which provides fine-grained spatial and referential safety
for C and C++ in hardware. This tag bit is not part of the data itself
and is instead kept on the side, flowing with the capability between
registers and the memory subsystem, and any attempt to amplify the
privilege of or corrupt a capability clears this tag (or, in some cases,
traps), rendering them impossible to forge; you can only create
capabilities that are (possibly trivial) subsets of existing ones.
When the capability is stored in memory, this tag bit needs to be
preserved, which is done through the use of tagged memory. Every
capability-sized word gains an additional non-addressable (from the
CPU's perspective; depending on the implementation the tag bits may be
stored in a small block of memory carved out of normal DRAM that the CPU
is blocked from accessing) bit. This means that capabilities can only be
stored to aligned locations; attempting to store them to unaligned
locations will trap with an alignment fault or, if you end up using a
memcpy call, will copy the raw bytes of the capability's representation
but lose the tag, so when it is eventually loaded back as a capability
and dereferenced it will fault.
Since, on 64-bit architectures, our capabilities, used to implement C
language pointers, are 128-bit quantities, this means they need 16-byte
alignment. Currently the various #pragma pack directives, used to work
around (extremely broken and bogus) code that includes jsoncpp in a
context where the maximum alignment has been overridden, hard-code 8 as
the maximum alignment to use, and so do not sufficiently align CHERI /
Morello capabilities on 64-bit architectures. On Windows x64, the
default is also not 8 but 16 (ARM64 is supposedly 8), so this is
slightly dodgy to do there too, but in practice likely not an issue so
long as you don't use any 128-bit types there.
Instead of hard-coding a width, use a directive that resets the packing
back to the default. Unfortunately, whilst GCC and Clang both accept
using #pragma pack(push, 0) as shorthand like for any non-zero value,
MSVC does not, so this needs to be two directives.
2022-01-12 22:27:16 +01:00
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack()
|
2016-12-03 21:29:14 +01:00
|
|
|
|
2007-06-13 17:51:04 +02:00
|
|
|
namespace Json {
|
|
|
|
|
2014-07-01 00:48:54 +02:00
|
|
|
class Value;
|
2015-01-22 22:25:30 +01:00
|
|
|
|
|
|
|
/**
|
2019-09-16 21:37:14 +02:00
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* \code
|
|
|
|
* using namespace Json;
|
|
|
|
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
|
|
|
|
* { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
|
|
|
|
* writer->write(value, &std::cout);
|
|
|
|
* std::cout << std::endl; // add lf and flush
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*/
|
2015-01-22 21:31:32 +01:00
|
|
|
class JSON_API StreamWriter {
|
|
|
|
protected:
|
2019-01-17 22:35:29 +01:00
|
|
|
OStream* sout_; // not owned; will not delete
|
2015-01-22 21:31:32 +01:00
|
|
|
public:
|
2015-02-10 01:44:53 +01:00
|
|
|
StreamWriter();
|
2015-01-22 21:31:32 +01:00
|
|
|
virtual ~StreamWriter();
|
2019-09-16 21:37:14 +02:00
|
|
|
/** Write Value into document as configured in sub-class.
|
|
|
|
* Do not take ownership of sout, but maintain a reference during function.
|
|
|
|
* \pre sout != NULL
|
|
|
|
* \return zero on success (For now, we always return zero, so check the
|
|
|
|
* stream instead.) \throw std::exception possibly, depending on
|
|
|
|
* configuration
|
|
|
|
*/
|
2019-01-17 22:35:29 +01:00
|
|
|
virtual int write(Value const& root, OStream* sout) = 0;
|
2015-01-22 21:31:32 +01:00
|
|
|
|
2015-01-26 17:35:54 +01:00
|
|
|
/** \brief A simple abstract factory.
|
|
|
|
*/
|
|
|
|
class JSON_API Factory {
|
|
|
|
public:
|
|
|
|
virtual ~Factory();
|
2015-02-10 00:22:28 +01:00
|
|
|
/** \brief Allocate a CharReader via operator new().
|
|
|
|
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
|
|
|
*/
|
2015-02-10 01:44:53 +01:00
|
|
|
virtual StreamWriter* newStreamWriter() const = 0;
|
2018-05-20 22:55:27 +02:00
|
|
|
}; // Factory
|
2024-09-10 00:48:18 +02:00
|
|
|
}; // StreamWriter
|
2015-01-26 18:01:15 +01:00
|
|
|
|
2015-02-09 22:25:57 +01:00
|
|
|
/** \brief Write into stringstream, then return string, for convenience.
|
|
|
|
* A StreamWriter will be created from the factory, used, and then deleted.
|
|
|
|
*/
|
2019-01-17 22:35:29 +01:00
|
|
|
String JSON_API writeString(StreamWriter::Factory const& factory,
|
|
|
|
Value const& root);
|
2015-01-26 17:35:54 +01:00
|
|
|
|
2015-01-26 18:01:15 +01:00
|
|
|
/** \brief Build a StreamWriter implementation.
|
2015-01-26 18:12:53 +01:00
|
|
|
|
2019-09-16 19:40:35 +02:00
|
|
|
* Usage:
|
|
|
|
* \code
|
|
|
|
* using namespace Json;
|
|
|
|
* Value value = ...;
|
|
|
|
* StreamWriterBuilder builder;
|
|
|
|
* builder["commentStyle"] = "None";
|
|
|
|
* builder["indentation"] = " "; // or whatever you like
|
|
|
|
* std::unique_ptr<Json::StreamWriter> writer(
|
|
|
|
* builder.newStreamWriter());
|
|
|
|
* writer->write(value, &std::cout);
|
|
|
|
* std::cout << std::endl; // add lf and flush
|
|
|
|
* \endcode
|
2015-01-26 18:12:53 +01:00
|
|
|
*/
|
2015-01-26 18:01:15 +01:00
|
|
|
class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
|
|
|
|
public:
|
2015-02-10 00:22:28 +01:00
|
|
|
// Note: We use a Json::Value so that we can add data-members to this class
|
|
|
|
// without a major version bump.
|
|
|
|
/** Configuration of this builder.
|
2019-09-16 19:40:35 +02:00
|
|
|
* Available settings (case-sensitive):
|
|
|
|
* - "commentStyle": "None" or "All"
|
|
|
|
* - "indentation": "<anything>".
|
|
|
|
* - Setting this to an empty string also omits newline characters.
|
|
|
|
* - "enableYAMLCompatibility": false or true
|
|
|
|
* - slightly change the whitespace around colons
|
|
|
|
* - "dropNullPlaceholders": false or true
|
|
|
|
* - Drop the "null" string from the writer's output for nullValues.
|
|
|
|
* Strictly speaking, this is not valid JSON. But when the output is being
|
|
|
|
* fed to a browser's JavaScript, it makes for smaller output and the
|
|
|
|
* browser can handle the output just fine.
|
|
|
|
* - "useSpecialFloats": false or true
|
|
|
|
* - If true, outputs non-finite floating point values in the following way:
|
|
|
|
* NaN values as "NaN", positive infinity as "Infinity", and negative
|
|
|
|
* infinity as "-Infinity".
|
|
|
|
* - "precision": int
|
|
|
|
* - Number of precision digits for formatting of real values.
|
|
|
|
* - "precisionType": "significant"(default) or "decimal"
|
|
|
|
* - Type of precision for formatting of real values.
|
2021-03-02 16:57:54 +01:00
|
|
|
* - "emitUTF8": false or true
|
|
|
|
* - If true, outputs raw UTF8 strings instead of escaping them.
|
2019-09-16 19:40:35 +02:00
|
|
|
|
|
|
|
* You can examine 'settings_` yourself
|
|
|
|
* to see the defaults. You can also write and read them just like any
|
|
|
|
* JSON Value.
|
|
|
|
* \sa setDefaults()
|
|
|
|
*/
|
2015-02-10 00:22:28 +01:00
|
|
|
Json::Value settings_;
|
2015-01-26 18:17:42 +01:00
|
|
|
|
|
|
|
StreamWriterBuilder();
|
2019-01-11 20:58:53 +01:00
|
|
|
~StreamWriterBuilder() override;
|
2015-01-22 21:31:32 +01:00
|
|
|
|
2015-02-10 01:44:53 +01:00
|
|
|
/**
|
2015-02-10 00:22:28 +01:00
|
|
|
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
|
|
|
*/
|
2019-01-11 20:58:53 +01:00
|
|
|
StreamWriter* newStreamWriter() const override;
|
2015-02-10 00:22:28 +01:00
|
|
|
|
2015-02-10 01:24:56 +01:00
|
|
|
/** \return true if 'settings' are legal and consistent;
|
2015-02-10 00:22:28 +01:00
|
|
|
* otherwise, indicate bad settings via 'invalid'.
|
|
|
|
*/
|
|
|
|
bool validate(Json::Value* invalid) const;
|
2015-03-04 21:56:37 +01:00
|
|
|
/** A simple way to update a specific setting.
|
|
|
|
*/
|
2019-01-17 22:35:29 +01:00
|
|
|
Value& operator[](const String& key);
|
2015-03-04 21:56:37 +01:00
|
|
|
|
2015-02-10 00:22:28 +01:00
|
|
|
/** Called by ctor, but you can use this to reset settings_.
|
|
|
|
* \pre 'settings' != NULL (but Json::null is fine)
|
2015-02-10 01:16:24 +01:00
|
|
|
* \remark Defaults:
|
|
|
|
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
2015-02-10 00:22:28 +01:00
|
|
|
*/
|
|
|
|
static void setDefaults(Json::Value* settings);
|
2015-01-26 18:01:15 +01:00
|
|
|
};
|
2015-01-22 21:31:32 +01:00
|
|
|
|
2014-07-01 00:48:54 +02:00
|
|
|
/** \brief Abstract class for writers.
|
2015-03-08 20:01:28 +01:00
|
|
|
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
2014-07-01 00:48:54 +02:00
|
|
|
*/
|
2021-11-03 17:35:15 +01:00
|
|
|
class JSON_API Writer {
|
2014-07-01 00:48:54 +02:00
|
|
|
public:
|
|
|
|
virtual ~Writer();
|
|
|
|
|
2019-01-17 22:35:29 +01:00
|
|
|
virtual String write(const Value& root) = 0;
|
2014-07-01 00:48:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
|
|
|
*without formatting (not human friendly).
|
|
|
|
*
|
|
|
|
* The JSON document is written in a single line. It is not intended for 'human'
|
|
|
|
*consumption,
|
2018-02-09 02:05:50 +01:00
|
|
|
* but may be useful to support feature such as RPC where bandwidth is limited.
|
2014-07-01 00:48:54 +02:00
|
|
|
* \sa Reader, Value
|
2015-02-11 04:29:35 +01:00
|
|
|
* \deprecated Use StreamWriterBuilder.
|
2014-07-01 00:48:54 +02:00
|
|
|
*/
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 15:14:52 +02:00
|
|
|
#pragma warning(push)
|
2018-05-20 22:55:27 +02:00
|
|
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2024-09-10 00:48:18 +02:00
|
|
|
class JSON_API FastWriter : public Writer {
|
2014-07-01 00:48:54 +02:00
|
|
|
public:
|
|
|
|
FastWriter();
|
2019-01-15 00:09:26 +01:00
|
|
|
~FastWriter() override = default;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
void enableYAMLCompatibility();
|
|
|
|
|
|
|
|
/** \brief Drop the "null" string from the writer's output for nullValues.
|
|
|
|
* Strictly speaking, this is not valid JSON. But when the output is being
|
2017-12-03 17:54:29 +01:00
|
|
|
* fed to a browser's JavaScript, it makes for smaller output and the
|
2014-07-01 00:48:54 +02:00
|
|
|
* browser can handle the output just fine.
|
|
|
|
*/
|
|
|
|
void dropNullPlaceholders();
|
|
|
|
|
2014-09-03 01:09:07 +02:00
|
|
|
void omitEndingLineFeed();
|
|
|
|
|
2014-07-01 00:48:54 +02:00
|
|
|
public: // overridden from Writer
|
2019-01-17 22:35:29 +01:00
|
|
|
String write(const Value& root) override;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
private:
|
2014-09-15 02:15:29 +02:00
|
|
|
void writeValue(const Value& value);
|
2014-07-01 00:48:54 +02:00
|
|
|
|
2019-01-17 22:35:29 +01:00
|
|
|
String document_;
|
2019-01-18 09:46:57 +01:00
|
|
|
bool yamlCompatibilityEnabled_{false};
|
|
|
|
bool dropNullPlaceholders_{false};
|
|
|
|
bool omitEndingLineFeed_{false};
|
2014-07-01 00:48:54 +02:00
|
|
|
};
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 20:39:38 +02:00
|
|
|
#pragma warning(pop)
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
|
|
|
*human friendly way.
|
|
|
|
*
|
|
|
|
* The rules for line break and indent are as follow:
|
|
|
|
* - Object value:
|
|
|
|
* - if empty then print {} without indent and line break
|
|
|
|
* - if not empty the print '{', line break & indent, print one value per
|
|
|
|
*line
|
|
|
|
* and then unindent and line break and print '}'.
|
|
|
|
* - Array value:
|
|
|
|
* - if empty then print [] without indent and line break
|
|
|
|
* - if the array contains no object value, empty array or some other value
|
|
|
|
*types,
|
|
|
|
* and all the values fit on one lines, then print the array on a single
|
|
|
|
*line.
|
|
|
|
* - otherwise, it the values do not fit on one line, or the array contains
|
|
|
|
* object or non empty array, then print one value per line.
|
|
|
|
*
|
2021-12-15 03:04:47 +01:00
|
|
|
* If the Value have comments then they are outputted according to their
|
2014-07-01 00:48:54 +02:00
|
|
|
*#CommentPlacement.
|
|
|
|
*
|
|
|
|
* \sa Reader, Value, Value::setComment()
|
2015-01-26 18:23:31 +01:00
|
|
|
* \deprecated Use StreamWriterBuilder.
|
2014-07-01 00:48:54 +02:00
|
|
|
*/
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 15:14:52 +02:00
|
|
|
#pragma warning(push)
|
2018-05-20 22:55:27 +02:00
|
|
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2024-09-10 00:48:18 +02:00
|
|
|
class JSON_API StyledWriter : public Writer {
|
2014-07-01 00:48:54 +02:00
|
|
|
public:
|
|
|
|
StyledWriter();
|
2019-01-15 00:09:26 +01:00
|
|
|
~StyledWriter() override = default;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
public: // overridden from Writer
|
|
|
|
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
|
|
|
* \param root Value to serialize.
|
|
|
|
* \return String containing the JSON document that represents the root value.
|
|
|
|
*/
|
2019-01-17 22:35:29 +01:00
|
|
|
String write(const Value& root) override;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
private:
|
2014-09-15 02:15:29 +02:00
|
|
|
void writeValue(const Value& value);
|
|
|
|
void writeArrayValue(const Value& value);
|
2017-12-03 17:54:29 +01:00
|
|
|
bool isMultilineArray(const Value& value);
|
2019-01-17 22:35:29 +01:00
|
|
|
void pushValue(const String& value);
|
2014-07-01 00:48:54 +02:00
|
|
|
void writeIndent();
|
2019-01-17 22:35:29 +01:00
|
|
|
void writeWithIndent(const String& value);
|
2014-07-01 00:48:54 +02:00
|
|
|
void indent();
|
|
|
|
void unindent();
|
2014-09-15 02:15:29 +02:00
|
|
|
void writeCommentBeforeValue(const Value& root);
|
|
|
|
void writeCommentAfterValueOnSameLine(const Value& root);
|
2018-06-02 18:43:31 +02:00
|
|
|
static bool hasCommentForValue(const Value& value);
|
2019-01-17 22:35:29 +01:00
|
|
|
static String normalizeEOL(const String& text);
|
2014-07-01 00:48:54 +02:00
|
|
|
|
2019-12-04 02:08:45 +01:00
|
|
|
using ChildValues = std::vector<String>;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
ChildValues childValues_;
|
2019-01-17 22:35:29 +01:00
|
|
|
String document_;
|
|
|
|
String indentString_;
|
2019-01-18 09:46:57 +01:00
|
|
|
unsigned int rightMargin_{74};
|
|
|
|
unsigned int indentSize_{3};
|
|
|
|
bool addChildValues_{false};
|
2014-07-01 00:48:54 +02:00
|
|
|
};
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 20:39:38 +02:00
|
|
|
#pragma warning(pop)
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
|
|
|
human friendly way,
|
|
|
|
to a stream rather than to a string.
|
|
|
|
*
|
|
|
|
* The rules for line break and indent are as follow:
|
|
|
|
* - Object value:
|
|
|
|
* - if empty then print {} without indent and line break
|
|
|
|
* - if not empty the print '{', line break & indent, print one value per
|
|
|
|
line
|
|
|
|
* and then unindent and line break and print '}'.
|
|
|
|
* - Array value:
|
|
|
|
* - if empty then print [] without indent and line break
|
|
|
|
* - if the array contains no object value, empty array or some other value
|
|
|
|
types,
|
|
|
|
* and all the values fit on one lines, then print the array on a single
|
|
|
|
line.
|
|
|
|
* - otherwise, it the values do not fit on one line, or the array contains
|
|
|
|
* object or non empty array, then print one value per line.
|
|
|
|
*
|
2021-12-15 03:04:47 +01:00
|
|
|
* If the Value have comments then they are outputted according to their
|
2014-07-01 00:48:54 +02:00
|
|
|
#CommentPlacement.
|
|
|
|
*
|
|
|
|
* \sa Reader, Value, Value::setComment()
|
2015-01-26 18:23:31 +01:00
|
|
|
* \deprecated Use StreamWriterBuilder.
|
2014-07-01 00:48:54 +02:00
|
|
|
*/
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 20:39:38 +02:00
|
|
|
#pragma warning(push)
|
2018-05-20 22:55:27 +02:00
|
|
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2024-09-10 00:48:18 +02:00
|
|
|
class JSON_API StyledStreamWriter {
|
2014-07-01 00:48:54 +02:00
|
|
|
public:
|
2018-05-20 22:55:27 +02:00
|
|
|
/**
|
|
|
|
* \param indentation Each level will be indented by this amount extra.
|
|
|
|
*/
|
2019-01-17 22:35:29 +01:00
|
|
|
StyledStreamWriter(String indentation = "\t");
|
2019-01-15 00:09:19 +01:00
|
|
|
~StyledStreamWriter() = default;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
|
|
|
* \param out Stream to write to. (Can be ostringstream, e.g.)
|
|
|
|
* \param root Value to serialize.
|
|
|
|
* \note There is no point in deriving from Writer, since write() should not
|
|
|
|
* return a value.
|
|
|
|
*/
|
2019-10-11 20:19:00 +02:00
|
|
|
void write(OStream& out, const Value& root);
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
private:
|
2014-09-15 02:15:29 +02:00
|
|
|
void writeValue(const Value& value);
|
|
|
|
void writeArrayValue(const Value& value);
|
2017-12-03 17:54:29 +01:00
|
|
|
bool isMultilineArray(const Value& value);
|
2019-01-17 22:35:29 +01:00
|
|
|
void pushValue(const String& value);
|
2014-07-01 00:48:54 +02:00
|
|
|
void writeIndent();
|
2019-01-17 22:35:29 +01:00
|
|
|
void writeWithIndent(const String& value);
|
2014-07-01 00:48:54 +02:00
|
|
|
void indent();
|
|
|
|
void unindent();
|
2014-09-15 02:15:29 +02:00
|
|
|
void writeCommentBeforeValue(const Value& root);
|
|
|
|
void writeCommentAfterValueOnSameLine(const Value& root);
|
2018-06-02 18:43:31 +02:00
|
|
|
static bool hasCommentForValue(const Value& value);
|
2019-01-17 22:35:29 +01:00
|
|
|
static String normalizeEOL(const String& text);
|
2014-07-01 00:48:54 +02:00
|
|
|
|
2019-12-04 02:08:45 +01:00
|
|
|
using ChildValues = std::vector<String>;
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
ChildValues childValues_;
|
2019-01-17 22:35:29 +01:00
|
|
|
OStream* document_;
|
|
|
|
String indentString_;
|
2019-01-18 09:46:57 +01:00
|
|
|
unsigned int rightMargin_{74};
|
2019-01-17 22:35:29 +01:00
|
|
|
String indentation_;
|
2015-01-23 20:09:43 +01:00
|
|
|
bool addChildValues_ : 1;
|
|
|
|
bool indented_ : 1;
|
2014-07-01 00:48:54 +02:00
|
|
|
};
|
2017-09-16 11:01:09 +02:00
|
|
|
#if defined(_MSC_VER)
|
2017-09-11 20:39:38 +02:00
|
|
|
#pragma warning(pop)
|
2017-09-16 11:01:09 +02:00
|
|
|
#endif
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
#if defined(JSON_HAS_INT64)
|
2019-01-17 22:35:29 +01:00
|
|
|
String JSON_API valueToString(Int value);
|
|
|
|
String JSON_API valueToString(UInt value);
|
2014-07-01 00:48:54 +02:00
|
|
|
#endif // if defined(JSON_HAS_INT64)
|
2019-01-17 22:35:29 +01:00
|
|
|
String JSON_API valueToString(LargestInt value);
|
|
|
|
String JSON_API valueToString(LargestUInt value);
|
2019-10-11 20:19:00 +02:00
|
|
|
String JSON_API valueToString(
|
|
|
|
double value, unsigned int precision = Value::defaultRealPrecision,
|
|
|
|
PrecisionType precisionType = PrecisionType::significantDigits);
|
2019-01-17 22:35:29 +01:00
|
|
|
String JSON_API valueToString(bool value);
|
|
|
|
String JSON_API valueToQuotedString(const char* value);
|
2024-09-10 02:38:22 +02:00
|
|
|
String JSON_API valueToQuotedString(const char* value, size_t length);
|
2014-07-01 00:48:54 +02:00
|
|
|
|
|
|
|
/// \brief Output using the StyledStreamWriter.
|
|
|
|
/// \see Json::operator>>()
|
2019-01-17 22:35:29 +01:00
|
|
|
JSON_API OStream& operator<<(OStream&, const Value& root);
|
2007-06-13 17:51:04 +02:00
|
|
|
|
|
|
|
} // namespace Json
|
|
|
|
|
2016-12-03 21:29:14 +01:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2013-05-08 22:21:11 +02:00
|
|
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
2014-07-01 00:48:54 +02:00
|
|
|
#pragma warning(pop)
|
2013-05-08 22:21:11 +02:00
|
|
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
|
|
|
|
2007-06-13 17:51:04 +02:00
|
|
|
#endif // JSON_WRITER_H_INCLUDED
|