summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/jsonParse-persistence.cpp2
-rw-r--r--lib/jsonParse.impl.cpp7
-rw-r--r--lib/jsonParse.ll3
-rw-r--r--lib/persistence.h19
4 files changed, 16 insertions, 15 deletions
diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp
index 7c00773..dce9d3c 100644
--- a/lib/jsonParse-persistence.cpp
+++ b/lib/jsonParse-persistence.cpp
@@ -1,4 +1,6 @@
#include "jsonParse-persistence.h"
+#include <type_traits>
+#include <utility>
namespace Persistence {
void
diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp
index 4d13eae..0913847 100644
--- a/lib/jsonParse.impl.cpp
+++ b/lib/jsonParse.impl.cpp
@@ -25,7 +25,7 @@ json::jsonParser::appendEscape(unsigned long cp, std::string & str)
str += char((cp >> 6) + 192);
str += char((cp & 63) + 128);
}
- else if (0xd800 <= cp && cp <= 0xdfff) {
+ else if ((0xd800 <= cp && cp <= 0xdfff) || cp > 0x10FFFF) {
throw std::range_error("Invalid UTF-8 sequence");
}
else if (cp <= 0xFFFF) {
@@ -33,13 +33,10 @@ json::jsonParser::appendEscape(unsigned long cp, std::string & str)
str += char(((cp >> 6) & 63) + 128);
str += char((cp & 63) + 128);
}
- else if (cp <= 0x10FFFF) {
+ else {
str += char((cp >> 18) + 240);
str += char(((cp >> 12) & 63) + 128);
str += char(((cp >> 6) & 63) + 128);
str += char((cp & 63) + 128);
}
- else {
- throw std::range_error("Invalid UTF-8 sequence");
- }
}
diff --git a/lib/jsonParse.ll b/lib/jsonParse.ll
index c9c708c..ab09e80 100644
--- a/lib/jsonParse.ll
+++ b/lib/jsonParse.ll
@@ -17,7 +17,6 @@ class jsonBaseFlexLexer;
#ifdef __clang__
#pragma clang diagnostic ignored "-Wnull-conversion"
#endif
-[[maybe_unused]]static constexpr auto x=getpid;
%}
beginobj "{"
@@ -155,4 +154,6 @@ text [^\\\"]*
<*>. {
LexerError("Unexpected input");
+ // Make iwyu think unistd.h is required
+ [[maybe_unused]]static constexpr auto x=getpid;
}
diff --git a/lib/persistence.h b/lib/persistence.h
index 5d5fb0f..519cb0e 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -11,6 +11,7 @@
#include <stdexcept>
#include <string>
#include <string_view>
+#include <type_traits>
#include <utility>
#include <vector>
@@ -36,7 +37,7 @@ namespace Persistence {
virtual void beginObject(Stack &);
virtual void endObject(Stack &);
virtual void beforeValue(Stack &);
- virtual SelectionPtr select(const std::string &);
+ [[nodiscard]] virtual SelectionPtr select(const std::string &);
};
template<typename T> struct SelectionT;
@@ -49,14 +50,14 @@ namespace Persistence {
{
}
- static SelectionPtr
+ [[nodiscard]] static SelectionPtr
make(T & value)
{
return make_s<SelectionT<T>>(value);
}
template<typename S>
- static SelectionPtr
+ [[nodiscard]] static SelectionPtr
make_s(T & value)
{
return std::make_unique<S>(value);
@@ -77,10 +78,10 @@ namespace Persistence {
};
struct PersistenceStore {
- template<typename T> inline bool persistType() const;
+ template<typename T> [[nodiscard]] inline bool persistType() const;
template<typename T>
- inline bool
+ [[nodiscard]] inline bool
persistValue(const std::string_view key, T & value)
{
if (key == name) {
@@ -148,7 +149,7 @@ namespace Persistence {
virtual bool persist(PersistenceStore & store) = 0;
template<typename T>
- constexpr static auto
+ [[nodiscard]] constexpr static auto
typeName()
{
constexpr std::string_view name {__PRETTY_FUNCTION__};
@@ -159,8 +160,8 @@ namespace Persistence {
template<typename T> static void addFactory() __attribute__((constructor));
static void addFactory(const std::string_view, std::function<std::unique_ptr<Persistable>()>,
std::function<std::shared_ptr<Persistable>()>);
- static std::unique_ptr<Persistable> callFactory(const std::string_view);
- static std::shared_ptr<Persistable> callSharedFactory(const std::string_view);
+ [[nodiscard]] static std::unique_ptr<Persistable> callFactory(const std::string_view);
+ [[nodiscard]] static std::shared_ptr<Persistable> callSharedFactory(const std::string_view);
};
template<typename T>
@@ -223,7 +224,7 @@ namespace Persistence {
using SelectionV<Ptr>::SelectionV;
- SelectionPtr
+ [[nodiscard]] SelectionPtr
select(const std::string & mbr) override
{
using namespace std::literals;