Devin Jeanpierre | 59e4d35 | 2017-07-21 03:44:36 -0700 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 2 | // 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 Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 7 | #define CPPTL_JSON_FEATURES_H_INCLUDED |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 8 | |
Baptiste Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 9 | #if !defined(JSON_IS_AMALGAMATION) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 10 | #include "forwards.h" |
Baptiste Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 11 | #endif // if !defined(JSON_IS_AMALGAMATION) |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 12 | |
Sergiy80 | d6e666f | 2016-12-03 22:29:14 +0200 | [diff] [blame] | 13 | #pragma pack(push, 8) |
| 14 | |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 15 | namespace Json { |
| 16 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 17 | /** \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 | */ |
| 21 | class JSON_API Features { |
| 22 | public: |
| 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 Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 30 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 31 | /** \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 Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 38 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 39 | /** \brief Initialize the configuration like JsonConfig::allFeatures; |
| 40 | */ |
| 41 | Features(); |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 42 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 43 | /// \c true if comments are allowed. Default: \c true. |
Billy Donahue | dc4a7f9 | 2019-01-17 11:07:53 -0500 | [diff] [blame] | 44 | bool allowComments_{ true }; |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 45 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 46 | /// \c true if root must be either an array or an object value. Default: \c |
| 47 | /// false. |
Billy Donahue | dc4a7f9 | 2019-01-17 11:07:53 -0500 | [diff] [blame] | 48 | bool strictRoot_{ false }; |
Aaron Jacobs | 642befc | 2014-04-23 23:28:23 +0000 | [diff] [blame] | 49 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 50 | /// \c true if dropped null placeholders are allowed. Default: \c false. |
Billy Donahue | dc4a7f9 | 2019-01-17 11:07:53 -0500 | [diff] [blame] | 51 | bool allowDroppedNullPlaceholders_{ false }; |
Aaron Jacobs | 642befc | 2014-04-23 23:28:23 +0000 | [diff] [blame] | 52 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 53 | /// \c true if numeric object key are allowed. Default: \c false. |
Billy Donahue | dc4a7f9 | 2019-01-17 11:07:53 -0500 | [diff] [blame] | 54 | bool allowNumericKeys_{ false }; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 55 | }; |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 56 | |
| 57 | } // namespace Json |
| 58 | |
Sergiy80 | d6e666f | 2016-12-03 22:29:14 +0200 | [diff] [blame] | 59 | #pragma pack(pop) |
| 60 | |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 61 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED |