summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamroot.jam1
-rw-r--r--slicer/db/sqlInsertSerializer.cpp4
-rw-r--r--slicer/db/sqlInsertSerializer.h2
-rw-r--r--slicer/db/sqlSelectDeserializer.cpp4
-rw-r--r--slicer/db/sqlUpdateSerializer.cpp4
-rw-r--r--slicer/db/sqlUpdateSerializer.h2
-rw-r--r--slicer/json/serializer.cpp8
-rw-r--r--slicer/json/serializer.h4
-rw-r--r--slicer/slicer/modelParts.cpp8
-rw-r--r--slicer/slicer/modelParts.h2
-rw-r--r--slicer/slicer/modelPartsTypes.cpp10
-rw-r--r--slicer/slicer/slicer.cpp4
-rw-r--r--slicer/test/preprocessor.cpp2
-rw-r--r--slicer/test/serializers.cpp34
-rw-r--r--slicer/tool/parser.cpp8
-rw-r--r--slicer/xml/serializer.cpp30
-rw-r--r--slicer/xml/serializer.h4
17 files changed, 68 insertions, 63 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index f3d42e8..11ef158 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -21,6 +21,7 @@ project
<toolset>tidy:<checkxx>bugprone-*
<toolset>tidy:<checkxx>clang-*
<toolset>tidy:<checkxx>misc-*
+ <toolset>tidy:<checkxx>modernize-*
<toolset>tidy:<checkxx>hicpp-*
;
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp
index e944065..6d02212 100644
--- a/slicer/db/sqlInsertSerializer.cpp
+++ b/slicer/db/sqlInsertSerializer.cpp
@@ -12,9 +12,9 @@
namespace Slicer {
using namespace std::placeholders;
- SqlInsertSerializer::SqlInsertSerializer(DB::Connection * const c, const std::string & t) :
+ SqlInsertSerializer::SqlInsertSerializer(DB::Connection * const c, std::string t) :
connection(c),
- tableName(t)
+ tableName(std::move(t))
{
}
diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h
index d5c8ced..fcabb4a 100644
--- a/slicer/db/sqlInsertSerializer.h
+++ b/slicer/db/sqlInsertSerializer.h
@@ -9,7 +9,7 @@
namespace Slicer {
class DLL_PUBLIC SqlInsertSerializer : public Slicer::Serializer {
public:
- SqlInsertSerializer(DB::Connection * const, const std::string & tableName);
+ SqlInsertSerializer(DB::Connection * const, std::string tableName);
virtual void Serialize(Slicer::ModelPartForRootPtr) override;
diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp
index 250de03..c4ea0d5 100644
--- a/slicer/db/sqlSelectDeserializer.cpp
+++ b/slicer/db/sqlSelectDeserializer.cpp
@@ -7,7 +7,7 @@ namespace Slicer {
SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand * c, Ice::optional<std::string> tc) :
cmd(c),
columnCount(0),
- typeIdColName(tc)
+ typeIdColName(std::move(tc))
{
}
@@ -96,7 +96,7 @@ namespace Slicer {
for (auto col = 0u; col < columnCount; col += 1) {
const DB::Column & c = (*cmd)[col];
if (!c.isNull()) {
- auto fmpr = rmp->GetChildRef(c.name, NULL, false);
+ auto fmpr = rmp->GetChildRef(c.name, nullptr, false);
if (fmpr) {
auto fmp = fmpr.Child();
fmp->Create();
diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp
index 07d6f15..0153fbf 100644
--- a/slicer/db/sqlUpdateSerializer.cpp
+++ b/slicer/db/sqlUpdateSerializer.cpp
@@ -11,9 +11,9 @@
namespace Slicer {
using namespace std::placeholders;
- SqlUpdateSerializer::SqlUpdateSerializer(DB::Connection * const c, const std::string & t) :
+ SqlUpdateSerializer::SqlUpdateSerializer(DB::Connection * const c, std::string t) :
connection(c),
- tableName(t)
+ tableName(std::move(t))
{
}
diff --git a/slicer/db/sqlUpdateSerializer.h b/slicer/db/sqlUpdateSerializer.h
index f695634..d142c04 100644
--- a/slicer/db/sqlUpdateSerializer.h
+++ b/slicer/db/sqlUpdateSerializer.h
@@ -8,7 +8,7 @@
namespace Slicer {
class DLL_PUBLIC SqlUpdateSerializer : public Slicer::Serializer {
public:
- SqlUpdateSerializer(DB::Connection * const, const std::string & tableName);
+ SqlUpdateSerializer(DB::Connection * const, std::string tableName);
virtual void Serialize(Slicer::ModelPartForRootPtr) override;
diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp
index 4a7dcc9..8c41550 100644
--- a/slicer/json/serializer.cpp
+++ b/slicer/json/serializer.cpp
@@ -334,13 +334,13 @@ namespace Slicer {
json::serializeValue(doc, strm, "utf-8");
}
- JsonFileSerializer::JsonFileSerializer(const std::filesystem::path & p) :
- path(p)
+ JsonFileSerializer::JsonFileSerializer(std::filesystem::path p) :
+ path(std::move(p))
{
}
- JsonFileDeserializer::JsonFileDeserializer(const std::filesystem::path & p) :
- path(p)
+ JsonFileDeserializer::JsonFileDeserializer(std::filesystem::path p) :
+ path(std::move(p))
{
}
diff --git a/slicer/json/serializer.h b/slicer/json/serializer.h
index 15157d4..b1a97b3 100644
--- a/slicer/json/serializer.h
+++ b/slicer/json/serializer.h
@@ -26,7 +26,7 @@ namespace Slicer {
class DLL_PUBLIC JsonFileSerializer : public JsonSerializer {
public:
- JsonFileSerializer(const std::filesystem::path &);
+ JsonFileSerializer(std::filesystem::path);
virtual void Serialize(ModelPartForRootPtr) override;
@@ -56,7 +56,7 @@ namespace Slicer {
class DLL_PUBLIC JsonFileDeserializer : public Deserializer {
public:
- JsonFileDeserializer(const std::filesystem::path &);
+ JsonFileDeserializer(std::filesystem::path);
virtual void Deserialize(ModelPartForRootPtr) override;
diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp
index 702bc93..e70cd61 100644
--- a/slicer/slicer/modelParts.cpp
+++ b/slicer/slicer/modelParts.cpp
@@ -53,14 +53,14 @@ namespace Slicer {
ModelPart::GetAnonChild(const HookFilter & flt)
{
auto ref = GetAnonChildRef(flt);
- return ref ? ref.Child() : ModelPartPtr(NULL);
+ return ref ? ref.Child() : ModelPartPtr(nullptr);
}
ModelPartPtr
ModelPart::GetChild(const std::string & memberName, const HookFilter & flt)
{
auto ref = GetChildRef(memberName, flt);
- return ref ? ref.Child() : ModelPartPtr(NULL);
+ return ref ? ref.Child() : ModelPartPtr(nullptr);
}
bool
@@ -75,8 +75,8 @@ namespace Slicer {
return shared_from_this();
}
- HookCommon::HookCommon(const std::string & n) :
- name(n)
+ HookCommon::HookCommon(std::string n) :
+ name(std::move(n))
{
}
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 6e13fc9..9b7d886 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -108,7 +108,7 @@ namespace Slicer {
class DLL_PUBLIC HookCommon {
public:
- HookCommon(const std::string &);
+ HookCommon(std::string);
bool filter(const HookFilter & flt);
void apply(const ChildHandler & ch, const ModelPartPtr & modelPart);
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index 8a7dc39..0f95c1f 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -4,13 +4,13 @@
#include <cxxabi.h>
namespace Slicer {
- typedef std::map<std::string, ClassRef, std::less<>> ClassRefMap;
- typedef boost::multi_index_container<
+ using ClassRefMap = std::map<std::string, ClassRef, std::less<>>;
+ using ClassNameMap = boost::multi_index_container<
std::pair<std::string, std::string>,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<boost::multi_index::member<std::pair<std::string, std::string>, const std::string, &std::pair<std::string, std::string>::first>, std::less<>>,
boost::multi_index::ordered_unique<boost::multi_index::member<std::pair<std::string, std::string>, const std::string, &std::pair<std::string, std::string>::second>, std::less<>>
- >> ClassNameMap;
+ >>;
static void createClassMaps() __attribute__((constructor(208)));
static void deleteClassMaps() __attribute__((destructor(208)));
@@ -100,7 +100,7 @@ namespace Slicer {
// ModelPartForRootBase
ModelPartForRootBase::ModelPartForRootBase(ModelPartPtr m) :
- mp(m)
+ mp(std::move(m))
{
}
@@ -188,7 +188,7 @@ namespace Slicer {
std::string ModelPartForComplexBase::demangle(const char * mangled)
{
- auto buf = std::unique_ptr<char, decltype(free)*>(abi::__cxa_demangle(mangled, NULL, NULL, NULL), std::free);
+ auto buf = std::unique_ptr<char, decltype(free)*>(abi::__cxa_demangle(mangled, nullptr, nullptr, nullptr), std::free);
return "::" + std::string(buf.get());
}
diff --git a/slicer/slicer/slicer.cpp b/slicer/slicer/slicer.cpp
index ba24faf..512e025 100644
--- a/slicer/slicer/slicer.cpp
+++ b/slicer/slicer/slicer.cpp
@@ -10,13 +10,13 @@ namespace Slicer {
}
Slicer::ChildRef::ChildRef(ModelPartPtr m) :
- mpp(m),
+ mpp(std::move(m)),
mdr(emptyMetadata)
{
}
Slicer::ChildRef::ChildRef(Slicer::ModelPartPtr mp, const Slicer::Metadata & md) :
- mpp(mp),
+ mpp(std::move(mp)),
mdr(md)
{
}
diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp
index e8202ba..fe789d0 100644
--- a/slicer/test/preprocessor.cpp
+++ b/slicer/test/preprocessor.cpp
@@ -8,7 +8,7 @@
#include <definedDirs.h>
#include "helpers.h"
-typedef std::map<std::string, unsigned int> ComponentsCount;
+using ComponentsCount = std::map<std::string, unsigned int>;
ComponentsCount COMPONENTS_IN_TEST_ICE = {
{ "classtype.ice", 1 },
{ "classes.ice", 3 },
diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp
index 097a3fb..311a9f2 100644
--- a/slicer/test/serializers.cpp
+++ b/slicer/test/serializers.cpp
@@ -20,7 +20,6 @@
#include "conversions.h"
namespace fs = std::filesystem;
-namespace pl = std::placeholders;
// LCOV_EXCL_START
BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::ClassMap::iterator )
@@ -37,14 +36,14 @@ class FileBased {
public:
template<typename T, typename DeserializerIn>
void
- verifyByFile(const fs::path & infile, const std::function<void(const T &)> & check = NULL)
+ verifyByFile(const fs::path & infile, const std::function<void(const T &)> & check = nullptr)
{
verifyByFile<T, DeserializerIn>(infile, infile, check);
}
template<typename T, typename DeserializerIn>
void
- verifyByFile(const fs::path & infile, const fs::path & expOutFile, const std::function<void(const T &)> & check = NULL)
+ verifyByFile(const fs::path & infile, const fs::path & expOutFile, const std::function<void(const T &)> & check = nullptr)
{
const fs::path input = rootDir / "initial" / infile;
const fs::path expected = rootDir / "initial" / expOutFile;
@@ -83,7 +82,7 @@ class FileBased {
const std::function<Internal(const fs::path &)> & in,
const std::function<void(const Internal &, const fs::path &)> & out,
const std::function<void(Internal &)> & ifree,
- const std::function<void(const T &)> & check = NULL)
+ const std::function<void(const T &)> & check = nullptr)
{
const fs::path input = rootDir / "initial" / infile;
const fs::path tmph = binDir / "byHandler";
@@ -238,13 +237,6 @@ checkStruct(const TestModule::StructType & st)
BOOST_REQUIRE_EQUAL(st.b, 13);
}
-template<class T>
-void
-checkAssertEq(const T & expected, const T & actual)
-{
- BOOST_REQUIRE_EQUAL(expected, actual);
-}
-
void
checkEntityRef(const TestXml::EntityRef & er)
{
@@ -377,22 +369,30 @@ BOOST_AUTO_TEST_CASE( structtype_json )
BOOST_AUTO_TEST_CASE( simplestring_xml )
{
- verifyByFile<std::string, Slicer::XmlFileDeserializer>("string.xml", std::bind(checkAssertEq<std::string>, "test string", pl::_1));
+ verifyByFile<std::string, Slicer::XmlFileDeserializer>("string.xml", [](const auto & s) {
+ BOOST_REQUIRE_EQUAL("test string", s);
+ });
}
BOOST_AUTO_TEST_CASE( simpleint_xml )
{
- verifyByFile<Ice::Int, Slicer::XmlFileDeserializer>("int.xml", std::bind(checkAssertEq<Ice::Int>, 27, pl::_1));
+ verifyByFile<Ice::Int, Slicer::XmlFileDeserializer>("int.xml", [](const auto & i) {
+ BOOST_REQUIRE_EQUAL(27, i);
+ });
}
BOOST_AUTO_TEST_CASE( simplestring_json )
{
- verifyByFile<std::string, Slicer::JsonFileDeserializer>("string2.json", std::bind(checkAssertEq<std::string>, "test string", pl::_1));
+ verifyByFile<std::string, Slicer::JsonFileDeserializer>("string2.json", [](const auto & s) {
+ BOOST_REQUIRE_EQUAL("test string", s);
+ });
}
BOOST_AUTO_TEST_CASE( simpleint_json )
{
- verifyByFile<Ice::Int, Slicer::JsonFileDeserializer>("int2.json", std::bind(checkAssertEq<Ice::Int>, 27, pl::_1));
+ verifyByFile<Ice::Int, Slicer::JsonFileDeserializer>("int2.json", [](const auto & i) {
+ BOOST_REQUIRE_EQUAL(27, i);
+ });
}
BOOST_AUTO_TEST_CASE( complexClass_xmlattrAndText )
@@ -626,7 +626,7 @@ BOOST_AUTO_TEST_CASE( simple_complete_validator )
BOOST_AUTO_TEST_CASE( missingConversion )
{
- auto in = json::parseValue("{\"conv\": \"2016-06-30 12:34:56\"}");
+ auto in = json::parseValue(R"J({"conv": "2016-06-30 12:34:56"})J");
BOOST_REQUIRE_THROW((
Slicer::DeserializeAny<Slicer::JsonValueDeserializer, TestModule2::MissingConvPtr>(in)
), Slicer::NoConversionFound);
@@ -640,7 +640,7 @@ BOOST_AUTO_TEST_CASE( missingConversion )
BOOST_AUTO_TEST_CASE( conversion )
{
- auto in = json::parseValue("{\"conv\": \"2016-06-30 12:34:56\"}");
+ auto in = json::parseValue(R"J({"conv": "2016-06-30 12:34:56"})J");
auto obj = Slicer::DeserializeAny<Slicer::JsonValueDeserializer, TestModule2::ConvPtr>(in);
BOOST_REQUIRE_EQUAL("2016-06-30 12:34:56", obj->conv);
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index 649ba59..ca92390 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -15,7 +15,7 @@ namespace fs = std::filesystem;
namespace Slicer {
Slicer::Slicer() :
- cpp(NULL),
+ cpp(nullptr),
headerPrefix("slicer"),
components(0),
classNo(0)
@@ -569,7 +569,7 @@ namespace Slicer {
unsigned int
Slicer::Execute()
{
- if (cpp != NULL && !cppPath.empty()) {
+ if (cpp && !cppPath.empty()) {
throw CompilerError("Both file handle and path provided.");
}
auto cppfile = std::unique_ptr<FILE, decltype(&fclose)>(
@@ -589,7 +589,7 @@ namespace Slicer {
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slicer", slicePath, args);
FILE * cppHandle = icecpp->preprocess(false);
- if (cppHandle == NULL) {
+ if (!cppHandle) {
throw CompilerError("preprocess failed");
}
@@ -612,7 +612,7 @@ namespace Slicer {
u->destroy();
if (!cppPath.empty()) {
- cpp = NULL;
+ cpp = nullptr;
}
return Components() - initial;
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index 842a2a3..dbd0af1 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -24,7 +24,7 @@ namespace Slicer {
const std::string md_elements = "xml:elements";
const std::string keyName = "key";
const std::string valueName = "value";
- typedef xmlpp::Element * (xmlpp::Element::* ElementCreatorF) (const Glib::ustring &, const Glib::ustring &);
+ using ElementCreatorF = xmlpp::Element * (xmlpp::Element::*) (const Glib::ustring &, const Glib::ustring &);
const auto defaultElementCreator = std::bind((ElementCreatorF)&xmlpp::Element::add_child_element, _1, _2, Glib::ustring());
static const Glib::ustring TrueText("true");
@@ -32,8 +32,8 @@ namespace Slicer {
class XmlValueSource : public ValueSource {
public:
- explicit XmlValueSource(const Glib::ustring & s) :
- value(s)
+ explicit XmlValueSource(Glib::ustring s) :
+ value(std::move(s))
{
}
@@ -106,7 +106,7 @@ namespace Slicer {
class XmlValueTarget : public ValueTarget {
public:
explicit XmlValueTarget(std::function<void(const Glib::ustring &)> a) :
- apply(a)
+ apply(std::move(a))
{
}
@@ -255,8 +255,9 @@ namespace Slicer {
{
while (node) {
if (auto element = dynamic_cast<const xmlpp::Element *>(node)) {
- auto smpr = mp->GetChildRef(element->get_name(),
- std::bind(metaDataFlagNotSet, std::bind(&Slicer::HookCommon::GetMetadata, _1), md_attribute));
+ auto smpr = mp->GetChildRef(element->get_name(), [](const auto & h) {
+ return metaDataFlagNotSet(h->GetMetadata(), md_attribute);
+ });
if (smpr) {
auto smp = smpr.Child();
if (metaDataFlagSet(smpr.ChildMetaData(), md_bare)) {
@@ -268,8 +269,9 @@ namespace Slicer {
}
}
else if (auto attribute = dynamic_cast<const xmlpp::Attribute *>(node)) {
- auto smp = mp->GetChild(attribute->get_name(),
- std::bind(metaDataFlagSet, std::bind(&Slicer::HookCommon::GetMetadata, _1), md_attribute));
+ auto smp = mp->GetChild(attribute->get_name(), [](const auto & h) {
+ return metaDataFlagSet(h->GetMetadata(), md_attribute);
+ });
if (smp) {
smp->Create();
smp->SetValue(XmlAttributeValueSource(attribute));
@@ -279,7 +281,9 @@ namespace Slicer {
else if (auto content = dynamic_cast<const xmlpp::ContentNode *>(node)) {
ModelPartPtr smp;
if (!content->is_white_space()) {
- smp = mp->GetAnonChild(std::bind(metaDataFlagSet, std::bind(&Slicer::HookCommon::GetMetadata, _1), md_text));
+ smp = mp->GetAnonChild([](const auto & h) {
+ return metaDataFlagSet(h->GetMetadata(), md_text);
+ });
}
if (smp) {
smp->SetValue(XmlContentValueSource(content));
@@ -403,13 +407,13 @@ namespace Slicer {
doc.write_to_stream(strm);
}
- XmlFileSerializer::XmlFileSerializer(const std::filesystem::path & p) :
- path(p)
+ XmlFileSerializer::XmlFileSerializer(std::filesystem::path p) :
+ path(std::move(p))
{
}
- XmlFileDeserializer::XmlFileDeserializer(const std::filesystem::path & p) :
- path(p)
+ XmlFileDeserializer::XmlFileDeserializer(std::filesystem::path p) :
+ path(std::move(p))
{
}
diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h
index 561b08f..1ab2ec2 100644
--- a/slicer/xml/serializer.h
+++ b/slicer/xml/serializer.h
@@ -34,7 +34,7 @@ namespace Slicer {
class DLL_PUBLIC XmlFileSerializer : public XmlSerializer {
public:
- XmlFileSerializer(const std::filesystem::path &);
+ XmlFileSerializer(std::filesystem::path);
virtual void Serialize(ModelPartForRootPtr) override;
@@ -73,7 +73,7 @@ namespace Slicer {
class DLL_PUBLIC XmlFileDeserializer : public XmlDeserializer {
public:
- XmlFileDeserializer(const std::filesystem::path &);
+ XmlFileDeserializer(std::filesystem::path);
virtual void Deserialize(ModelPartForRootPtr) override;