diff --git a/JSON/include/Poco/JSON/Array.h b/JSON/include/Poco/JSON/Array.h index 98477b0dd..a68e27ead 100644 --- a/JSON/include/Poco/JSON/Array.h +++ b/JSON/include/Poco/JSON/Array.h @@ -35,27 +35,28 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_Array_INCLUDED #define JSON_Array_INCLUDED -#include -#include - #include "Poco/JSON/JSON.h" #include "Poco/SharedPtr.h" #include "Poco/Dynamic/Var.h" +#include +#include + namespace Poco { namespace JSON { + class Object; class JSON_API Array { public: - typedef std::vector ValueVector; typedef SharedPtr Ptr; @@ -199,6 +200,7 @@ inline void Array::remove(unsigned int index) namespace Poco { namespace Dynamic { + template <> class VarHolderImpl: public VarHolder { @@ -337,6 +339,7 @@ private: JSON::Array::Ptr _val; }; + }} // namespace Poco::JSON diff --git a/JSON/include/Poco/JSON/DefaultHandler.h b/JSON/include/Poco/JSON/DefaultHandler.h index 2801dfa8a..84b65e123 100644 --- a/JSON/include/Poco/JSON/DefaultHandler.h +++ b/JSON/include/Poco/JSON/DefaultHandler.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_DefaultHandler_INCLUDED #define JSON_DefaultHandler_INCLUDED @@ -154,4 +155,5 @@ inline void DefaultHandler::null() }} // namespace Poco::JSON + #endif // JSON_DefaultHandler_INCLUDED diff --git a/JSON/include/Poco/JSON/Handler.h b/JSON/include/Poco/JSON/Handler.h index d1e31d560..9bbb7d185 100644 --- a/JSON/include/Poco/JSON/Handler.h +++ b/JSON/include/Poco/JSON/Handler.h @@ -35,12 +35,14 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_Handler_INCLUDED #define JSON_Handler_INCLUDED -#include "Poco/Dynamic/Var.h" #include "Poco/JSON/JSON.h" +#include "Poco/Dynamic/Var.h" + namespace Poco { namespace JSON { @@ -95,4 +97,5 @@ private: }} // namespace Poco::JSON + #endif // JSON_Handler_INCLUDED diff --git a/JSON/include/Poco/JSON/JSONException.h b/JSON/include/Poco/JSON/JSONException.h index d9eefea23..4ba70b671 100644 --- a/JSON/include/Poco/JSON/JSONException.h +++ b/JSON/include/Poco/JSON/JSONException.h @@ -35,6 +35,7 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_JSONException_INCLUDED #define JSON_JSONException_INCLUDED @@ -46,8 +47,10 @@ namespace Poco { namespace JSON { + POCO_DECLARE_EXCEPTION(JSON_API, JSONException, Poco::Exception) + }} // namespace Poco::JSON diff --git a/JSON/include/Poco/JSON/Object.h b/JSON/include/Poco/JSON/Object.h index 012dcd35b..0b243aa0f 100644 --- a/JSON/include/Poco/JSON/Object.h +++ b/JSON/include/Poco/JSON/Object.h @@ -35,30 +35,29 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_Object_INCLUDED #define JSON_Object_INCLUDED +#include "Poco/JSON/JSON.h" +#include "Poco/JSON/Array.h" +#include "Poco/SharedPtr.h" +#include "Poco/Dynamic/Var.h" #include #include #include #include -#include "Poco/SharedPtr.h" -#include "Poco/Dynamic/Var.h" - -#include "Poco/JSON/JSON.h" -#include "Poco/JSON/Array.h" namespace Poco { namespace JSON { class JSON_API Object - /// Represents a JSON object + /// Represents a JSON object. { public: - typedef SharedPtr Ptr; Object(); @@ -344,6 +343,7 @@ private: JSON::Object::Ptr _val; }; + }} // namespace Poco::JSON diff --git a/JSON/include/Poco/JSON/Parser.h b/JSON/include/Poco/JSON/Parser.h index 6ef1c7c12..be908f10b 100644 --- a/JSON/include/Poco/JSON/Parser.h +++ b/JSON/include/Poco/JSON/Parser.h @@ -35,68 +35,66 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_JSONParser_INCLUDED #define JSON_JSONParser_INCLUDED -#include -#include - -#include "Poco/Dynamic/Var.h" -#include "Poco/StreamTokenizer.h" - #include "Poco/JSON/JSON.h" #include "Poco/JSON/Object.h" #include "Poco/JSON/Array.h" #include "Poco/JSON/Handler.h" +#include "Poco/Dynamic/Var.h" +#include "Poco/StreamTokenizer.h" +#include +#include + namespace Poco { namespace JSON { class JSON_API Parser - /// A class for passing JSON strings or streams + /// A class for passing JSON strings or streams. { public: Parser(); - /// Constructor + /// Constructor. virtual ~Parser(); - /// Destructor + /// Destructor. void parse(const std::string& source); - /// Parses a string + /// Parses a string. void parse(std::istream& in); - /// Parses a JSON from the input stream + /// Parses a JSON from the input stream. void setHandler(Handler* handler); - /// Set the handler + /// Set the handler. Handler* getHandler(); - /// Returns the handler + /// Returns the handler. private: - const Token* nextToken(); - /// Returns the next token + /// Returns the next token. void readObject(); - /// Starts reading an object - + /// Starts reading an object. void readArray(); - /// Starts reading an array + /// Starts reading an array. bool readRow(bool firstCall = false); /// Reads a property value pair. Returns true when a next row is expected. void readValue(const Token* token); - /// Read a value from the token + /// Read a value from the token. bool readElements(bool firstCall = false); - /// Read all elements of an array + /// Read all elements of an array. StreamTokenizer _tokenizer; Handler* _handler; diff --git a/JSON/include/Poco/JSON/Stringifier.h b/JSON/include/Poco/JSON/Stringifier.h index d9c9f0fe4..f7ef4ca89 100644 --- a/JSON/include/Poco/JSON/Stringifier.h +++ b/JSON/include/Poco/JSON/Stringifier.h @@ -35,14 +35,15 @@ // DEALINGS IN THE SOFTWARE. // + #ifndef JSON_JSONStringifier_INCLUDED #define JSON_JSONStringifier_INCLUDED -#include - #include "Poco/Dynamic/Var.h" #include "Poco/JSON/JSON.h" +#include + namespace Poco { namespace JSON { @@ -52,7 +53,6 @@ class JSON_API Stringifier /// Helper class for creating a String from a JSON object or array { public: - static void stringify(const Dynamic::Var& any, std::ostream& out, unsigned int indent = 0); /// Writes a String representation of the value to the output stream. /// When indent is 0, the String will be created as small as possible. @@ -61,4 +61,5 @@ public: }} // namespace Poco::JSON + #endif // JSON_JSONStringifier_INCLUDED diff --git a/JSON/include/Poco/JSON/Template.h b/JSON/include/Poco/JSON/Template.h index 117f4fae5..26a8480da 100644 --- a/JSON/include/Poco/JSON/Template.h +++ b/JSON/include/Poco/JSON/Template.h @@ -39,14 +39,13 @@ #define JSON_JSONTemplate_INCLUDED -#include -#include - #include "Poco/JSON/JSON.h" #include "Poco/Dynamic/Var.h" #include "Poco/SharedPtr.h" #include "Poco/Path.h" #include "Poco/Timestamp.h" +#include +#include namespace Poco { @@ -66,106 +65,91 @@ class JSON_API Template /// conditional output, ... /// /// All text is send to the outputstream. A command is placed - /// between . + /// between + /// + /// ---- /// /// These are the available commands: - /// - /// The result of the query is send to the output stream - /// This command can also be written as - /// - /// When the result of query is true, all the text between - /// if and else (or endif when there is no else) is send to the - /// output stream. When the result of query is false, all the text - /// between else and endif is send to the output stream. An empty - /// object, an empty array or a null value is considered as a false value. - /// For numbers a zero is false. An empty String is also false. - /// - /// This can be used to check the existance of the value. - /// Use this for example when a zero value is ok (which returns false for . - /// - /// The result of the query must be an array. For each element - /// in the array the text between for and endfor is send to the - /// output stream. The active element is stored in the variable. - /// - /// Includes a template. When the filename is relative it will try - /// to resolve the filename against the active template. When this - /// file doesn't exist, it can still be found when the JSONTemplateCache - /// is used. + /// + /// + /// ---- + /// The result of the query is send to the output stream + /// This command can also be written as + /// + /// + /// ---- + /// When the result of query is true, all the text between + /// if and else (or endif when there is no else) is send to the + /// output stream. When the result of query is false, all the text + /// between else and endif is send to the output stream. An empty + /// object, an empty array or a null value is considered as a false value. + /// For numbers a zero is false. An empty String is also false. + /// + /// + /// ---- + /// This can be used to check the existance of the value. + /// Use this for example when a zero value is ok (which returns false for . + /// + /// + /// ---- + /// The result of the query must be an array. For each element + /// in the array the text between for and endfor is send to the + /// output stream. The active element is stored in the variable. + /// + /// + /// ---- + /// Includes a template. When the filename is relative it will try + /// to resolve the filename against the active template. When this + /// file doesn't exist, it can still be found when the JSONTemplateCache + /// is used. /// /// A query is passed to Poco::JSON::Query to get the value. { public: typedef SharedPtr