- added Features class that describes allowed extension for Reader, to allow for strict configuration
- added tests from json.org jsonchecker and modified jsontestrunner to use strict parsing mode when executing them
diff --git a/include/json/reader.h b/include/json/reader.h
index e113569..ee1d6a2 100644
--- a/include/json/reader.h
+++ b/include/json/reader.h
@@ -1,7 +1,7 @@
#ifndef CPPTL_JSON_READER_H_INCLUDED
# define CPPTL_JSON_READER_H_INCLUDED
-# include "forwards.h"
+# include "features.h"
# include "value.h"
# include <deque>
# include <stack>
@@ -10,11 +10,8 @@
namespace Json {
- class Value;
-
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
*
- *
*/
class JSON_API Reader
{
@@ -22,14 +19,24 @@
typedef char Char;
typedef const Char *Location;
+ /** \brief Constructs a Reader allowing all features
+ * for parsing.
+ */
Reader();
+ /** \brief Constructs a Reader allowing the specified feature set
+ * for parsing.
+ */
+ Reader( const Features &features );
+
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
+ * This parameter is ignored if Features::allowComments_
+ * is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
bool parse( const std::string &document,
@@ -42,6 +49,8 @@
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
+ * This parameter is ignored if Features::allowComments_
+ * is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
bool parse( const char *beginDoc, const char *endDoc,
@@ -50,7 +59,7 @@
/// \brief Parse from input stream.
/// \see Json::operator>>(std::istream&, Json::Value&).
- bool parse( std::istream&,
+ bool parse( std::istream &is,
Value &root,
bool collectComments = true );
@@ -152,6 +161,7 @@
Location lastValueEnd_;
Value *lastValue_;
std::string commentsBefore_;
+ Features features_;
bool collectComments_;
};