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 |
Jacob Bundgaard | 01db7b7 | 2019-10-16 17:07:41 +0200 | [diff] [blame] | 26 | * - Trailing commas in objects and arrays are allowed. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 27 | * - Root object can be any JSON value |
| 28 | * - Assumes Value strings are encoded in UTF-8 |
| 29 | */ |
| 30 | static Features all(); |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 31 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 32 | /** \brief A configuration that is strictly compatible with the JSON |
| 33 | * specification. |
| 34 | * - Comments are forbidden. |
Jacob Bundgaard | 01db7b7 | 2019-10-16 17:07:41 +0200 | [diff] [blame] | 35 | * - Trailing commas in objects and arrays are forbidden. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 36 | * - 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 Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 40 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 41 | /** \brief Initialize the configuration like JsonConfig::allFeatures; |
| 42 | */ |
| 43 | Features(); |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 44 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 45 | /// \c true if comments are allowed. Default: \c true. |
Billy Donahue | 2b593a9 | 2019-01-18 03:46:57 -0500 | [diff] [blame] | 46 | bool allowComments_{true}; |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 47 | |
Jacob Bundgaard | 1c8f7d8 | 2019-11-04 13:29:17 +0100 | [diff] [blame^] | 48 | /// \c true if trailing commas in objects and arrays are allowed. Default \c |
| 49 | /// true. |
Jacob Bundgaard | 01db7b7 | 2019-10-16 17:07:41 +0200 | [diff] [blame] | 50 | bool allowTrailingCommas_{true}; |
| 51 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 52 | /// \c true if root must be either an array or an object value. Default: \c |
| 53 | /// false. |
Billy Donahue | 2b593a9 | 2019-01-18 03:46:57 -0500 | [diff] [blame] | 54 | bool strictRoot_{false}; |
Aaron Jacobs | 642befc | 2014-04-23 23:28:23 +0000 | [diff] [blame] | 55 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 56 | /// \c true if dropped null placeholders are allowed. Default: \c false. |
Billy Donahue | 2b593a9 | 2019-01-18 03:46:57 -0500 | [diff] [blame] | 57 | bool allowDroppedNullPlaceholders_{false}; |
Aaron Jacobs | 642befc | 2014-04-23 23:28:23 +0000 | [diff] [blame] | 58 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 59 | /// \c true if numeric object key are allowed. Default: \c false. |
Billy Donahue | 2b593a9 | 2019-01-18 03:46:57 -0500 | [diff] [blame] | 60 | bool allowNumericKeys_{false}; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 61 | }; |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 62 | |
| 63 | } // namespace Json |
| 64 | |
Sergiy80 | d6e666f | 2016-12-03 22:29:14 +0200 | [diff] [blame] | 65 | #pragma pack(pop) |
| 66 | |
Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 67 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED |