mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-25 16:13:42 +01:00
code cleanups
This commit is contained in:
parent
ac8c9ad1ca
commit
eb8c662c4c
@ -35,27 +35,28 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_Array_INCLUDED
|
#ifndef JSON_Array_INCLUDED
|
||||||
#define JSON_Array_INCLUDED
|
#define JSON_Array_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "Poco/JSON/JSON.h"
|
#include "Poco/JSON/JSON.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Dynamic/Var.h"
|
#include "Poco/Dynamic/Var.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
class Object;
|
class Object;
|
||||||
|
|
||||||
|
|
||||||
class JSON_API Array
|
class JSON_API Array
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::vector<Dynamic::Var> ValueVector;
|
typedef std::vector<Dynamic::Var> ValueVector;
|
||||||
typedef SharedPtr<Array> Ptr;
|
typedef SharedPtr<Array> Ptr;
|
||||||
|
|
||||||
@ -199,6 +200,7 @@ inline void Array::remove(unsigned int index)
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Dynamic {
|
namespace Dynamic {
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class VarHolderImpl<JSON::Array::Ptr>: public VarHolder
|
class VarHolderImpl<JSON::Array::Ptr>: public VarHolder
|
||||||
{
|
{
|
||||||
@ -337,6 +339,7 @@ private:
|
|||||||
JSON::Array::Ptr _val;
|
JSON::Array::Ptr _val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_DefaultHandler_INCLUDED
|
#ifndef JSON_DefaultHandler_INCLUDED
|
||||||
#define JSON_DefaultHandler_INCLUDED
|
#define JSON_DefaultHandler_INCLUDED
|
||||||
|
|
||||||
@ -154,4 +155,5 @@ inline void DefaultHandler::null()
|
|||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
#endif // JSON_DefaultHandler_INCLUDED
|
#endif // JSON_DefaultHandler_INCLUDED
|
||||||
|
@ -35,12 +35,14 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_Handler_INCLUDED
|
#ifndef JSON_Handler_INCLUDED
|
||||||
#define JSON_Handler_INCLUDED
|
#define JSON_Handler_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Dynamic/Var.h"
|
|
||||||
#include "Poco/JSON/JSON.h"
|
#include "Poco/JSON/JSON.h"
|
||||||
|
#include "Poco/Dynamic/Var.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
@ -95,4 +97,5 @@ private:
|
|||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
#endif // JSON_Handler_INCLUDED
|
#endif // JSON_Handler_INCLUDED
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_JSONException_INCLUDED
|
#ifndef JSON_JSONException_INCLUDED
|
||||||
#define JSON_JSONException_INCLUDED
|
#define JSON_JSONException_INCLUDED
|
||||||
|
|
||||||
@ -46,8 +47,10 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(JSON_API, JSONException, Poco::Exception)
|
POCO_DECLARE_EXCEPTION(JSON_API, JSONException, Poco::Exception)
|
||||||
|
|
||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,30 +35,29 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_Object_INCLUDED
|
#ifndef JSON_Object_INCLUDED
|
||||||
#define 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 <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "Poco/SharedPtr.h"
|
|
||||||
#include "Poco/Dynamic/Var.h"
|
|
||||||
|
|
||||||
#include "Poco/JSON/JSON.h"
|
|
||||||
#include "Poco/JSON/Array.h"
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
class JSON_API Object
|
class JSON_API Object
|
||||||
/// Represents a JSON object
|
/// Represents a JSON object.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SharedPtr<Object> Ptr;
|
typedef SharedPtr<Object> Ptr;
|
||||||
|
|
||||||
Object();
|
Object();
|
||||||
@ -344,6 +343,7 @@ private:
|
|||||||
JSON::Object::Ptr _val;
|
JSON::Object::Ptr _val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,68 +35,66 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_JSONParser_INCLUDED
|
#ifndef JSON_JSONParser_INCLUDED
|
||||||
#define JSON_JSONParser_INCLUDED
|
#define JSON_JSONParser_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <istream>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "Poco/Dynamic/Var.h"
|
|
||||||
#include "Poco/StreamTokenizer.h"
|
|
||||||
|
|
||||||
#include "Poco/JSON/JSON.h"
|
#include "Poco/JSON/JSON.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "Poco/JSON/Array.h"
|
#include "Poco/JSON/Array.h"
|
||||||
#include "Poco/JSON/Handler.h"
|
#include "Poco/JSON/Handler.h"
|
||||||
|
#include "Poco/Dynamic/Var.h"
|
||||||
|
#include "Poco/StreamTokenizer.h"
|
||||||
|
#include <istream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
class JSON_API Parser
|
class JSON_API Parser
|
||||||
/// A class for passing JSON strings or streams
|
/// A class for passing JSON strings or streams.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Parser();
|
Parser();
|
||||||
/// Constructor
|
/// Constructor.
|
||||||
|
|
||||||
virtual ~Parser();
|
virtual ~Parser();
|
||||||
/// Destructor
|
/// Destructor.
|
||||||
|
|
||||||
void parse(const std::string& source);
|
void parse(const std::string& source);
|
||||||
/// Parses a string
|
/// Parses a string.
|
||||||
|
|
||||||
void parse(std::istream& in);
|
void parse(std::istream& in);
|
||||||
/// Parses a JSON from the input stream
|
/// Parses a JSON from the input stream.
|
||||||
|
|
||||||
void setHandler(Handler* handler);
|
void setHandler(Handler* handler);
|
||||||
/// Set the handler
|
/// Set the handler.
|
||||||
|
|
||||||
Handler* getHandler();
|
Handler* getHandler();
|
||||||
/// Returns the handler
|
/// Returns the handler.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Token* nextToken();
|
const Token* nextToken();
|
||||||
/// Returns the next token
|
/// Returns the next token.
|
||||||
|
|
||||||
void readObject();
|
void readObject();
|
||||||
/// Starts reading an object
|
/// Starts reading an object.
|
||||||
|
|
||||||
|
|
||||||
void readArray();
|
void readArray();
|
||||||
/// Starts reading an array
|
/// Starts reading an array.
|
||||||
|
|
||||||
bool readRow(bool firstCall = false);
|
bool readRow(bool firstCall = false);
|
||||||
/// Reads a property value pair. Returns true when a next row is expected.
|
/// Reads a property value pair. Returns true when a next row is expected.
|
||||||
|
|
||||||
void readValue(const Token* token);
|
void readValue(const Token* token);
|
||||||
/// Read a value from the token
|
/// Read a value from the token.
|
||||||
|
|
||||||
bool readElements(bool firstCall = false);
|
bool readElements(bool firstCall = false);
|
||||||
/// Read all elements of an array
|
/// Read all elements of an array.
|
||||||
|
|
||||||
StreamTokenizer _tokenizer;
|
StreamTokenizer _tokenizer;
|
||||||
Handler* _handler;
|
Handler* _handler;
|
||||||
|
@ -35,14 +35,15 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef JSON_JSONStringifier_INCLUDED
|
#ifndef JSON_JSONStringifier_INCLUDED
|
||||||
#define JSON_JSONStringifier_INCLUDED
|
#define JSON_JSONStringifier_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "Poco/Dynamic/Var.h"
|
#include "Poco/Dynamic/Var.h"
|
||||||
#include "Poco/JSON/JSON.h"
|
#include "Poco/JSON/JSON.h"
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
@ -52,7 +53,6 @@ class JSON_API Stringifier
|
|||||||
/// Helper class for creating a String from a JSON object or array
|
/// Helper class for creating a String from a JSON object or array
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void stringify(const Dynamic::Var& any, std::ostream& out, unsigned int indent = 0);
|
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.
|
/// Writes a String representation of the value to the output stream.
|
||||||
/// When indent is 0, the String will be created as small as possible.
|
/// When indent is 0, the String will be created as small as possible.
|
||||||
@ -61,4 +61,5 @@ public:
|
|||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
#endif // JSON_JSONStringifier_INCLUDED
|
#endif // JSON_JSONStringifier_INCLUDED
|
||||||
|
@ -39,14 +39,13 @@
|
|||||||
#define JSON_JSONTemplate_INCLUDED
|
#define JSON_JSONTemplate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
#include "Poco/JSON/JSON.h"
|
#include "Poco/JSON/JSON.h"
|
||||||
#include "Poco/Dynamic/Var.h"
|
#include "Poco/Dynamic/Var.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -66,106 +65,91 @@ class JSON_API Template
|
|||||||
/// conditional output, ...
|
/// conditional output, ...
|
||||||
///
|
///
|
||||||
/// All text is send to the outputstream. A command is placed
|
/// All text is send to the outputstream. A command is placed
|
||||||
/// between <? and ?>.
|
/// between
|
||||||
|
/// <?
|
||||||
|
/// and
|
||||||
|
/// ?>
|
||||||
|
/// ----
|
||||||
///
|
///
|
||||||
/// These are the available commands:
|
/// These are the available commands:
|
||||||
/// <? echo query ?>
|
///
|
||||||
/// The result of the query is send to the output stream
|
/// <? echo query ?>
|
||||||
/// This command can also be written as <?= query ?>
|
/// ----
|
||||||
/// <? if query ?> <? else ?> <? endif ?>
|
/// The result of the query is send to the output stream
|
||||||
/// When the result of query is true, all the text between
|
/// This command can also be written as <?= query ?>
|
||||||
/// 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
|
/// <? if query ?> <? else ?> <? endif ?>
|
||||||
/// 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.
|
/// When the result of query is true, all the text between
|
||||||
/// For numbers a zero is false. An empty String is also false.
|
/// if and else (or endif when there is no else) is send to the
|
||||||
/// <? ifexist query ?> <? else ?> <? endif ?>
|
/// output stream. When the result of query is false, all the text
|
||||||
/// This can be used to check the existance of the value.
|
/// between else and endif is send to the output stream. An empty
|
||||||
/// Use this for example when a zero value is ok (which returns false for <? if ?>.
|
/// object, an empty array or a null value is considered as a false value.
|
||||||
/// <? for variable query ?> <? endfor ?>
|
/// For numbers a zero is false. An empty String is also false.
|
||||||
/// 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
|
/// <? ifexist query ?> <? else ?> <? endif ?>
|
||||||
/// output stream. The active element is stored in the variable.
|
/// ----
|
||||||
/// <? include "filename" ?>
|
/// This can be used to check the existance of the value.
|
||||||
/// Includes a template. When the filename is relative it will try
|
/// Use this for example when a zero value is ok (which returns false for <? if ?>.
|
||||||
/// to resolve the filename against the active template. When this
|
///
|
||||||
/// file doesn't exist, it can still be found when the JSONTemplateCache
|
/// <? for variable query ?> <? endfor ?>
|
||||||
/// is used.
|
/// ----
|
||||||
|
/// 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.
|
||||||
|
///
|
||||||
|
/// <? include "filename" ?>
|
||||||
|
/// ----
|
||||||
|
/// 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.
|
/// A query is passed to Poco::JSON::Query to get the value.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef SharedPtr<Template> Ptr;
|
typedef SharedPtr<Template> Ptr;
|
||||||
|
|
||||||
|
|
||||||
Template();
|
Template();
|
||||||
/// Constructor
|
/// Constructor.
|
||||||
|
|
||||||
|
|
||||||
Template(const Path& templatePath);
|
Template(const Path& templatePath);
|
||||||
/// Constructor. Creates a template from a file.
|
/// Constructor. Creates a template from a file.
|
||||||
|
|
||||||
|
|
||||||
virtual ~Template();
|
virtual ~Template();
|
||||||
/// Destructor
|
/// Destructor.
|
||||||
|
|
||||||
|
|
||||||
void parse();
|
void parse();
|
||||||
/// Parse a template from a file
|
/// Parse a template from a file.
|
||||||
|
|
||||||
|
|
||||||
void parse(const std::string& source);
|
void parse(const std::string& source);
|
||||||
/// Parse a template from a String
|
/// Parse a template from a string.
|
||||||
|
|
||||||
|
|
||||||
void parse(std::istream& in);
|
void parse(std::istream& in);
|
||||||
/// Parse a template from a input stream
|
/// Parse a template from a input stream.
|
||||||
|
|
||||||
|
|
||||||
Timestamp parseTime() const;
|
Timestamp parseTime() const;
|
||||||
/// Returns the time when the template was parsed
|
/// Returns the time when the template was parsed.
|
||||||
|
|
||||||
|
|
||||||
void render(const Dynamic::Var& data, std::ostream& out) const;
|
void render(const Dynamic::Var& data, std::ostream& out) const;
|
||||||
/// Renders the template and send the output to the stream
|
/// Renders the template and send the output to the stream.
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
std::string readText(std::istream& in);
|
std::string readText(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
std::string readWord(std::istream& in);
|
std::string readWord(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
std::string readQuery(std::istream& in);
|
std::string readQuery(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
std::string readTemplateCommand(std::istream& in);
|
std::string readTemplateCommand(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
std::string readString(std::istream& in);
|
std::string readString(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
void readWhiteSpace(std::istream& in);
|
void readWhiteSpace(std::istream& in);
|
||||||
|
|
||||||
|
|
||||||
MultiPart* _parts;
|
MultiPart* _parts;
|
||||||
|
|
||||||
|
|
||||||
std::stack<MultiPart*> _partStack;
|
std::stack<MultiPart*> _partStack;
|
||||||
|
|
||||||
|
|
||||||
MultiPart* _currentPart;
|
MultiPart* _currentPart;
|
||||||
|
|
||||||
|
|
||||||
Path _templatePath;
|
Path _templatePath;
|
||||||
|
|
||||||
|
|
||||||
Timestamp _parseTime;
|
Timestamp _parseTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void Template::parse(const std::string& source)
|
inline void Template::parse(const std::string& source)
|
||||||
{
|
{
|
||||||
std::istringstream is(source);
|
std::istringstream is(source);
|
||||||
@ -178,6 +162,8 @@ inline Timestamp Template::parseTime() const
|
|||||||
return _parseTime;
|
return _parseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // namespace Poco::JSON
|
}} // namespace Poco::JSON
|
||||||
|
|
||||||
|
|
||||||
#endif // JSON_JSONTemplate_INCLUDED
|
#endif // JSON_JSONTemplate_INCLUDED
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
#define JSON_JSONTemplateCache_INCLUDED
|
#define JSON_JSONTemplateCache_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include "Poco/JSON/JSON.h"
|
||||||
#include <map>
|
#include "Poco/JSON/Template.h"
|
||||||
|
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Logger.h"
|
#include "Poco/Logger.h"
|
||||||
#include "Poco/JSON/Template.h"
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@ -60,13 +60,12 @@ class JSON_API TemplateCache
|
|||||||
/// and load a new one.
|
/// and load a new one.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TemplateCache();
|
TemplateCache();
|
||||||
/// Constructor. The cache must be created
|
/// Constructor. The cache must be created
|
||||||
/// and not destroyed as long as it is used.
|
/// and not destroyed as long as it is used.
|
||||||
|
|
||||||
virtual ~TemplateCache();
|
virtual ~TemplateCache();
|
||||||
/// Destructor
|
/// Destructor.
|
||||||
|
|
||||||
void addPath(const Path& path);
|
void addPath(const Path& path);
|
||||||
/// Add a path for resolving template paths.
|
/// Add a path for resolving template paths.
|
||||||
@ -88,7 +87,6 @@ public:
|
|||||||
/// Sets the logger for the cache.
|
/// Sets the logger for the cache.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static TemplateCache* _instance;
|
static TemplateCache* _instance;
|
||||||
std::vector<Path> _includePaths;
|
std::vector<Path> _includePaths;
|
||||||
std::map<std::string, Template::Ptr> _cache;
|
std::map<std::string, Template::Ptr> _cache;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/JSON/Array.h"
|
#include "Poco/JSON/Array.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "Poco/JSON/Stringifier.h"
|
#include "Poco/JSON/Stringifier.h"
|
||||||
@ -47,19 +48,16 @@ namespace JSON {
|
|||||||
|
|
||||||
Array::Array()
|
Array::Array()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Array::Array(const Array& copy) : _values(copy._values)
|
Array::Array(const Array& copy) : _values(copy._values)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Array::~Array()
|
Array::~Array()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,4 +151,4 @@ void Array::stringify(std::ostream& out, unsigned int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
} } // namespace Poco::JSON
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/JSON/DefaultHandler.h"
|
#include "Poco/JSON/DefaultHandler.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
|
|
||||||
@ -151,4 +152,4 @@ void DefaultHandler::setValue(const Var& value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
} } // namespace Poco::JSON
|
||||||
|
@ -33,16 +33,18 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/JSON/Handler.h"
|
#include "Poco/JSON/Handler.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
|
|
||||||
namespace Poco
|
|
||||||
{
|
namespace Poco {
|
||||||
namespace JSON
|
namespace JSON {
|
||||||
{
|
|
||||||
|
|
||||||
Handler::~Handler()
|
Handler::~Handler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
|
||||||
|
} } // namespace Poco::JSON
|
||||||
|
@ -33,12 +33,16 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/JSON/JSONException.h"
|
#include "Poco/JSON/JSONException.h"
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
POCO_IMPLEMENT_EXCEPTION(JSONException, Exception, "JSON Exception")
|
POCO_IMPLEMENT_EXCEPTION(JSONException, Exception, "JSON Exception")
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
|
||||||
|
} } // Namespace Poco::JSON
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "Poco/JSON/Array.h"
|
#include "Poco/JSON/Array.h"
|
||||||
#include "Poco/JSON/Stringifier.h"
|
#include "Poco/JSON/Stringifier.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ void Object::stringify(std::ostream& out, unsigned int indent) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
out << '}';
|
out << '}';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
|
||||||
|
} } // namespace Poco::JSON
|
||||||
|
@ -33,19 +33,18 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Poco/Ascii.h"
|
|
||||||
#include "Poco/Token.h"
|
|
||||||
#include "Poco/JSON/Parser.h"
|
#include "Poco/JSON/Parser.h"
|
||||||
#include "Poco/JSON/JSONException.h"
|
#include "Poco/JSON/JSONException.h"
|
||||||
|
#include "Poco/Ascii.h"
|
||||||
|
#include "Poco/Token.h"
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco
|
namespace Poco {
|
||||||
{
|
namespace JSON {
|
||||||
namespace JSON
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
class SeparatorToken: public Token
|
class SeparatorToken: public Token
|
||||||
@ -90,6 +89,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class StringToken: public Token
|
class StringToken: public Token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -243,6 +243,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class KeywordToken : public Token
|
class KeywordToken : public Token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -281,6 +282,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class NumberToken: public Token
|
class NumberToken: public Token
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -418,9 +420,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Class _activeClass;
|
Class _activeClass;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -697,4 +697,4 @@ bool Parser::readElements(bool firstCall)
|
|||||||
throw JSONException(format("Invalid token '%s' found.", token->asString()));
|
throw JSONException(format("Invalid token '%s' found.", token->asString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
} } // namespace Poco::JSON
|
||||||
|
@ -33,13 +33,12 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
|
#include "Poco/JSON/Query.h"
|
||||||
#include "Poco/StringTokenizer.h"
|
#include "Poco/StringTokenizer.h"
|
||||||
#include "Poco/RegularExpression.h"
|
#include "Poco/RegularExpression.h"
|
||||||
#include "Poco/NumberParser.h"
|
#include "Poco/NumberParser.h"
|
||||||
|
#include <sstream>
|
||||||
#include "Poco/JSON/Query.h"
|
|
||||||
|
|
||||||
|
|
||||||
using Poco::Dynamic::Var;
|
using Poco::Dynamic::Var;
|
||||||
@ -49,7 +48,7 @@ namespace Poco {
|
|||||||
namespace JSON {
|
namespace JSON {
|
||||||
|
|
||||||
|
|
||||||
Query::Query(const Var& source) : _source(source)
|
Query::Query(const Var& source): _source(source)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -145,4 +144,4 @@ Var Query::find(const std::string& path) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
} } // Namespace Poco::JSON
|
||||||
|
@ -33,11 +33,11 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
#include "Poco/JSON/Stringifier.h"
|
#include "Poco/JSON/Stringifier.h"
|
||||||
#include "Poco/JSON/Array.h"
|
#include "Poco/JSON/Array.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
using Poco::Dynamic::Var;
|
using Poco::Dynamic::Var;
|
||||||
@ -115,4 +115,4 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
} } // Namespace Poco::JSON
|
||||||
|
@ -32,11 +32,13 @@
|
|||||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
#include "Poco/File.h"
|
|
||||||
#include "Poco/FileStream.h"
|
|
||||||
#include "Poco/JSON/Template.h"
|
#include "Poco/JSON/Template.h"
|
||||||
#include "Poco/JSON/TemplateCache.h"
|
#include "Poco/JSON/TemplateCache.h"
|
||||||
#include "Poco/JSON/Query.h"
|
#include "Poco/JSON/Query.h"
|
||||||
|
#include "Poco/File.h"
|
||||||
|
#include "Poco/FileStream.h"
|
||||||
|
|
||||||
|
|
||||||
using Poco::Dynamic::Var;
|
using Poco::Dynamic::Var;
|
||||||
@ -52,12 +54,10 @@ POCO_IMPLEMENT_EXCEPTION(JSONTemplateException, Exception, "Template Exception")
|
|||||||
class Part
|
class Part
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Part()
|
Part()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual ~Part()
|
virtual ~Part()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -68,10 +68,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class StringPart : public Part
|
class StringPart: public Part
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StringPart() : Part()
|
StringPart() : Part()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -80,57 +79,46 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual ~StringPart()
|
virtual ~StringPart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render(const Var& data, std::ostream& out) const
|
void render(const Var& data, std::ostream& out) const
|
||||||
{
|
{
|
||||||
out << _content;
|
out << _content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setContent(const std::string& content)
|
void setContent(const std::string& content)
|
||||||
{
|
{
|
||||||
_content = content;
|
_content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::string getContent() const
|
inline std::string getContent() const
|
||||||
{
|
{
|
||||||
return _content;
|
return _content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _content;
|
std::string _content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MultiPart : public Part
|
class MultiPart: public Part
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MultiPart()
|
MultiPart()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual ~MultiPart()
|
virtual ~MultiPart()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void addPart(Part* part)
|
virtual void addPart(Part* part)
|
||||||
{
|
{
|
||||||
_parts.push_back(part);
|
_parts.push_back(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render(const Var& data, std::ostream& out) const
|
void render(const Var& data, std::ostream& out) const
|
||||||
{
|
{
|
||||||
for(VectorParts::const_iterator it = _parts.begin(); it != _parts.end(); ++it)
|
for(VectorParts::const_iterator it = _parts.begin(); it != _parts.end(); ++it)
|
||||||
@ -140,15 +128,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
VectorParts _parts;
|
VectorParts _parts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class EchoPart : public Part
|
class EchoPart: public Part
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EchoPart(const std::string& query) : Part(), _query(query)
|
EchoPart(const std::string& query) : Part(), _query(query)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -157,7 +143,6 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render(const Var& data, std::ostream& out) const
|
void render(const Var& data, std::ostream& out) const
|
||||||
{
|
{
|
||||||
Query query(data);
|
Query query(data);
|
||||||
@ -170,7 +155,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _query;
|
std::string _query;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -261,7 +245,6 @@ public:
|
|||||||
class LogicPart : public MultiPart
|
class LogicPart : public MultiPart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LogicPart() : MultiPart()
|
LogicPart() : MultiPart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -296,22 +279,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<SharedPtr<LogicQuery> > _queries;
|
std::vector<SharedPtr<LogicQuery> > _queries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LoopPart : public MultiPart
|
class LoopPart: public MultiPart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoopPart(const std::string& name, const std::string& query) : MultiPart(), _name(name), _query(query)
|
LoopPart(const std::string& name, const std::string& query) : MultiPart(), _name(name), _query(query)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~LoopPart()
|
virtual ~LoopPart()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void render(const Var& data, std::ostream& out) const
|
void render(const Var& data, std::ostream& out) const
|
||||||
@ -336,14 +316,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
std::string _query;
|
std::string _query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class IncludePart : public Part
|
class IncludePart: public Part
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -370,7 +348,6 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render(const Var& data, std::ostream& out) const
|
void render(const Var& data, std::ostream& out) const
|
||||||
{
|
{
|
||||||
TemplateCache* cache = TemplateCache::instance();
|
TemplateCache* cache = TemplateCache::instance();
|
||||||
@ -388,9 +365,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Path _path;
|
Path _path;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -748,4 +723,4 @@ void Template::render(const Var& data, std::ostream& out) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // Namespace Poco::JSON
|
} } // Namespace Poco::JSON
|
||||||
|
@ -33,16 +33,18 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
#include "Poco/JSON/TemplateCache.h"
|
#include "Poco/JSON/TemplateCache.h"
|
||||||
|
|
||||||
namespace Poco
|
|
||||||
{
|
namespace Poco {
|
||||||
namespace JSON
|
namespace JSON {
|
||||||
{
|
|
||||||
|
|
||||||
TemplateCache* TemplateCache::_instance = NULL;
|
TemplateCache* TemplateCache::_instance = NULL;
|
||||||
|
|
||||||
|
|
||||||
TemplateCache::TemplateCache() : _logger(NULL)
|
TemplateCache::TemplateCache() : _logger(NULL)
|
||||||
{
|
{
|
||||||
setup();
|
setup();
|
||||||
@ -169,4 +171,5 @@ Path TemplateCache::resolvePath(const Path& path) const
|
|||||||
throw FileNotFoundException(path.toString());
|
throw FileNotFoundException(path.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // Poco::JSON
|
|
||||||
|
} } // Poco::JSON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user