Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [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 | |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 6 | #ifndef JSON_FEATURES_H_INCLUDED |
| 7 | #define JSON_FEATURES_H_INCLUDED |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 8 | |
| 9 | #if !defined(JSON_IS_AMALGAMATION) |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 10 | #include "forwards.h" |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 11 | #endif // if !defined(JSON_IS_AMALGAMATION) |
| 12 | |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 13 | #pragma pack(push, 8) |
| 14 | |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 15 | namespace Json { |
| 16 | |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [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(); |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 30 | |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [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(); |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 38 | |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 39 | /** \brief Initialize the configuration like JsonConfig::allFeatures; |
| 40 | */ |
| 41 | Features(); |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 42 | |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 43 | /// \c true if comments are allowed. Default: \c true. |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 44 | bool allowComments_{true}; |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 45 | |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 46 | /// \c true if root must be either an array or an object value. Default: \c |
| 47 | /// false. |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 48 | bool strictRoot_{false}; |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 49 | |
| 50 | /// \c true if dropped null placeholders are allowed. Default: \c false. |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 51 | bool allowDroppedNullPlaceholders_{false}; |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 52 | |
| 53 | /// \c true if numeric object key are allowed. Default: \c false. |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 54 | bool allowNumericKeys_{false}; |
Derek Sollenberger | 2eb3b4d | 2016-01-11 14:41:40 -0500 | [diff] [blame] | 55 | }; |
Leon Scroggins III | f59fb0e | 2014-05-28 15:19:42 -0400 | [diff] [blame] | 56 | |
| 57 | } // namespace Json |
| 58 | |
Haibo Huang | b0bee82 | 2021-02-24 15:40:15 -0800 | [diff] [blame] | 59 | #pragma pack(pop) |
| 60 | |
| 61 | #endif // JSON_FEATURES_H_INCLUDED |