From 320ac40056a377be91a1d1d0ec7af3c2c1a1bf02 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 26 May 2021 10:01:50 +0300 Subject: [PATCH] Add method SetAttributeOrRemoveIf for VPLayoutFileWriter class. --- src/app/puzzle/xml/vplayoutfilewriter.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 287e6997e..04cb8e323 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -68,6 +68,10 @@ private: template void SetAttribute(const QString &name, const char (&value)[N]); + + template + void SetAttributeOrRemoveIf(const QString &name, const T &value, + const std::function &removeCondition); }; //--------------------------------------------------------------------------------------------------------------------- @@ -107,4 +111,15 @@ inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&v writeAttribute(name, QString(value)); } +//--------------------------------------------------------------------------------------------------------------------- +template +inline void VPLayoutFileWriter::SetAttributeOrRemoveIf(const QString &name, const T &value, + const std::function &removeCondition) +{ + if (not removeCondition(value)) + { + SetAttribute(name, value); + } +} + #endif // VPLAYOUTFILEWRITER_H