fix windows build (includes update to inja.hpp 57ac9b93725cb)

This commit is contained in:
Juergen E. Fischer 2019-08-07 17:32:43 +02:00
parent 97a002f35a
commit 650f79617c
20 changed files with 67 additions and 41 deletions

View File

@ -500,6 +500,7 @@ IF (PEDANTIC)
SET(_warnings "${_warnings} /wd4231 ") # nonstandard extension used : 'identifier' before template explicit instantiation (used in Qt template classes)
SET(_warnings "${_warnings} /wd4244 ") # conversion from '...' to '...' possible loss of data
SET(_warnings "${_warnings} /wd4251 ") # needs to have dll-interface to be used by clients of class (occurs in Qt template classes)
SET(_warnings "${_warnings} /wd4267 ") # 'argument': conversion from 'size_t' to 'int', possible loss of data
SET(_warnings "${_warnings} /wd4275 ") # non dll-interface class '...' used as base for dll-interface class '...'
SET(_warnings "${_warnings} /wd4290 ") # c++ exception specification ignored except to indicate a function is not __declspec(nothrow) (occurs in sip generated bindings)
SET(_warnings "${_warnings} /wd4456 ") # declaration of '...' hides previous local declaration

View File

@ -1441,6 +1441,7 @@ struct Bytecode {
GreaterEqual,
Less,
LessEqual,
At,
Different,
DivisibleBy,
Even,
@ -2017,6 +2018,7 @@ namespace inja {
class ParserStatic {
ParserStatic() {
functions.add_builtin("at", 2, Bytecode::Op::At);
functions.add_builtin("default", 2, Bytecode::Op::Default);
functions.add_builtin("divisibleBy", 2, Bytecode::Op::DivisibleBy);
functions.add_builtin("even", 1, Bytecode::Op::Even);
@ -2062,7 +2064,7 @@ class Parser {
bool parse_expression(Template& tmpl) {
if (!parse_expression_and(tmpl)) return false;
if (m_tok.kind != Token::Kind::Id || m_tok.text != "or") return true;
if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("or")) return true;
get_next_token();
if (!parse_expression_and(tmpl)) return false;
append_function(tmpl, Bytecode::Op::Or, 2);
@ -2071,7 +2073,7 @@ class Parser {
bool parse_expression_and(Template& tmpl) {
if (!parse_expression_not(tmpl)) return false;
if (m_tok.kind != Token::Kind::Id || m_tok.text != "and") return true;
if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("and")) return true;
get_next_token();
if (!parse_expression_not(tmpl)) return false;
append_function(tmpl, Bytecode::Op::And, 2);
@ -2079,7 +2081,7 @@ class Parser {
}
bool parse_expression_not(Template& tmpl) {
if (m_tok.kind == Token::Kind::Id && m_tok.text == "not") {
if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("not")) {
get_next_token();
if (!parse_expression_not(tmpl)) return false;
append_function(tmpl, Bytecode::Op::Not, 1);
@ -2094,7 +2096,7 @@ class Parser {
Bytecode::Op op;
switch (m_tok.kind) {
case Token::Kind::Id:
if (m_tok.text == "in")
if (m_tok.text == static_cast<decltype(m_tok.text)>("in"))
op = Bytecode::Op::In;
else
return true;
@ -2182,7 +2184,9 @@ class Parser {
append_callback(tmpl, func_token.text, num_args);
return true;
}
} else if (m_tok.text == "true" || m_tok.text == "false" || m_tok.text == "null") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("true") ||
m_tok.text == static_cast<decltype(m_tok.text)>("false") ||
m_tok.text == static_cast<decltype(m_tok.text)>("null")) {
// true, false, null are json literals
if (brace_level == 0 && bracket_level == 0) {
json_first = m_tok.text;
@ -2261,7 +2265,7 @@ class Parser {
bool parse_statement(Template& tmpl, nonstd::string_view path) {
if (m_tok.kind != Token::Kind::Id) return false;
if (m_tok.text == "if") {
if (m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
get_next_token();
// evaluate expression
@ -2272,7 +2276,7 @@ class Parser {
// conditional jump; destination will be filled in by else or endif
tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
} else if (m_tok.text == "endif") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("endif")) {
if (m_if_stack.empty()) {
inja_throw("parser_error", "endif without matching if");
}
@ -2291,7 +2295,7 @@ class Parser {
// pop if stack
m_if_stack.pop_back();
} else if (m_tok.text == "else") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("else")) {
if (m_if_stack.empty())
inja_throw("parser_error", "else without matching if");
auto& if_data = m_if_stack.back();
@ -2307,7 +2311,7 @@ class Parser {
if_data.prev_cond_jump = std::numeric_limits<unsigned int>::max();
// chained else if
if (m_tok.kind == Token::Kind::Id && m_tok.text == "if") {
if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
get_next_token();
// evaluate expression
@ -2319,7 +2323,7 @@ class Parser {
// conditional jump; destination will be filled in by else or endif
tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
}
} else if (m_tok.text == "for") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("for")) {
get_next_token();
// options: for a in arr; for a, b in obj
@ -2338,7 +2342,7 @@ class Parser {
get_next_token();
}
if (m_tok.kind != Token::Kind::Id || m_tok.text != "in")
if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("in"))
inja_throw("parser_error",
"expected 'in', got '" + m_tok.describe() + "'");
get_next_token();
@ -2352,7 +2356,7 @@ class Parser {
tmpl.bytecodes.back().value = key_token.text;
}
tmpl.bytecodes.back().str = static_cast<std::string>(value_token.text);
} else if (m_tok.text == "endfor") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("endfor")) {
get_next_token();
if (m_loop_stack.empty()) {
inja_throw("parser_error", "endfor without matching for");
@ -2364,7 +2368,7 @@ class Parser {
tmpl.bytecodes.emplace_back(Bytecode::Op::EndLoop);
tmpl.bytecodes.back().args = m_loop_stack.back() + 1; // loop body
m_loop_stack.pop_back();
} else if (m_tok.text == "include") {
} else if (m_tok.text == static_cast<decltype(m_tok.text)>("include")) {
get_next_token();
if (m_tok.kind != Token::Kind::String) {
@ -2736,8 +2740,8 @@ class Renderer {
enum class Type { Map, Array };
Type loop_type;
nonstd::string_view key_name; // variable name for keys
nonstd::string_view value_name; // variable name for values
nonstd::string_view key_name; // variable name for keys
nonstd::string_view value_name; // variable name for values
json data; // data with loop info added
json values; // values to iterate over
@ -2749,8 +2753,8 @@ class Renderer {
// loop over map
using KeyValue = std::pair<nonstd::string_view, json*>;
using MapValues = std::vector<KeyValue>;
MapValues map_values; // values to iterate over
MapValues::iterator map_it; // iterator over values
MapValues map_values; // values to iterate over
MapValues::iterator map_it; // iterator over values
};
@ -2784,11 +2788,11 @@ class Renderer {
}
case Bytecode::Op::PrintValue: {
const json& val = *get_args(bc)[0];
if (val.is_string())
if (val.is_string()) {
os << val.get_ref<const std::string&>();
else
} else {
os << val.dump();
// val.dump(os);
}
pop_args(bc);
break;
}
@ -2819,7 +2823,15 @@ class Renderer {
break;
}
case Bytecode::Op::Length: {
auto result = get_args(bc)[0]->size();
const json& val = *get_args(bc)[0];
int result;
if (val.is_string()) {
result = val.get_ref<const std::string&>().length();
} else {
result = val.size();
}
pop_args(bc);
m_stack.emplace_back(result);
break;
@ -2831,6 +2843,13 @@ class Renderer {
m_stack.emplace_back(std::move(result));
break;
}
case Bytecode::Op::At: {
auto args = get_args(bc);
auto result = args[0]->at(args[1]->get<int>());
pop_args(bc);
m_stack.emplace_back(result);
break;
}
case Bytecode::Op::First: {
auto result = get_args(bc)[0]->front();
pop_args(bc);
@ -3187,7 +3206,7 @@ class Environment {
std::unique_ptr<Impl> m_impl;
public:
Environment(): Environment("./") { }
Environment(): Environment("") { }
explicit Environment(const std::string& global_path): m_impl(stdinja::make_unique<Impl>()) {
m_impl->input_path = global_path;

View File

@ -340,7 +340,9 @@ bool QSpatiaLiteResultPrivate::fetchNext( QSqlCachedResult::ValueCache &values,
q->setAt( QSql::AfterLastRow );
return false;
}
#ifndef _MSC_VER // avoid warning
return false;
#endif
}
QSpatiaLiteResult::QSpatiaLiteResult( const QSpatiaLiteDriver *db )

View File

@ -25,7 +25,7 @@
#include "qgspostgresstringutils.h"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann;
#include <QSettings>

View File

@ -26,7 +26,7 @@ email : marco.hugentobler at sourcepole dot com
#ifndef SIP_RUN
#include <nlohmann/json_fwd.hpp>
using json = nlohmann::json;
using namespace nlohmann;
#endif
class QgsMapToPixel;

View File

@ -38,7 +38,7 @@ email : morb at ozemail dot com dot au
#ifndef SIP_RUN
#include <nlohmann/json_fwd.hpp>
using json = nlohmann::json;
using namespace nlohmann;
#endif
class QgsGeometryEngine;

View File

@ -24,7 +24,7 @@
#ifndef SIP_RUN
#include <nlohmann/json_fwd.hpp>
using json = nlohmann::json;
using namespace nlohmann;
#endif
#include <QPointer>

View File

@ -17,7 +17,8 @@
#include "qgsmessagelog.h"
#include <QDebug>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann;
static void jumpSpace( const QString &txt, int &i )
{

View File

@ -1232,7 +1232,7 @@ void QgsTemplatedLineSymbolLayerBase::renderPolylineVertex( const QPolygonF &poi
QgsRenderContext &rc = context.renderContext();
double origAngle = symbolAngle();
int i, maxCount;
int i = -1, maxCount = 0;
bool isRing = false;
QgsExpressionContextScope *scope = new QgsExpressionContextScope();

View File

@ -315,8 +315,9 @@ QVariant QgsStyleModel::data( const QModelIndex &index, int role ) const
default:
return QVariant();
}
return QVariant();
#ifndef _MSC_VER // avoid warning
return QVariant(); // avoid warning
#endif
}
bool QgsStyleModel::setData( const QModelIndex &index, const QVariant &value, int role )

View File

@ -187,7 +187,9 @@ QVariant QgsDateTimeEditWrapper::value() const
}
break;
}
#ifndef _MSC_VER // avoid warnings
return QVariant(); // avoid warnings
#endif
}
void QgsDateTimeEditWrapper::setValue( const QVariant &value )

View File

@ -36,7 +36,7 @@
#include <QCompleter>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann;
QgsValueRelationWidgetWrapper::QgsValueRelationWidgetWrapper( QgsVectorLayer *layer, int fieldIdx, QWidget *editor, QWidget *parent )

View File

@ -509,8 +509,9 @@ QVariant QgsProcessingToolboxModel::data( const QModelIndex &index, int role ) c
default:
return QVariant();
}
#ifndef _MSC_VER // avoid warning
return QVariant();
#endif
}
int QgsProcessingToolboxModel::rowCount( const QModelIndex &parent ) const

View File

@ -42,7 +42,7 @@ email : a.furieri@lqt.it
#include <QRegularExpression>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann;
const QString QgsSpatiaLiteProvider::SPATIALITE_KEY = QStringLiteral( "spatialite" );

View File

@ -32,7 +32,7 @@ class QgsVectorLayer;
#ifndef SIP_RUN
#include "nlohmann/json_fwd.hpp"
using json = nlohmann::json;
using namespace nlohmann;
#endif
/**

View File

@ -28,7 +28,7 @@
#include "nlohmann/json.hpp"
#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif

View File

@ -29,11 +29,10 @@
#include "qgsserverresponse.h"
#include "qgsserverinterface.h"
#include "nlohmann/json.hpp"
#include "inja/inja.hpp"
using json = nlohmann::json;
using namespace nlohmann;
using namespace inja;

View File

@ -24,7 +24,7 @@
#include "inja/inja.hpp"
#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif
class QgsServerApiContext;

View File

@ -27,7 +27,7 @@
#include "nlohmann/json_fwd.hpp"
#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif

View File

@ -893,10 +893,10 @@ void QgsWfs3CollectionsItemsHandler::handleRequest( const QgsServerApiContext &c
// limit & offset
// Apparently the standard set limits 0-10000 (and does not implement paging,
// so we do our own paging with "offset")
const long offset { params.value( QStringLiteral( "offset" ) ).toLongLong( &ok ) };
const qlonglong offset { params.value( QStringLiteral( "offset" ) ).toLongLong( &ok ) };
// TODO: make the max limit configurable
const long limit { params.value( QStringLiteral( "limit" ) ).toLongLong( &ok ) };
const qlonglong limit { params.value( QStringLiteral( "limit" ) ).toLongLong( &ok ) };
// TODO: implement time
const QString time { context.request()->queryParameter( QStringLiteral( "time" ) ) };