- VS2012: build/tests

- JSON: style and exceptions catch by ref fix
- NumberParser: case-insensitive hex parsing
- Dynamic::Var: const std::string& cast operator specialization (coaxing std::string ctor)
- LocalDateTime: strftime fix (buffer too small for full tz string, use %Z instead of %z - makes no difference on windows but is more portable)
- small buildwin.cmd vsvars32.bat call fix
This commit is contained in:
Aleksandar Fabijanic
2012-09-24 03:51:40 +00:00
parent a6cc973fe3
commit d8397b9153
30 changed files with 3715 additions and 3739 deletions

View File

@@ -38,13 +38,17 @@
#include "Poco/JSON/TemplateCache.h"
#include "Poco/JSON/Query.h"
namespace Poco
{
namespace JSON
{
using Poco::Dynamic::Var;
namespace Poco {
namespace JSON {
POCO_IMPLEMENT_EXCEPTION(JSONTemplateException, Exception, "Template Exception")
class Part
{
public:
@@ -58,11 +62,12 @@ public:
{
}
virtual void render(const DynamicAny& data, std::ostream& out) const = 0;
virtual void render(const Var& data, std::ostream& out) const = 0;
typedef std::vector<SharedPtr<Part> > VectorParts;
};
class StringPart : public Part
{
public:
@@ -81,7 +86,7 @@ public:
}
void render(const DynamicAny& data, std::ostream& out) const
void render(const Var& data, std::ostream& out) const
{
out << _content;
}
@@ -103,6 +108,7 @@ private:
std::string _content;
};
class MultiPart : public Part
{
public:
@@ -125,7 +131,7 @@ public:
}
void render(const DynamicAny& 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)
{
@@ -138,6 +144,7 @@ protected:
VectorParts _parts;
};
class EchoPart : public Part
{
public:
@@ -151,10 +158,10 @@ public:
}
void render(const DynamicAny& data, std::ostream& out) const
void render(const Var& data, std::ostream& out) const
{
Query query(data);
DynamicAny value = query.find(_query);
Var value = query.find(_query);
if ( ! value.isEmpty() )
{
@@ -167,6 +174,7 @@ private:
std::string _query;
};
class LogicQuery
{
public:
@@ -178,18 +186,18 @@ public:
{
}
virtual bool apply(const DynamicAny& data) const
virtual bool apply(const Var& data) const
{
bool logic = false;
Query query(data);
DynamicAny value = query.find(_queryString);
Var value = query.find(_queryString);
if ( ! value.isEmpty() ) // When empty, logic will be false
{
if ( value.isString() )
// An empty string must result in false, otherwise true
// Which is not the case when we convert to bool with DynamicAny
// Which is not the case when we convert to bool with Var
{
std::string s = value.convert<std::string>();
logic = ! s.empty();
@@ -198,7 +206,7 @@ public:
{
// All other values, try to convert to bool
// An empty object or array will turn into false
// all other values depend on the convert<> in DynamicAny
// all other values depend on the convert<> in Var
logic = value.convert<bool>();
}
}
@@ -210,6 +218,7 @@ protected:
std::string _queryString;
};
class LogicExistQuery : public LogicQuery
{
public:
@@ -221,10 +230,10 @@ public:
{
}
virtual bool apply(const DynamicAny& data) const
virtual bool apply(const Var& data) const
{
Query query(data);
DynamicAny value = query.find(_queryString);
Var value = query.find(_queryString);
return !value.isEmpty();
}
@@ -242,7 +251,7 @@ public:
{
}
virtual bool apply(const DynamicAny& data) const
virtual bool apply(const Var& data) const
{
return true;
}
@@ -273,7 +282,7 @@ public:
_queries.push_back(new LogicElseQuery());
}
void render(const DynamicAny& data, std::ostream& out) const
void render(const Var& data, std::ostream& out) const
{
int count = 0;
for(std::vector<SharedPtr<LogicQuery> >::const_iterator it = _queries.begin(); it != _queries.end(); ++it, ++count)
@@ -291,6 +300,7 @@ private:
std::vector<SharedPtr<LogicQuery> > _queries;
};
class LoopPart : public MultiPart
{
public:
@@ -304,7 +314,7 @@ public:
}
void render(const DynamicAny& data, std::ostream& out) const
void render(const Var& data, std::ostream& out) const
{
Query query(data);
@@ -316,7 +326,7 @@ public:
{
for(int i = 0; i < array->size(); i++)
{
DynamicAny value = array->get(i);
Var value = array->get(i);
dataObject->set(_name, value);
MultiPart::render(data, out);
}
@@ -361,7 +371,7 @@ public:
}
void render(const DynamicAny& data, std::ostream& out) const
void render(const Var& data, std::ostream& out) const
{
TemplateCache* cache = TemplateCache::instance();
if ( cache == NULL )
@@ -383,12 +393,14 @@ private:
};
Template::Template(const Path& templatePath)
: _parts(NULL)
, _templatePath(templatePath)
{
}
Template::Template()
: _parts(NULL)
{
@@ -713,6 +725,7 @@ void Template::readWhiteSpace(std::istream& in)
}
}
std::string Template::readString(std::istream& in)
{
std::string str;
@@ -728,9 +741,11 @@ std::string Template::readString(std::istream& in)
return str;
}
void Template::render(const DynamicAny& data, std::ostream& out) const
void Template::render(const Var& data, std::ostream& out) const
{
_parts->render(data, out);
}
}} // Namespace Poco::JSON