json_features.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
  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. #ifndef JSON_FEATURES_H_INCLUDED
  6. #define JSON_FEATURES_H_INCLUDED
  7. #if !defined(JSON_IS_AMALGAMATION)
  8. #include "forwards.h"
  9. #endif // if !defined(JSON_IS_AMALGAMATION)
  10. #pragma pack(push)
  11. #pragma pack()
  12. namespace Json {
  13. /** \brief Configuration passed to reader and writer.
  14. * This configuration object can be used to force the Reader or Writer
  15. * to behave in a standard conforming way.
  16. */
  17. class JSON_API Features {
  18. public:
  19. /** \brief A configuration that allows all features and assumes all strings
  20. * are UTF-8.
  21. * - C & C++ comments are allowed
  22. * - Root object can be any JSON value
  23. * - Assumes Value strings are encoded in UTF-8
  24. */
  25. static Features all();
  26. /** \brief A configuration that is strictly compatible with the JSON
  27. * specification.
  28. * - Comments are forbidden.
  29. * - Root object must be either an array or an object value.
  30. * - Assumes Value strings are encoded in UTF-8
  31. */
  32. static Features strictMode();
  33. /** \brief Initialize the configuration like JsonConfig::allFeatures;
  34. */
  35. Features();
  36. /// \c true if comments are allowed. Default: \c true.
  37. bool allowComments_{true};
  38. /// \c true if root must be either an array or an object value. Default: \c
  39. /// false.
  40. bool strictRoot_{false};
  41. /// \c true if dropped null placeholders are allowed. Default: \c false.
  42. bool allowDroppedNullPlaceholders_{false};
  43. /// \c true if numeric object key are allowed. Default: \c false.
  44. bool allowNumericKeys_{false};
  45. };
  46. } // namespace Json
  47. #pragma pack(pop)
  48. #endif // JSON_FEATURES_H_INCLUDED