blob: 7c7e9f5de15e259eba132de8efa5d80b78f9f92c [file] [log] [blame]
Haibo Huangb0bee822021-02-24 15:40:15 -08001// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -04002// Distributed under MIT license, or public domain if desired and
3// recognized in your jurisdiction.
4// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
Haibo Huangb0bee822021-02-24 15:40:15 -08006#ifndef JSON_FEATURES_H_INCLUDED
7#define JSON_FEATURES_H_INCLUDED
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -04008
9#if !defined(JSON_IS_AMALGAMATION)
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050010#include "forwards.h"
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040011#endif // if !defined(JSON_IS_AMALGAMATION)
12
Haibo Huangb0bee822021-02-24 15:40:15 -080013#pragma pack(push, 8)
14
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040015namespace Json {
16
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050017/** \brief Configuration passed to reader and writer.
18 * This configuration object can be used to force the Reader or Writer
19 * to behave in a standard conforming way.
20 */
21class JSON_API Features {
22public:
23 /** \brief A configuration that allows all features and assumes all strings
24 * are UTF-8.
25 * - C & C++ comments are allowed
26 * - Root object can be any JSON value
27 * - Assumes Value strings are encoded in UTF-8
28 */
29 static Features all();
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040030
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050031 /** \brief A configuration that is strictly compatible with the JSON
32 * specification.
33 * - Comments are forbidden.
34 * - Root object must be either an array or an object value.
35 * - Assumes Value strings are encoded in UTF-8
36 */
37 static Features strictMode();
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040038
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050039 /** \brief Initialize the configuration like JsonConfig::allFeatures;
40 */
41 Features();
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040042
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050043 /// \c true if comments are allowed. Default: \c true.
Haibo Huangb0bee822021-02-24 15:40:15 -080044 bool allowComments_{true};
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040045
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050046 /// \c true if root must be either an array or an object value. Default: \c
47 /// false.
Haibo Huangb0bee822021-02-24 15:40:15 -080048 bool strictRoot_{false};
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050049
50 /// \c true if dropped null placeholders are allowed. Default: \c false.
Haibo Huangb0bee822021-02-24 15:40:15 -080051 bool allowDroppedNullPlaceholders_{false};
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050052
53 /// \c true if numeric object key are allowed. Default: \c false.
Haibo Huangb0bee822021-02-24 15:40:15 -080054 bool allowNumericKeys_{false};
Derek Sollenberger2eb3b4d2016-01-11 14:41:40 -050055};
Leon Scroggins IIIf59fb0e2014-05-28 15:19:42 -040056
57} // namespace Json
58
Haibo Huangb0bee822021-02-24 15:40:15 -080059#pragma pack(pop)
60
61#endif // JSON_FEATURES_H_INCLUDED