json_features.h 1.8 KB

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