blob: 8ba1e8fd31fd2cb8b5a6194536d172fade93f9e9 [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
6#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
Aaron Jacobs9fa4e842014-07-01 08:48:54 +10007#define CPPTL_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
Jacob Bundgaard01db7b72019-10-16 17:07:41 +020026 * - Trailing commas in objects and arrays are allowed.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100027 * - 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.
Jacob Bundgaard01db7b72019-10-16 17:07:41 +020035 * - Trailing commas in objects and arrays are forbidden.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100036 * - Root object must be either an array or an object value.
37 * - Assumes Value strings are encoded in UTF-8
38 */
39 static Features strictMode();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000040
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100041 /** \brief Initialize the configuration like JsonConfig::allFeatures;
42 */
43 Features();
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000044
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100045 /// \c true if comments are allowed. Default: \c true.
Billy Donahue2b593a92019-01-18 03:46:57 -050046 bool allowComments_{true};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000047
Jacob Bundgaard01db7b72019-10-16 17:07:41 +020048 /// \c true if trailing commas in objects and arrays are allowed. Default \c true.
49 bool allowTrailingCommas_{true};
50
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100051 /// \c true if root must be either an array or an object value. Default: \c
52 /// false.
Billy Donahue2b593a92019-01-18 03:46:57 -050053 bool strictRoot_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000054
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100055 /// \c true if dropped null placeholders are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050056 bool allowDroppedNullPlaceholders_{false};
Aaron Jacobs642befc2014-04-23 23:28:23 +000057
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100058 /// \c true if numeric object key are allowed. Default: \c false.
Billy Donahue2b593a92019-01-18 03:46:57 -050059 bool allowNumericKeys_{false};
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100060};
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000061
62} // namespace Json
63
Sergiy80d6e666f2016-12-03 22:29:14 +020064#pragma pack(pop)
65
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +000066#endif // CPPTL_JSON_FEATURES_H_INCLUDED