summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icespider/common/pathparts.cpp1
-rw-r--r--icespider/common/pathparts.h1
-rw-r--r--icespider/compile/routeCompiler.cpp2
-rw-r--r--icespider/compile/routeCompiler.h2
-rw-r--r--icespider/core/core.cpp1
-rw-r--r--icespider/core/core.h7
-rw-r--r--icespider/core/flatMap.h4
-rw-r--r--icespider/core/ihttpRequest.cpp5
-rw-r--r--icespider/core/ihttpRequest.h12
-rw-r--r--icespider/core/irouteHandler.cpp1
-rw-r--r--icespider/core/irouteHandler.h2
-rw-r--r--icespider/core/xwwwFormUrlEncoded.h1
-rw-r--r--icespider/fcgi/cgiRequestBase.cpp1
-rw-r--r--icespider/fcgi/cgiRequestBase.h1
-rw-r--r--icespider/fileSessions/fileSessions.cpp1
-rw-r--r--icespider/testing/testRequest.cpp1
-rw-r--r--icespider/unittests/testAccept.cpp2
-rw-r--r--icespider/unittests/testApp.cpp3
-rw-r--r--icespider/unittests/testCompile.cpp2
-rw-r--r--icespider/unittests/testFcgi.cpp4
-rw-r--r--icespider/unittests/testFileSessions.cpp1
-rw-r--r--icespider/unittests/testPerf.cpp5
-rw-r--r--icespider/xslt/exslt-init.cpp3
23 files changed, 57 insertions, 6 deletions
diff --git a/icespider/common/pathparts.cpp b/icespider/common/pathparts.cpp
index 654081a..6c11dec 100644
--- a/icespider/common/pathparts.cpp
+++ b/icespider/common/pathparts.cpp
@@ -8,6 +8,7 @@ namespace ba = boost::algorithm;
namespace IceSpider {
const auto slash = ba::first_finder("/", ba::is_equal());
+
Path::Path(const std::string_view & p) : path(p)
{
auto relp = p.substr(1);
diff --git a/icespider/common/pathparts.h b/icespider/common/pathparts.h
index 077386d..f759730 100644
--- a/icespider/common/pathparts.h
+++ b/icespider/common/pathparts.h
@@ -17,6 +17,7 @@ namespace IceSpider {
[[nodiscard]] virtual bool matches(const std::string_view &) const = 0;
};
+
using PathPartPtr = std::unique_ptr<PathPart>;
class DLL_PUBLIC PathLiteral : public PathPart {
diff --git a/icespider/compile/routeCompiler.cpp b/icespider/compile/routeCompiler.cpp
index 3828d46..3d3913d 100644
--- a/icespider/compile/routeCompiler.cpp
+++ b/icespider/compile/routeCompiler.cpp
@@ -28,6 +28,7 @@
namespace IceSpider {
using namespace AdHoc::literals;
+
namespace Compile {
RouteCompiler::RouteCompiler()
{
@@ -280,6 +281,7 @@ namespace IceSpider {
}
AdHocFormatter(MimePair, R"C({ "%?", "%?" })C");
+
static std::string
outputSerializerMime(const IceSpider::OutputSerializers::value_type & os)
{
diff --git a/icespider/compile/routeCompiler.h b/icespider/compile/routeCompiler.h
index ee388ad..2a09187 100644
--- a/icespider/compile/routeCompiler.h
+++ b/icespider/compile/routeCompiler.h
@@ -47,12 +47,14 @@ namespace IceSpider::Compile {
static Slice::OperationPtr findOperation(const std::string &, const Units &);
static Slice::OperationPtr findOperation(
const std::string &, const Slice::ContainerPtr &, const Ice::StringSeq & = Ice::StringSeq());
+
// using Type = std::pair<Slice::StructPtr, Slice::ClassDeclPtr>;
struct Type {
std::string type;
std::optional<std::string> scoped;
Slice::DataMemberList members;
};
+
static Type findType(const std::string &, const Units &);
static std::optional<Type> findType(
const std::string &, const Slice::ContainerPtr &, const Ice::StringSeq & = Ice::StringSeq());
diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp
index 448c7ec..7aa1317 100644
--- a/icespider/core/core.cpp
+++ b/icespider/core/core.cpp
@@ -126,6 +126,7 @@ namespace IceSpider {
}
AdHocFormatter(LogExp, "Exception type: %?\nDetail: %?\n");
+
void
Core::defaultErrorReport(IHttpRequest * request, const std::exception & exception) const
{
diff --git a/icespider/core/core.h b/icespider/core/core.h
index b2150f8..7fa66a7 100644
--- a/icespider/core/core.h
+++ b/icespider/core/core.h
@@ -19,6 +19,7 @@
#include <string_view>
#include <vector>
#include <visibility.h>
+
// IWYU pragma: no_include "factory.impl.h"
namespace IceSpider {
@@ -67,8 +68,8 @@ namespace IceSpider {
Routes routes;
};
- class DLL_PUBLIC Plugin : public virtual Ice::Object {
- };
+ class DLL_PUBLIC Plugin : public virtual Ice::Object { };
+
using PluginFactory = AdHoc::Factory<Plugin, Ice::CommunicatorPtr, Ice::PropertiesPtr>;
enum ErrorHandlerResult {
@@ -76,10 +77,12 @@ namespace IceSpider {
ErrorHandlerResult_Handled,
ErrorHandlerResult_Modified,
};
+
class DLL_PUBLIC ErrorHandler : public AdHoc::AbstractPluginImplementation {
public:
virtual ErrorHandlerResult handleError(IHttpRequest * IHttpRequest, const std::exception &) const = 0;
};
+
using ErrorHandlerPlugin = AdHoc::PluginOf<ErrorHandler>;
}
diff --git a/icespider/core/flatMap.h b/icespider/core/flatMap.h
index 8a8cc20..a0ed57d 100644
--- a/icespider/core/flatMap.h
+++ b/icespider/core/flatMap.h
@@ -23,16 +23,19 @@ namespace IceSpider {
{
return c(v.first, n);
}
+
bool
operator()(const N & n, const V & v) const
{
return c(n, v.first);
}
+
Comp c;
};
public:
flatmap() = default;
+
explicit flatmap(std::size_t n)
{
reserve(n);
@@ -93,6 +96,7 @@ namespace IceSpider {
{
return cbegin();
}
+
[[nodiscard]] auto
end() const
{
diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp
index c575c82..ed7fce6 100644
--- a/icespider/core/ihttpRequest.cpp
+++ b/icespider/core/ihttpRequest.cpp
@@ -167,8 +167,9 @@ namespace IceSpider {
XWwwFormUrlEncoded::urlencodeto(o, value.begin(), value.end());
if (e) {
std::string buf(45, 0);
- struct tm tm {
- };
+
+ struct tm tm { };
+
gmtime_r(&*e, &tm);
buf.resize(strftime(buf.data(), buf.length(), "; expires=%a, %d %b %Y %T %Z", &tm));
o << buf;
diff --git a/icespider/core/ihttpRequest.h b/icespider/core/ihttpRequest.h
index a32509a..e8b1594 100644
--- a/icespider/core/ihttpRequest.h
+++ b/icespider/core/ihttpRequest.h
@@ -28,6 +28,7 @@ namespace IceSpider {
std::optional<std::string_view> group, type;
float q {1.0F};
};
+
using Accepted = std::vector<Accept>;
using PathElements = std::vector<std::string>;
using OptionalString = std::optional<std::string_view>;
@@ -86,18 +87,21 @@ namespace IceSpider {
return std::nullopt;
}
}
+
template<typename T>
[[nodiscard]] T
getURLParam(unsigned int n) const
{
return *getFrom<T, unsigned int>(n, &IHttpRequest::getURLParam);
}
+
template<typename T>
[[nodiscard]] std::optional<T>
getBody() const
{
return Slicer::DeserializeAnyWith<T>(getDeserializer());
}
+
template<typename T>
[[nodiscard]] std::optional<T>
getBodyParam(const std::optional<IceSpider::StringMap> & map, const std::string_view & key) const
@@ -113,9 +117,11 @@ namespace IceSpider {
return boost::lexical_cast<T>(i->second);
}
}
+
void responseRedirect(const std::string_view & url, const OptionalString & = {}) const;
void setCookie(const std::string_view &, const std::string_view &, const OptionalString & = {},
const OptionalString & = {}, bool = false, std::optional<time_t> = {});
+
template<typename T>
void
setCookie(const std::string_view & n, const T & v, const OptionalString & d, const OptionalString & p, bool s,
@@ -129,31 +135,37 @@ namespace IceSpider {
setCookie(n, std::string_view(vs), d, p, s, e);
}
}
+
template<typename T>
[[nodiscard]] std::optional<T>
getQueryStringParam(const std::string_view & key) const
{
return getFrom<T, std::string_view>(key, &IHttpRequest::getQueryStringParam);
}
+
template<typename T>
[[nodiscard]] std::optional<T>
getHeaderParam(const std::string_view & key) const
{
return getFrom<T, std::string_view>(key, &IHttpRequest::getHeaderParam);
}
+
template<typename T>
[[nodiscard]] std::optional<T>
getCookieParam(const std::string_view & key) const
{
return getFrom<T, std::string_view>(key, &IHttpRequest::getCookieParam);
}
+
virtual void response(short, const std::string_view &) const = 0;
+
template<typename T>
void
response(const IRouteHandler * route, const T & t) const
{
modelPartResponse(route, Slicer::ModelPart::CreateRootFor(t));
}
+
void modelPartResponse(const IRouteHandler * route, const Slicer::ModelPartForRootPtr &) const;
const Core * core;
diff --git a/icespider/core/irouteHandler.cpp b/icespider/core/irouteHandler.cpp
index 85b49f6..3219e17 100644
--- a/icespider/core/irouteHandler.cpp
+++ b/icespider/core/irouteHandler.cpp
@@ -18,6 +18,7 @@ namespace IceSpider {
static const std::string APPLICATION_JSON = MimeTypeFmt::get(APPLICATION, JSON);
const RouteOptions IRouteHandler::defaultRouteOptions {};
+
IRouteHandler::IRouteHandler(HttpMethod m, const std::string_view & p) :
IRouteHandler(m, p, defaultRouteOptions) { }
diff --git a/icespider/core/irouteHandler.h b/icespider/core/irouteHandler.h
index c9c09e2..2b13b22 100644
--- a/icespider/core/irouteHandler.h
+++ b/icespider/core/irouteHandler.h
@@ -12,6 +12,7 @@
#include <pathparts.h>
#include <string_view>
#include <visibility.h>
+
// IWYU pragma: no_include "factory.impl.h"
// IWYU pragma: no_include <Ice/Comparable.h>
// IWYU pragma: no_include <string>
@@ -51,6 +52,7 @@ namespace IceSpider {
void addRouteSerializer(const MimeType &, const StreamSerializerFactoryPtr &);
};
+
using IRouteHandlerPtr = std::shared_ptr<IRouteHandler>;
using IRouteHandlerCPtr = std::shared_ptr<const IRouteHandler>;
using RouteHandlerFactory = AdHoc::Factory<IRouteHandler, const Core *>;
diff --git a/icespider/core/xwwwFormUrlEncoded.h b/icespider/core/xwwwFormUrlEncoded.h
index d4b11f3..a296864 100644
--- a/icespider/core/xwwwFormUrlEncoded.h
+++ b/icespider/core/xwwwFormUrlEncoded.h
@@ -10,6 +10,7 @@
#include <string>
#include <string_view>
#include <visibility.h>
+
// IWYU pragma: no_forward_declare boost::algorithm::split_iterator
namespace IceSpider {
diff --git a/icespider/fcgi/cgiRequestBase.cpp b/icespider/fcgi/cgiRequestBase.cpp
index 108f2ce..5cefc4e 100644
--- a/icespider/fcgi/cgiRequestBase.cpp
+++ b/icespider/fcgi/cgiRequestBase.cpp
@@ -95,6 +95,7 @@ namespace IceSpider {
AdHocFormatter(VarFmt, "\t%?: [%?]\n");
AdHocFormatter(PathFmt, "\t[%?]\n");
+
template<typename Fmt, typename Map>
void
dumpMap(std::ostream & s, const std::string_view & n, const Map & map)
diff --git a/icespider/fcgi/cgiRequestBase.h b/icespider/fcgi/cgiRequestBase.h
index 32cdca3..a576db1 100644
--- a/icespider/fcgi/cgiRequestBase.h
+++ b/icespider/fcgi/cgiRequestBase.h
@@ -8,6 +8,7 @@
#include <iosfwd>
#include <maybeString.h>
#include <string_view>
+
// IWYU pragma: no_forward_declare AdHoc::case_less
namespace IceSpider {
diff --git a/icespider/fileSessions/fileSessions.cpp b/icespider/fileSessions/fileSessions.cpp
index 6818410..9a23898 100644
--- a/icespider/fileSessions/fileSessions.cpp
+++ b/icespider/fileSessions/fileSessions.cpp
@@ -170,4 +170,5 @@ namespace IceSpider {
const Ice::Short duration;
};
}
+
NAMEDFACTORY("IceSpider-FileSessions", IceSpider::FileSessions, IceSpider::PluginFactory);
diff --git a/icespider/testing/testRequest.cpp b/icespider/testing/testRequest.cpp
index e522bc1..552987c 100644
--- a/icespider/testing/testRequest.cpp
+++ b/icespider/testing/testRequest.cpp
@@ -13,6 +13,7 @@
namespace IceSpider {
constexpr std::string_view slash("/");
+
TestRequest::TestRequest(const Core * c, HttpMethod m, const std::string_view & p) : IHttpRequest(c), method(m)
{
namespace ba = boost::algorithm;
diff --git a/icespider/unittests/testAccept.cpp b/icespider/unittests/testAccept.cpp
index 67b1411..410147f 100644
--- a/icespider/unittests/testAccept.cpp
+++ b/icespider/unittests/testAccept.cpp
@@ -7,6 +7,7 @@
#include <ostream>
#include <string_view>
#include <vector>
+
namespace IceSpider {
class Http400_BadRequest;
}
@@ -24,6 +25,7 @@ namespace std {
}
BOOST_TEST_DECORATOR(*boost::unit_test::timeout(1))
+
BOOST_DATA_TEST_CASE(bad_requests,
make({
"", // Can't specify nothing
diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp
index 9f84999..8f13793 100644
--- a/icespider/unittests/testApp.cpp
+++ b/icespider/unittests/testApp.cpp
@@ -32,6 +32,7 @@
#include <string_view>
#include <test-api.h>
#include <testRequest.h>
+
namespace Ice {
struct Current;
}
@@ -44,6 +45,7 @@ struct forceEarlyChangeDir {
std::filesystem::current_path(rootDir);
}
};
+
BOOST_TEST_GLOBAL_FIXTURE(forceEarlyChangeDir);
BOOST_AUTO_TEST_CASE(testLoadConfiguration)
@@ -214,6 +216,7 @@ class Dummy : public IceSpider::Plugin, TestIceSpider::DummyPlugin {
public:
Dummy(const Ice::CommunicatorPtr &, const Ice::PropertiesPtr &) { }
};
+
NAMEDFACTORY("DummyPlugin", Dummy, IceSpider::PluginFactory);
BOOST_FIXTURE_TEST_SUITE(ta, TestApp);
diff --git a/icespider/unittests/testCompile.cpp b/icespider/unittests/testCompile.cpp
index 8d01113..19395ac 100644
--- a/icespider/unittests/testCompile.cpp
+++ b/icespider/unittests/testCompile.cpp
@@ -25,11 +25,13 @@ struct forceEarlyChangeDir {
std::filesystem::current_path(rootDir);
}
};
+
BOOST_TEST_GLOBAL_FIXTURE(forceEarlyChangeDir);
class CoreFixture {
protected:
CoreFixture() : modeDir(binDir.lexically_relative(rootDir / "bin" / "testCompile.test")) { }
+
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
const std::filesystem::path modeDir;
};
diff --git a/icespider/unittests/testFcgi.cpp b/icespider/unittests/testFcgi.cpp
index 5b1ac5b..e77e954 100644
--- a/icespider/unittests/testFcgi.cpp
+++ b/icespider/unittests/testFcgi.cpp
@@ -23,11 +23,13 @@
namespace IceSpider {
class Http400_BadRequest;
}
+
namespace IceSpider {
class Http405_MethodNotAllowed;
}
using namespace std::literals;
+
namespace std {
template<typename T>
ostream &
@@ -68,6 +70,7 @@ public:
{
return std::cin;
}
+
// LCOV_EXCL_STOP
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
@@ -132,6 +135,7 @@ namespace std {
}
return s;
}
+
// LCOV_EXCL_STOP
}
diff --git a/icespider/unittests/testFileSessions.cpp b/icespider/unittests/testFileSessions.cpp
index 2470363..9f73d43 100644
--- a/icespider/unittests/testFileSessions.cpp
+++ b/icespider/unittests/testFileSessions.cpp
@@ -26,6 +26,7 @@ public:
root(communicator->getProperties()->getProperty("IceSpider.FileSessions.Path"))
{
}
+
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
const std::filesystem::path root;
};
diff --git a/icespider/unittests/testPerf.cpp b/icespider/unittests/testPerf.cpp
index 85abc92..7a24faf 100644
--- a/icespider/unittests/testPerf.cpp
+++ b/icespider/unittests/testPerf.cpp
@@ -25,6 +25,7 @@ public:
{
return std::cin;
}
+
// LCOV_EXCL_STOP
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
@@ -55,8 +56,7 @@ public:
}
};
-class CoreFixture : public IceSpider::CoreWithDefaultRouter, public benchmark::Fixture {
-};
+class CoreFixture : public IceSpider::CoreWithDefaultRouter, public benchmark::Fixture { };
BENCHMARK_F(CoreFixture, script_name_root)(benchmark::State & state)
{
@@ -118,6 +118,7 @@ AcceptParse(benchmark::State & state, const std::string_view accept)
benchmark::DoNotOptimize(IceSpider::IHttpRequest::parseAccept(accept));
}
}
+
BENCHMARK_CAPTURE_LITERAL(AcceptParse, "*/*");
BENCHMARK_CAPTURE_LITERAL(AcceptParse, "any/html");
BENCHMARK_CAPTURE_LITERAL(AcceptParse, "image/png, */*");
diff --git a/icespider/xslt/exslt-init.cpp b/icespider/xslt/exslt-init.cpp
index d4489e7..110a999 100644
--- a/icespider/xslt/exslt-init.cpp
+++ b/icespider/xslt/exslt-init.cpp
@@ -3,6 +3,7 @@
#include <libxslt/xslt.h>
static void initLibXml() __attribute__((constructor(102)));
+
void
initLibXml()
{
@@ -12,10 +13,12 @@ initLibXml()
// LCOV_EXCL_START lcov actually misses destructor functions
static void cleanupLibXml() __attribute__((destructor(102)));
+
void
cleanupLibXml()
{
xsltCleanupGlobals();
xmlCleanupParser();
}
+
// LCOV_EXCL_STOP