blob: 7c7e9f5de15e259eba132de8efa5d80b78f9f92c [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
Sergiy80d6e666f2016-12-03 22:29:14 +020013#pragma pack(push, 8)
14
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000015namespace Json {
16
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100017/** \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();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000030
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100031 /** \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();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000038
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100039 /** \brief Initialize the configuration like JsonConfig::allFeatures;
40 */
41 Features();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000042
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100043 /// \c true if comments are allowed. Default: \c true.
Billy Donahue2b593a92019-01-18 03:46:57 -050044 bool allowComments_{true};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000045
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100046 /// \c true if root must be either an array or an object value. Default: \c
47 /// false.
Billy Donahue2b593a92019-01-18 03:46:57 -050048 bool strictRoot_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000049
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100050 /// \c true if dropped null placeholders are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050051 bool allowDroppedNullPlaceholders_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000052
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100053 /// \c true if numeric object key are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050054 bool allowNumericKeys_{false};
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100055};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000056
57} // namespace Json
58
Sergiy80d6e666f2016-12-03 22:29:14 +020059#pragma pack(pop)
60
Jordan Bayles9704ced2019-11-14 09:38:11 -080061#endif // JSON_FEATURES_H_INCLUDED