blob: e4a61d6f186bca1a8fe18b20844fd30e75a3516d [file] [log] [blame]
Devin Jeanpierre59e4d352017-07-21 03:44:36 -07001// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +00002// 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
Jordan Bayles9704ced2019-11-14 09:38:11 -08006#ifndef JSON_FEATURES_H_INCLUDED
7#define JSON_FEATURES_H_INCLUDED
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +00008
Baptiste Lepilleureadc4782011-05-02 21:09:30 +00009#if !defined(JSON_IS_AMALGAMATION)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100010#include "forwards.h"
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000011#endif // if !defined(JSON_IS_AMALGAMATION)
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000012
Jessica Clarke42e892d2022-01-12 21:27:16 +000013#pragma pack(push)
14#pragma pack()
Sergiy80d6e666f2016-12-03 22:29:14 +020015
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000016namespace Json {
17
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100018/** \brief Configuration passed to reader and writer.
19 * This configuration object can be used to force the Reader or Writer
20 * to behave in a standard conforming way.
21 */
22class JSON_API Features {
23public:
24 /** \brief A configuration that allows all features and assumes all strings
25 * are UTF-8.
26 * - C & C++ comments are allowed
27 * - Root object can be any JSON value
28 * - Assumes Value strings are encoded in UTF-8
29 */
30 static Features all();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000031
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100032 /** \brief A configuration that is strictly compatible with the JSON
33 * specification.
34 * - Comments are forbidden.
35 * - Root object must be either an array or an object value.
36 * - Assumes Value strings are encoded in UTF-8
37 */
38 static Features strictMode();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000039
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100040 /** \brief Initialize the configuration like JsonConfig::allFeatures;
41 */
42 Features();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000043
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100044 /// \c true if comments are allowed. Default: \c true.
Billy Donahue2b593a92019-01-18 03:46:57 -050045 bool allowComments_{true};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000046
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100047 /// \c true if root must be either an array or an object value. Default: \c
48 /// false.
Billy Donahue2b593a92019-01-18 03:46:57 -050049 bool strictRoot_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000050
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100051 /// \c true if dropped null placeholders are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050052 bool allowDroppedNullPlaceholders_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000053
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100054 /// \c true if numeric object key are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050055 bool allowNumericKeys_{false};
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100056};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000057
58} // namespace Json
59
Sergiy80d6e666f2016-12-03 22:29:14 +020060#pragma pack(pop)
61
Jordan Bayles9704ced2019-11-14 09:38:11 -080062#endif // JSON_FEATURES_H_INCLUDED