Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix windows build (includes update to inja.hpp 57ac9b93725cb)
  • Loading branch information
jef-n committed Aug 7, 2019
1 parent 97a002f commit 650f796
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 41 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -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
Expand Down
63 changes: 41 additions & 22 deletions external/inja/inja.hpp
Expand Up @@ -1441,6 +1441,7 @@ struct Bytecode {
GreaterEqual,
Less,
LessEqual,
At,
Different,
DivisibleBy,
Even,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -2071,15 +2073,15 @@ 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);
return true;
}

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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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");
}
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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");
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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

};

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions external/qspatialite/qsql_spatialite.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp
Expand Up @@ -25,7 +25,7 @@
#include "qgspostgresstringutils.h"

#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann;

#include <QSettings>

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsabstractgeometry.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometry.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsjsonutils.h
Expand Up @@ -24,7 +24,7 @@

#ifndef SIP_RUN
#include <nlohmann/json_fwd.hpp>
using json = nlohmann::json;
using namespace nlohmann;
#endif

#include <QPointer>
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgspostgresstringutils.cpp
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology/qgslinesymbollayer.cpp
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/core/symbology/qgsstylemodel.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/qgsdatetimeeditwrapper.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion src/gui/processing/qgsprocessingtoolboxmodel.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -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" );
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverapiutils.h
Expand Up @@ -32,7 +32,7 @@ class QgsVectorLayer;

#ifndef SIP_RUN
#include "nlohmann/json_fwd.hpp"
using json = nlohmann::json;
using namespace nlohmann;
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverexception.h
Expand Up @@ -28,7 +28,7 @@
#include "nlohmann/json.hpp"

#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif


Expand Down
3 changes: 1 addition & 2 deletions src/server/qgsserverogcapihandler.cpp
Expand Up @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverogcapihandler.h
Expand Up @@ -24,7 +24,7 @@
#include "inja/inja.hpp"

#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif

class QgsServerApiContext;
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserverquerystringparameter.h
Expand Up @@ -27,7 +27,7 @@
#include "nlohmann/json_fwd.hpp"

#ifndef SIP_RUN
using json = nlohmann::json;
using namespace nlohmann;
#endif


Expand Down
4 changes: 2 additions & 2 deletions src/server/services/wfs3/qgswfs3handlers.cpp
Expand Up @@ -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" ) ) };
Expand Down

0 comments on commit 650f796

Please sign in to comment.