do not include <ciso646> with C++20

This commit is contained in:
Roman Telezhynskyi 2023-07-17 16:33:57 +03:00
parent 62f468b57b
commit c8844853b5
24 changed files with 745 additions and 581 deletions

View file

@ -30,9 +30,13 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCoreApplication> #include <QCoreApplication>
#include <ciso646>
#include <memory> #include <memory>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#endif #endif

View file

@ -36,16 +36,18 @@
#include "../vgeometry/vlayoutplacelabel.h" #include "../vgeometry/vlayoutplacelabel.h"
#include "../vlayout/vlayoutpiecepath.h" #include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h" #include "../vlayout/vtextmanager.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/floatItemData/floatitemdef.h" #include "../vpatterndb/floatItemData/floatitemdef.h"
#include "compatibility.h" #include "../vwidgets/vpiecegrainline.h"
#include "svgfont/vsvgfont.h"
#include "vpiecegrainline.h"
#include "vplayoutliterals.h" #include "vplayoutliterals.h"
#include <QFont> #include <QFont>
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
#include <Qt>
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")

View file

@ -29,15 +29,19 @@
#ifndef VPLAYOUTFILEWRITER_H #ifndef VPLAYOUTFILEWRITER_H
#define VPLAYOUTFILEWRITER_H #define VPLAYOUTFILEWRITER_H
#include <QCoreApplication>
#include <QLocale> #include <QLocale>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QCoreApplication>
#include <functional> #include <functional>
#include <ciso646>
#include "../vmisc/literals.h" // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../vmisc/literals.h"
class VPLayout; class VPLayout;
class VPSheet; class VPSheet;
@ -53,8 +57,8 @@ class VPLayoutFileWriter : public QXmlStreamWriter
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) // NOLINT Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) // NOLINT
public: public:
VPLayoutFileWriter()= default; VPLayoutFileWriter() = default;
~VPLayoutFileWriter()= default; ~VPLayoutFileWriter() = default;
void WriteFile(const VPLayoutPtr &layout, QIODevice *file); void WriteFile(const VPLayoutPtr &layout, QIODevice *file);
@ -75,20 +79,20 @@ private:
void WriteMargins(const QMarginsF &margins, bool ignore); void WriteMargins(const QMarginsF &margins, bool ignore);
void WriteSize(QSizeF size); void WriteSize(QSizeF size);
template <typename T> template <typename T> void SetAttribute(const QString &name, const T &value);
void SetAttribute(const QString &name, const T &value);
template <size_t N> template <size_t N>
void SetAttribute(const QString &name, const char (&value)[N]); //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays) void SetAttribute(const QString &name,
const char (&value)[N]); // NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays)
// NOLINT(modernize-avoid-c-arrays)
template <typename T> template <typename T>
void SetAttributeOrRemoveIf(const QString &name, const T &value, void SetAttributeOrRemoveIf(const QString &name, const T &value,
const std::function<bool(const T&)> &removeCondition); const std::function<bool(const T &)> &removeCondition);
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T> template <typename T> void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value)
void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value)
{ {
// See specification for xs:decimal // See specification for xs:decimal
const QLocale locale = QLocale::c(); const QLocale locale = QLocale::c();
@ -96,29 +100,28 @@ void VPLayoutFileWriter::SetAttribute(const QString &name, const T &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <> inline void VPLayoutFileWriter::SetAttribute<QString>(const QString &name, const QString &value)
inline void VPLayoutFileWriter::SetAttribute<QString>(const QString &name, const QString &value)
{ {
writeAttribute(name, value); writeAttribute(name, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <> inline void VPLayoutFileWriter::SetAttribute<QChar>(const QString &name, const QChar &value)
inline void VPLayoutFileWriter::SetAttribute<QChar>(const QString &name, const QChar &value)
{ {
writeAttribute(name, value); writeAttribute(name, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <> inline void VPLayoutFileWriter::SetAttribute<bool>(const QString &name, const bool &value)
inline void VPLayoutFileWriter::SetAttribute<bool>(const QString &name, const bool &value)
{ {
writeAttribute(name, value ? trueStr : falseStr); writeAttribute(name, value ? trueStr : falseStr);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <size_t N> template <size_t N>
inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays) inline void VPLayoutFileWriter::SetAttribute(
const QString &name, const char (&value)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays)
// NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays)
{ {
writeAttribute(name, QString(value)); writeAttribute(name, QString(value));
} }
@ -126,7 +129,7 @@ inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&v
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
inline void VPLayoutFileWriter::SetAttributeOrRemoveIf(const QString &name, const T &value, inline void VPLayoutFileWriter::SetAttributeOrRemoveIf(const QString &name, const T &value,
const std::function<bool(const T&)> &removeCondition) const std::function<bool(const T &)> &removeCondition)
{ {
if (not removeCondition(value)) if (not removeCondition(value))
{ {

View file

@ -28,16 +28,20 @@
#include "dialogdatetimeformats.h" #include "dialogdatetimeformats.h"
#include "ui_dialogdatetimeformats.h" #include "ui_dialogdatetimeformats.h"
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogDateTimeFormats::DialogDateTimeFormats(const QDate &date, const QStringList &predefinedFormats, DialogDateTimeFormats::DialogDateTimeFormats(const QDate &date, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent) const QStringList &userDefinedFormats, QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::DialogDateTimeFormats), ui(new Ui::DialogDateTimeFormats),
m_dateMode(true), m_dateMode(true),
m_date(date), m_date(date),
m_predefined(predefinedFormats) m_predefined(predefinedFormats)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -47,11 +51,11 @@ DialogDateTimeFormats::DialogDateTimeFormats(const QDate &date, const QStringLis
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogDateTimeFormats::DialogDateTimeFormats(const QTime &time, const QStringList &predefinedFormats, DialogDateTimeFormats::DialogDateTimeFormats(const QTime &time, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent) const QStringList &userDefinedFormats, QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::DialogDateTimeFormats), ui(new Ui::DialogDateTimeFormats),
m_dateMode(false), m_dateMode(false),
m_time(time), m_time(time),
m_predefined(predefinedFormats) m_predefined(predefinedFormats)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -69,7 +73,7 @@ auto DialogDateTimeFormats::GetFormats() const -> QStringList
{ {
QStringList formats; QStringList formats;
for (int i=0; i<ui->listWidget->count(); ++i) for (int i = 0; i < ui->listWidget->count(); ++i)
{ {
if (const QListWidgetItem *lineItem = ui->listWidget->item(i)) if (const QListWidgetItem *lineItem = ui->listWidget->item(i))
{ {

View file

@ -28,12 +28,16 @@
#include "dialogknownmaterials.h" #include "dialogknownmaterials.h"
#include "ui_dialogknownmaterials.h" #include "ui_dialogknownmaterials.h"
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogKnownMaterials::DialogKnownMaterials(QWidget *parent) DialogKnownMaterials::DialogKnownMaterials(QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::DialogKnownMaterials) ui(new Ui::DialogKnownMaterials)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -80,7 +84,7 @@ auto DialogKnownMaterials::GetList() const -> QStringList
{ {
QStringList list; QStringList list;
for (int i=0; i<ui->listWidget->count(); ++i) for (int i = 0; i < ui->listWidget->count(); ++i)
{ {
if (const QListWidgetItem *item = ui->listWidget->item(i)) if (const QListWidgetItem *item = ui->listWidget->item(i))
{ {

View file

@ -34,7 +34,11 @@
#include <QSet> #include <QSet>
#include <QStringList> #include <QStringList>
#include <QSvgRenderer> #include <QSvgRenderer>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
@ -72,7 +76,7 @@ auto MimeTypeFromByteArray(const QByteArray &data) -> QMimeType
QSet<QString> aliases = ConvertToSet<QString>(mime.aliases()); QSet<QString> aliases = ConvertToSet<QString>(mime.aliases());
aliases.insert(mime.name()); aliases.insert(mime.name());
QSet<QString> gzipMime {"application/gzip", "application/x-gzip"}; QSet<QString> gzipMime{"application/gzip", "application/x-gzip"};
if (gzipMime.contains(aliases)) if (gzipMime.contains(aliases))
{ {
@ -92,7 +96,7 @@ auto PrepareImageFilters() -> QString
const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats(); const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
const QSet<QString> filterFormats{"bmp", "jpeg", "jpg", "png", "svg", "svgz", "tif", "tiff", "webp"}; const QSet<QString> filterFormats{"bmp", "jpeg", "jpg", "png", "svg", "svgz", "tif", "tiff", "webp"};
QStringList sufixes; QStringList sufixes;
for (const auto& format : supportedFormats) for (const auto &format : supportedFormats)
{ {
if (filterFormats.contains(format)) if (filterFormats.contains(format))
{ {

View file

@ -27,20 +27,24 @@
*************************************************************************/ *************************************************************************/
#include "vbackgroundpatternimage.h" #include "vbackgroundpatternimage.h"
#include "utils.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#include "utils.h"
#include <QMimeType> #include <QBuffer>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QMimeDatabase>
#include <QPixmap>
#include <QBuffer>
#include <QImageReader> #include <QImageReader>
#include <ciso646> #include <QMimeDatabase>
#include <QMimeType>
#include <QPixmap>
#include <QSvgRenderer> #include <QSvgRenderer>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
const QString VBackgroundPatternImage::brokenImage = QStringLiteral("://icon/svg/broken_path.svg"); const QString VBackgroundPatternImage::brokenImage = QStringLiteral("://icon/svg/broken_path.svg");
namespace namespace
@ -57,7 +61,7 @@ auto ScaleRasterImage(const QImage &image) -> QSize
const double ratioX = PrintDPI / (image.dotsPerMeterX() / 100. * 2.54); const double ratioX = PrintDPI / (image.dotsPerMeterX() / 100. * 2.54);
const double ratioY = PrintDPI / (image.dotsPerMeterY() / 100. * 2.54); const double ratioY = PrintDPI / (image.dotsPerMeterY() / 100. * 2.54);
const QSize imageSize = image.size(); const QSize imageSize = image.size();
return {qRound(imageSize.width()*ratioX), qRound(imageSize.height()*ratioY)}; return {qRound(imageSize.width() * ratioX), qRound(imageSize.height() * ratioY)};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -65,9 +69,9 @@ auto ScaleVectorImage(const QSvgRenderer &renderer) -> QSize
{ {
const QSize imageSize = renderer.defaultSize(); const QSize imageSize = renderer.defaultSize();
constexpr double ratio = PrintDPI / 90.; constexpr double ratio = PrintDPI / 90.;
return {qRound(imageSize.width()*ratio), qRound(imageSize.height()*ratio)}; return {qRound(imageSize.width() * ratio), qRound(imageSize.height() * ratio)};
} }
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VBackgroundPatternImage::FromFile(const QString &fileName, bool builtIn) -> VBackgroundPatternImage auto VBackgroundPatternImage::FromFile(const QString &fileName, bool builtIn) -> VBackgroundPatternImage

View file

@ -27,22 +27,25 @@
*************************************************************************/ *************************************************************************/
#include "vpatternimage.h" #include "vpatternimage.h"
#include <QBuffer>
#include <QDebug>
#include <QFile>
#include <QImage> #include <QImage>
#include <QImageReader> #include <QImageReader>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
#include <QRegularExpressionMatch> #include <QRegularExpressionMatch>
#include <QSvgRenderer>
#include <QDebug>
#include <QBuffer>
#include <QSize> #include <QSize>
#include <QFile> #include <QSvgRenderer>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#include "utils.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "utils.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPatternImage::FromFile(const QString &fileName) -> VPatternImage auto VPatternImage::FromFile(const QString &fileName) -> VPatternImage
@ -148,7 +151,7 @@ auto VPatternImage::GetPixmap(int width, int height) const -> QPixmap
QImage image = imageReader.read(); QImage image = imageReader.read();
if (image.isNull()) if (image.isNull())
{ {
qCritical()<< tr("Couldn't read the image. Error: %1").arg(imageReader.errorString()); qCritical() << tr("Couldn't read the image. Error: %1").arg(imageReader.errorString());
return {}; return {};
} }

View file

@ -31,76 +31,79 @@
* Warning/diagnostic handling * Warning/diagnostic handling
*/ */
#define QT_DO_PRAGMA(text) _Pragma(#text) #define QT_DO_PRAGMA(text) _Pragma(#text)
#if defined(Q_CC_INTEL) && defined(Q_CC_MSVC) #if defined(Q_CC_INTEL) && defined(Q_CC_MSVC)
/* icl.exe: Intel compiler on Windows */ /* icl.exe: Intel compiler on Windows */
# undef QT_DO_PRAGMA /* not needed */ #undef QT_DO_PRAGMA /* not needed */
# define QT_WARNING_PUSH __pragma(warning(push)) #define QT_WARNING_PUSH __pragma(warning(push))
# define QT_WARNING_POP __pragma(warning(pop)) #define QT_WARNING_POP __pragma(warning(pop))
# define QT_WARNING_DISABLE_MSVC(number) #define QT_WARNING_DISABLE_MSVC(number)
# define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable: number)) #define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable : number))
# define QT_WARNING_DISABLE_CLANG(text) #define QT_WARNING_DISABLE_CLANG(text)
# define QT_WARNING_DISABLE_GCC(text) #define QT_WARNING_DISABLE_GCC(text)
#elif defined(Q_CC_INTEL) #elif defined(Q_CC_INTEL)
/* icc: Intel compiler on Linux or OS X */ /* icc: Intel compiler on Linux or OS X */
# define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push)) #define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push))
# define QT_WARNING_POP QT_DO_PRAGMA(warning(pop)) #define QT_WARNING_POP QT_DO_PRAGMA(warning(pop))
# define QT_WARNING_DISABLE_INTEL(number) QT_DO_PRAGMA(warning(disable: number)) #define QT_WARNING_DISABLE_INTEL(number) QT_DO_PRAGMA(warning(disable : number))
# define QT_WARNING_DISABLE_MSVC(number) #define QT_WARNING_DISABLE_MSVC(number)
# define QT_WARNING_DISABLE_CLANG(text) #define QT_WARNING_DISABLE_CLANG(text)
# define QT_WARNING_DISABLE_GCC(text) #define QT_WARNING_DISABLE_GCC(text)
#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500 #elif defined(Q_CC_MSVC) && _MSC_VER >= 1500
# undef QT_DO_PRAGMA /* not needed */ #undef QT_DO_PRAGMA /* not needed */
# define QT_WARNING_PUSH __pragma(warning(push)) #define QT_WARNING_PUSH __pragma(warning(push))
# define QT_WARNING_POP __pragma(warning(pop)) #define QT_WARNING_POP __pragma(warning(pop))
# define QT_WARNING_DISABLE_MSVC(number) __pragma(warning(disable: number)) #define QT_WARNING_DISABLE_MSVC(number) __pragma(warning(disable : number))
# define QT_WARNING_DISABLE_INTEL(number) #define QT_WARNING_DISABLE_INTEL(number)
# define QT_WARNING_DISABLE_CLANG(text) #define QT_WARNING_DISABLE_CLANG(text)
# define QT_WARNING_DISABLE_GCC(text) #define QT_WARNING_DISABLE_GCC(text)
#elif defined(Q_CC_CLANG) #elif defined(Q_CC_CLANG)
# define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push) #define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push)
# define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop) #define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop)
# define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text) #define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text)
# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text)// GCC directives work in Clang too #define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) // GCC directives work in Clang too
# define QT_WARNING_DISABLE_INTEL(number) #define QT_WARNING_DISABLE_INTEL(number)
# define QT_WARNING_DISABLE_MSVC(number) #define QT_WARNING_DISABLE_MSVC(number)
#elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) #elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
# define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push) #define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push)
# define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop) #define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop)
# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) #define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text)
# define QT_WARNING_DISABLE_CLANG(text) #define QT_WARNING_DISABLE_CLANG(text)
# define QT_WARNING_DISABLE_INTEL(number) #define QT_WARNING_DISABLE_INTEL(number)
# define QT_WARNING_DISABLE_MSVC(number) #define QT_WARNING_DISABLE_MSVC(number)
#else // All other compilers, GCC < 4.6 and MSVC < 2008 #else // All other compilers, GCC < 4.6 and MSVC < 2008
# define QT_WARNING_DISABLE_GCC(text) #define QT_WARNING_DISABLE_GCC(text)
# define QT_WARNING_PUSH #define QT_WARNING_PUSH
# define QT_WARNING_POP #define QT_WARNING_POP
# define QT_WARNING_DISABLE_INTEL(number) #define QT_WARNING_DISABLE_INTEL(number)
# define QT_WARNING_DISABLE_MSVC(number) #define QT_WARNING_DISABLE_MSVC(number)
# define QT_WARNING_DISABLE_CLANG(text) #define QT_WARNING_DISABLE_CLANG(text)
# define QT_WARNING_DISABLE_GCC(text) #define QT_WARNING_DISABLE_GCC(text)
#endif #endif
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#define Q_DISABLE_COPY_MOVE(Class) \ #define Q_DISABLE_COPY_MOVE(Class) \
Q_DISABLE_COPY(Class) \ Q_DISABLE_COPY(Class) \
Class(Class &&) = delete; \ Class(Class &&) = delete; \
Class &operator=(Class &&) = delete; Class &operator=(Class &&) = delete;
#endif #endif
#ifndef Q_DISABLE_ASSIGN_MOVE #ifndef Q_DISABLE_ASSIGN_MOVE
#define Q_DISABLE_ASSIGN_MOVE(Class) \ #define Q_DISABLE_ASSIGN_MOVE(Class) \
Q_DISABLE_ASSIGN(Class) \ Q_DISABLE_ASSIGN(Class) \
Class(Class &&) = delete; \ Class(Class &&) = delete; \
Class &operator=(Class &&) = delete; Class &operator=(Class &&) = delete;
#endif #endif
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wattributes") QT_WARNING_DISABLE_GCC("-Wattributes")
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
class QLocale; class QLocale;
class QChar; class QChar;
@ -125,23 +128,23 @@ QMUPARSERSHARED_EXPORT auto LocaleExpLower(const QLocale &locale) -> QChar;
QMUPARSERSHARED_EXPORT auto LocaleDecimalPoint(const QLocale &locale) -> QChar; QMUPARSERSHARED_EXPORT auto LocaleDecimalPoint(const QLocale &locale) -> QChar;
QMUPARSERSHARED_EXPORT auto LocaleGroupSeparator(const QLocale &locale) -> QChar; QMUPARSERSHARED_EXPORT auto LocaleGroupSeparator(const QLocale &locale) -> QChar;
#define INIT_LOCALE_VARIABLES(locale) \ #define INIT_LOCALE_VARIABLES(locale) \
const QChar positiveSign = LocalePositiveSign((locale)); \ const QChar positiveSign = LocalePositiveSign((locale)); \
const QChar negativeSign = LocaleNegativeSign((locale)); \ const QChar negativeSign = LocaleNegativeSign((locale)); \
const QChar sign0 = LocaleSign0((locale)); \ const QChar sign0 = LocaleSign0((locale)); \
const QChar sign1 = LocaleSign1((locale)); \ const QChar sign1 = LocaleSign1((locale)); \
const QChar sign2 = LocaleSign2((locale)); \ const QChar sign2 = LocaleSign2((locale)); \
const QChar sign3 = LocaleSign3((locale)); \ const QChar sign3 = LocaleSign3((locale)); \
const QChar sign4 = LocaleSign4((locale)); \ const QChar sign4 = LocaleSign4((locale)); \
const QChar sign5 = LocaleSign5((locale)); \ const QChar sign5 = LocaleSign5((locale)); \
const QChar sign6 = LocaleSign6((locale)); \ const QChar sign6 = LocaleSign6((locale)); \
const QChar sign7 = LocaleSign7((locale)); \ const QChar sign7 = LocaleSign7((locale)); \
const QChar sign8 = LocaleSign8((locale)); \ const QChar sign8 = LocaleSign8((locale)); \
const QChar sign9 = LocaleSign9((locale)); \ const QChar sign9 = LocaleSign9((locale)); \
const QChar expUpper = LocaleExpUpper((locale)); \ const QChar expUpper = LocaleExpUpper((locale)); \
const QChar expLower = LocaleExpLower((locale)); \ const QChar expLower = LocaleExpLower((locale)); \
const QChar decimalPoint = LocaleDecimalPoint((locale)); \ const QChar decimalPoint = LocaleDecimalPoint((locale)); \
const QChar groupSeparator = LocaleGroupSeparator((locale)); const QChar groupSeparator = LocaleGroupSeparator((locale));
QMUPARSERSHARED_EXPORT auto NameRegExp() -> QString; QMUPARSERSHARED_EXPORT auto NameRegExp() -> QString;
@ -150,12 +153,12 @@ QT_WARNING_POP
Q_REQUIRED_RESULT static inline auto QmuFuzzyComparePossibleNulls(double p1, double p2) -> bool; Q_REQUIRED_RESULT static inline auto QmuFuzzyComparePossibleNulls(double p1, double p2) -> bool;
static inline auto QmuFuzzyComparePossibleNulls(double p1, double p2) -> bool static inline auto QmuFuzzyComparePossibleNulls(double p1, double p2) -> bool
{ {
if(qFuzzyIsNull(p1)) if (qFuzzyIsNull(p1))
{ {
return qFuzzyIsNull(p2); return qFuzzyIsNull(p2);
} }
if(qFuzzyIsNull(p2)) if (qFuzzyIsNull(p2))
{ {
return false; return false;
} }

View file

@ -24,9 +24,13 @@
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <locale>
#include <ciso646>
#include <QtGlobal> #include <QtGlobal>
#include <locale>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
#include "qmuparserfixes.h" #include "qmuparserfixes.h"
@ -42,60 +46,60 @@
#define QMUP_VERSION_DATE "20191030; GC" #define QMUP_VERSION_DATE "20191030; GC"
// Detect whether the compiler supports C++11 noexcept exception specifications. // Detect whether the compiler supports C++11 noexcept exception specifications.
# if defined(__clang__) #if defined(__clang__)
# if __has_feature(cxx_noexcept) #if __has_feature(cxx_noexcept)
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept #define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept
# endif #endif
# elif defined(__GNUC__) #elif defined(__GNUC__)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept #define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
# endif #endif
# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 #elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept #define QMUP_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept
# else #else
# define QMUP_NOEXCEPT_EXPR(x) #define QMUP_NOEXCEPT_EXPR(x)
# endif #endif
#ifndef __has_cpp_attribute #ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0 #define __has_cpp_attribute(x) 0
#endif #endif
#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
#ifndef QT_HAS_CPP_ATTRIBUTE #ifndef QT_HAS_CPP_ATTRIBUTE
#ifdef __has_cpp_attribute #ifdef __has_cpp_attribute
# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else #else
# define QT_HAS_CPP_ATTRIBUTE(x) 0 #define QT_HAS_CPP_ATTRIBUTE(x) 0
#endif #endif
#endif // QT_HAS_CPP_ATTRIBUTE #endif // QT_HAS_CPP_ATTRIBUTE
#if defined(__cplusplus) #if defined(__cplusplus)
#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) #if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]] #define Q_FALLTHROUGH() [[clang::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) #elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
# define Q_FALLTHROUGH() [[gnu::fallthrough]] #define Q_FALLTHROUGH() [[gnu::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) #elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
# define Q_FALLTHROUGH() [[fallthrough]] #define Q_FALLTHROUGH() [[fallthrough]]
#endif #endif
#endif #endif
#ifndef Q_FALLTHROUGH #ifndef Q_FALLTHROUGH
# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) #if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL)
# define Q_FALLTHROUGH() __attribute__((fallthrough)) #define Q_FALLTHROUGH() __attribute__((fallthrough))
# else #else
# define Q_FALLTHROUGH() (void)0 #define Q_FALLTHROUGH() (void)0
#endif #endif
#endif // defined(__cplusplus) #endif // defined(__cplusplus)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
/** @brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ /** @brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */
//#define QMUP_MATH_EXCEPTIONS // #define QMUP_MATH_EXCEPTIONS
/** @brief Activate this option in order to compile with OpenMP support. /** @brief Activate this option in order to compile with OpenMP support.
OpenMP is used only in the bulk mode it may increase the performance a bit. OpenMP is used only in the bulk mode it may increase the performance a bit.
*/ */
//#define QMUP_USE_OPENMP // #define QMUP_USE_OPENMP
/** @brief Definition of the basic parser string type. */ /** @brief Definition of the basic parser string type. */
#define QMUP_STRING_TYPE std::wstring #define QMUP_STRING_TYPE std::wstring
@ -120,28 +124,28 @@ enum ECmdCode
// The following are codes for built in binary operators // The following are codes for built in binary operators
// apart from built in operators the user has the opportunity to // apart from built in operators the user has the opportunity to
// add user defined operators. // add user defined operators.
cmLE = 0, ///< Operator item: less or equal cmLE = 0, ///< Operator item: less or equal
cmGE = 1, ///< Operator item: greater or equal cmGE = 1, ///< Operator item: greater or equal
cmNEQ = 2, ///< Operator item: not equal cmNEQ = 2, ///< Operator item: not equal
cmEQ = 3, ///< Operator item: equals cmEQ = 3, ///< Operator item: equals
cmLT = 4, ///< Operator item: less than cmLT = 4, ///< Operator item: less than
cmGT = 5, ///< Operator item: greater than cmGT = 5, ///< Operator item: greater than
cmADD = 6, ///< Operator item: add cmADD = 6, ///< Operator item: add
cmSUB = 7, ///< Operator item: subtract cmSUB = 7, ///< Operator item: subtract
cmMUL = 8, ///< Operator item: multiply cmMUL = 8, ///< Operator item: multiply
cmDIV = 9, ///< Operator item: division cmDIV = 9, ///< Operator item: division
cmPOW = 10, ///< Operator item: y to the power of ... cmPOW = 10, ///< Operator item: y to the power of ...
cmLAND = 11, cmLAND = 11,
cmLOR = 12, cmLOR = 12,
cmASSIGN = 13, ///< Operator item: Assignment operator cmASSIGN = 13, ///< Operator item: Assignment operator
cmBO = 14, ///< Operator item: opening bracket cmBO = 14, ///< Operator item: opening bracket
cmBC = 15, ///< Operator item: closing bracket cmBC = 15, ///< Operator item: closing bracket
cmIF = 16, ///< For use in the ternary if-then-else operator cmIF = 16, ///< For use in the ternary if-then-else operator
cmELSE = 17, ///< For use in the ternary if-then-else operator cmELSE = 17, ///< For use in the ternary if-then-else operator
cmENDIF = 18, ///< For use in the ternary if-then-else operator cmENDIF = 18, ///< For use in the ternary if-then-else operator
cmARG_SEP = 19, ///< function argument separator cmARG_SEP = 19, ///< function argument separator
cmVAR = 20, ///< variable item cmVAR = 20, ///< variable item
cmVAL = 21, ///< value item cmVAL = 21, ///< value item
// For optimization purposes // For optimization purposes
cmVARPOW2, cmVARPOW2,
@ -151,25 +155,25 @@ enum ECmdCode
cmPOW2, cmPOW2,
// operators and functions // operators and functions
cmFUNC, ///< Code for a generic function item cmFUNC, ///< Code for a generic function item
cmFUNC_STR, ///< Code for a function with a string parameter cmFUNC_STR, ///< Code for a function with a string parameter
cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index
cmSTRING, ///< Code for a string token cmSTRING, ///< Code for a string token
cmOPRT_BIN, ///< user defined binary operator cmOPRT_BIN, ///< user defined binary operator
cmOPRT_POSTFIX, ///< code for postfix operators cmOPRT_POSTFIX, ///< code for postfix operators
cmOPRT_INFIX, ///< code for infix operators cmOPRT_INFIX, ///< code for infix operators
cmEND, ///< end of formula cmEND, ///< end of formula
cmUNKNOWN ///< uninitialized item cmUNKNOWN ///< uninitialized item
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** @brief Types internally used by the parser. /** @brief Types internally used by the parser.
*/ */
enum ETypeCode enum ETypeCode
{ {
tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) tpSTR = 0, ///< String type (Function arguments and constants only, no string variables)
tpDBL = 1, ///< Floating point variables tpDBL = 1, ///< Floating point variables
tpVOID = 2 ///< Undefined type. tpVOID = 2 ///< Undefined type.
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -183,9 +187,9 @@ enum EParserVersionInfo
/** @brief Parser operator precedence values. */ /** @brief Parser operator precedence values. */
enum EOprtAssociativity enum EOprtAssociativity
{ {
oaLEFT = 0, oaLEFT = 0,
oaRIGHT = 1, oaRIGHT = 1,
oaNONE = 2 oaNONE = 2
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -193,17 +197,17 @@ enum EOprtAssociativity
enum EOprtPrecedence enum EOprtPrecedence
{ {
// binary operators // binary operators
prLOR = 1, prLOR = 1,
prLAND = 2, prLAND = 2,
prLOGIC = 3, ///< logic operators prLOGIC = 3, ///< logic operators
prCMP = 4, ///< comparsion operators prCMP = 4, ///< comparsion operators
prADD_SUB = 5, ///< addition prADD_SUB = 5, ///< addition
prMUL_DIV = 6, ///< multiplication/division prMUL_DIV = 6, ///< multiplication/division
prPOW = 7, ///< power operator priority (highest) prPOW = 7, ///< power operator priority (highest)
// infix operators // infix operators
prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator
prPOSTFIX = 6 ///< Postfix operator priority (currently unused) prPOSTFIX = 6 ///< Postfix operator priority (currently unused)
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -222,12 +226,12 @@ typedef QMUP_STRING_TYPE string_type;
typedef string_type::value_type char_type; typedef string_type::value_type char_type;
/** @brief Typedef for easily using stringstream that respect the parser stringtype. */ /** @brief Typedef for easily using stringstream that respect the parser stringtype. */
typedef std::basic_stringstream < char_type, std::char_traits<char_type>, std::allocator<char_type> > stringstream_type; typedef std::basic_stringstream<char_type, std::char_traits<char_type>, std::allocator<char_type>> stringstream_type;
// Data container types // Data container types
/** @brief Type used for storing variables. */ /** @brief Type used for storing variables. */
typedef std::map<QString, qreal*> varmap_type; typedef std::map<QString, qreal *> varmap_type;
/** @brief Type used for storing constants. */ /** @brief Type used for storing constants. */
typedef std::map<QString, qreal> valmap_type; typedef std::map<QString, qreal> valmap_type;
@ -238,92 +242,92 @@ typedef std::map<QString, qmusizetype> strmap_type;
// Parser callbacks // Parser callbacks
/** @brief Callback type used for functions without arguments. */ /** @brief Callback type used for functions without arguments. */
typedef qreal ( *generic_fun_type ) (); typedef qreal (*generic_fun_type)();
/** @brief Callback type used for functions without arguments. */ /** @brief Callback type used for functions without arguments. */
typedef qreal ( *fun_type0 ) (); typedef qreal (*fun_type0)();
/** @brief Callback type used for functions with a single arguments. */ /** @brief Callback type used for functions with a single arguments. */
typedef qreal ( *fun_type1 ) ( qreal ); typedef qreal (*fun_type1)(qreal);
/** @brief Callback type used for functions with two arguments. */ /** @brief Callback type used for functions with two arguments. */
typedef qreal ( *fun_type2 ) ( qreal, qreal ); typedef qreal (*fun_type2)(qreal, qreal);
/** @brief Callback type used for functions with three arguments. */ /** @brief Callback type used for functions with three arguments. */
typedef qreal ( *fun_type3 ) ( qreal, qreal, qreal ); typedef qreal (*fun_type3)(qreal, qreal, qreal);
/** @brief Callback type used for functions with four arguments. */ /** @brief Callback type used for functions with four arguments. */
typedef qreal ( *fun_type4 ) ( qreal, qreal, qreal, qreal ); typedef qreal (*fun_type4)(qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type5 ) ( qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type5)(qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type6 ) ( qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type6)(qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type7 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type7)(qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type8 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type8)(qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type9 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type9)(qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *fun_type10 ) ( qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*fun_type10)(qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions without arguments. */ /** @brief Callback type used for functions without arguments. */
typedef qreal ( *bulkfun_type0 ) ( int, int ); typedef qreal (*bulkfun_type0)(int, int);
/** @brief Callback type used for functions with a single arguments. */ /** @brief Callback type used for functions with a single arguments. */
typedef qreal ( *bulkfun_type1 ) ( int, int, qreal ); typedef qreal (*bulkfun_type1)(int, int, qreal);
/** @brief Callback type used for functions with two arguments. */ /** @brief Callback type used for functions with two arguments. */
typedef qreal ( *bulkfun_type2 ) ( int, int, qreal, qreal ); typedef qreal (*bulkfun_type2)(int, int, qreal, qreal);
/** @brief Callback type used for functions with three arguments. */ /** @brief Callback type used for functions with three arguments. */
typedef qreal ( *bulkfun_type3 ) ( int, int, qreal, qreal, qreal ); typedef qreal (*bulkfun_type3)(int, int, qreal, qreal, qreal);
/** @brief Callback type used for functions with four arguments. */ /** @brief Callback type used for functions with four arguments. */
typedef qreal ( *bulkfun_type4 ) ( int, int, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type4)(int, int, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type5 ) ( int, int, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type5)(int, int, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type6 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type6)(int, int, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type7 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type7)(int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type8 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type8)(int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type9 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type9)(int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with five arguments. */ /** @brief Callback type used for functions with five arguments. */
typedef qreal ( *bulkfun_type10 ) ( int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal ); typedef qreal (*bulkfun_type10)(int, int, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal, qreal);
/** @brief Callback type used for functions with a variable argument list. */ /** @brief Callback type used for functions with a variable argument list. */
typedef qreal ( *multfun_type ) ( const qreal*, qmusizetype ); typedef qreal (*multfun_type)(const qreal *, qmusizetype);
/** @brief Callback type used for functions taking a string as an argument. */ /** @brief Callback type used for functions taking a string as an argument. */
typedef qreal ( *strfun_type1 ) ( const QString & ); typedef qreal (*strfun_type1)(const QString &);
/** @brief Callback type used for functions taking a string and a value as arguments. */ /** @brief Callback type used for functions taking a string and a value as arguments. */
typedef qreal ( *strfun_type2 ) ( const QString &, qreal ); typedef qreal (*strfun_type2)(const QString &, qreal);
/** @brief Callback type used for functions taking a string and two values as arguments. */ /** @brief Callback type used for functions taking a string and two values as arguments. */
typedef qreal ( *strfun_type3 ) ( const QString &, qreal, qreal ); typedef qreal (*strfun_type3)(const QString &, qreal, qreal);
/** @brief Callback used for functions that identify values in a string. */ /** @brief Callback used for functions that identify values in a string. */
typedef int ( *identfun_type ) ( const QString &sExpr, qmusizetype *nPos, qreal *fVal, const QLocale &locale, typedef int (*identfun_type)(const QString &sExpr, qmusizetype *nPos, qreal *fVal, const QLocale &locale, bool cNumbers,
bool cNumbers, const QChar &decimal, const QChar &thousand ); const QChar &decimal, const QChar &thousand);
/** @brief Callback used for variable creation factory functions. */ /** @brief Callback used for variable creation factory functions. */
typedef qreal* ( *facfun_type ) ( const QString &, void* ); typedef qreal *(*facfun_type)(const QString &, void *);
} // end of namespace } // namespace qmu
#endif #endif

View file

@ -29,14 +29,27 @@
#ifndef DXFDEF_H #ifndef DXFDEF_H
#define DXFDEF_H #define DXFDEF_H
#include <QtGlobal>
#include <ciso646>
#include <QtCore/qcontainerfwd.h> #include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
enum class VarMeasurement : quint8 { English=0, Metric=1 }; // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//Default drawing units for AutoCAD DesignCenter blocks: enum class VarMeasurement : quint8
enum class VarInsunits : quint8 { Inches=1, Millimeters=4, Centimeters=5 }; {
English = 0,
Metric = 1
};
// Default drawing units for AutoCAD DesignCenter blocks:
enum class VarInsunits : quint8
{
Inches = 1,
Millimeters = 4,
Centimeters = 5
};
// Helps mark end of string. See VDxfEngine::drawTextItem for more details // Helps mark end of string. See VDxfEngine::drawTextItem for more details
extern const QString endStringPlaceholder; extern const QString endStringPlaceholder;
@ -44,7 +57,7 @@ extern const QString endStringPlaceholder;
Q_REQUIRED_RESULT static inline auto DL_FuzzyComparePossibleNulls(double p1, double p2) -> bool; Q_REQUIRED_RESULT static inline auto DL_FuzzyComparePossibleNulls(double p1, double p2) -> bool;
static inline auto DL_FuzzyComparePossibleNulls(double p1, double p2) -> bool static inline auto DL_FuzzyComparePossibleNulls(double p1, double p2) -> bool
{ {
if(qFuzzyIsNull(p1)) if (qFuzzyIsNull(p1))
{ {
return qFuzzyIsNull(p2); return qFuzzyIsNull(p2);
} }

View file

@ -15,166 +15,161 @@
#define DRW_VERSION "0.6.3" #define DRW_VERSION "0.6.3"
#include <string>
#include <list>
#include <cmath>
#include <unordered_map>
#include <QtGlobal> #include <QtGlobal>
#include <ciso646> #include <cmath>
#include <list>
#include <string>
#include <unordered_map>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#ifdef DRW_ASSERTS #ifdef DRW_ASSERTS
# define drw_assert(a) assert(a) #define drw_assert(a) assert(a)
#else #else
# define drw_assert(a) #define drw_assert(a)
#endif #endif
#define UTF8STRING std::string #define UTF8STRING std::string
#define DRW_UNUSED(x) (void)x #define DRW_UNUSED(x) (void)x
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define DRW_WIN #define DRW_WIN
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# define DRW_WIN #define DRW_WIN
#elif defined(__MWERKS__) && defined(__INTEL__) #elif defined(__MWERKS__) && defined(__INTEL__)
# define DRW_WIN #define DRW_WIN
#else #else
# define DRW_POSIX #define DRW_POSIX
#endif #endif
#ifndef M_PI #ifndef M_PI
#define M_PI 3.141592653589793238462643 #define M_PI 3.141592653589793238462643
#endif #endif
#ifndef M_PI_2 #ifndef M_PI_2
#define M_PI_2 1.57079632679489661923 #define M_PI_2 1.57079632679489661923
#endif #endif
#define M_PIx2 6.283185307179586 // 2*PI #define M_PIx2 6.283185307179586 // 2*PI
#define ARAD 57.29577951308232 #define ARAD 57.29577951308232
#ifndef __has_cpp_attribute #ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0 #define __has_cpp_attribute(x) 0
#endif #endif
#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
#ifndef QT_HAS_CPP_ATTRIBUTE #ifndef QT_HAS_CPP_ATTRIBUTE
#ifdef __has_cpp_attribute #ifdef __has_cpp_attribute
# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else #else
# define QT_HAS_CPP_ATTRIBUTE(x) 0 #define QT_HAS_CPP_ATTRIBUTE(x) 0
#endif #endif
#endif // QT_HAS_CPP_ATTRIBUTE #endif // QT_HAS_CPP_ATTRIBUTE
#if defined(__cplusplus) #if defined(__cplusplus)
#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) #if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]] #define Q_FALLTHROUGH() [[clang::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) #elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
# define Q_FALLTHROUGH() [[gnu::fallthrough]] #define Q_FALLTHROUGH() [[gnu::fallthrough]]
#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) #elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
# define Q_FALLTHROUGH() [[fallthrough]] #define Q_FALLTHROUGH() [[fallthrough]]
#endif #endif
#endif #endif
#ifndef Q_FALLTHROUGH #ifndef Q_FALLTHROUGH
# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) #if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL)
# define Q_FALLTHROUGH() __attribute__((fallthrough)) #define Q_FALLTHROUGH() __attribute__((fallthrough))
# else #else
# define Q_FALLTHROUGH() (void)0 #define Q_FALLTHROUGH() (void)0
#endif #endif
#endif // defined(__cplusplus) #endif // defined(__cplusplus)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#define Q_DISABLE_COPY_MOVE(Class) \ #define Q_DISABLE_COPY_MOVE(Class) \
Q_DISABLE_COPY(Class) \ Q_DISABLE_COPY(Class) \
Class(Class &&) = delete; \ Class(Class &&) = delete; \
Class &operator=(Class &&) = delete; Class &operator=(Class &&) = delete;
#endif #endif
#ifndef Q_DISABLE_ASSIGN_MOVE #ifndef Q_DISABLE_ASSIGN_MOVE
#define Q_DISABLE_ASSIGN_MOVE(Class) \ #define Q_DISABLE_ASSIGN_MOVE(Class) \
Q_DISABLE_ASSIGN(Class) \ Q_DISABLE_ASSIGN(Class) \
Class(Class &&) = delete; \ Class(Class &&) = delete; \
Class &operator=(Class &&) = delete; Class &operator=(Class &&) = delete;
#endif #endif
typedef signed char dint8; /* 8 bit signed */ typedef signed char dint8; /* 8 bit signed */
typedef signed short dint16; /* 16 bit signed */ typedef signed short dint16; /* 16 bit signed */
typedef signed int dint32; /* 32 bit signed */ typedef signed int dint32; /* 32 bit signed */
typedef long long int dint64; /* 64 bit signed */ typedef long long int dint64; /* 64 bit signed */
typedef unsigned char duint8; /* 8 bit unsigned */ typedef unsigned char duint8; /* 8 bit unsigned */
typedef unsigned short duint16; /* 16 bit unsigned */ typedef unsigned short duint16; /* 16 bit unsigned */
typedef unsigned int duint32; /* 32 bit unsigned */ typedef unsigned int duint32; /* 32 bit unsigned */
typedef unsigned long long int duint64; /* 64 bit unsigned */ typedef unsigned long long int duint64; /* 64 bit unsigned */
typedef float dfloat32; /* 32 bit floating point */ typedef float dfloat32; /* 32 bit floating point */
typedef double ddouble64; /* 64 bit floating point */ typedef double ddouble64; /* 64 bit floating point */
typedef long double ddouble80; /* 80 bit floating point */ typedef long double ddouble80; /* 80 bit floating point */
namespace DRW { namespace DRW
{
//! Version numbers for the DXF Format. //! Version numbers for the DXF Format.
enum Version { enum Version
UNKNOWNV, //!< UNKNOWN VERSION. {
MC00, //!< DWG Release 1.1 UNKNOWNV, //!< UNKNOWN VERSION.
AC12, //!< DWG Release 1.2 MC00, //!< DWG Release 1.1
AC14, //!< DWG Release 1.4 AC12, //!< DWG Release 1.2
AC150, //!< DWG Release 2.0 AC14, //!< DWG Release 1.4
AC210, //!< DWG Release 2.10 AC150, //!< DWG Release 2.0
AC1002, //!< DWG Release 2.5 AC210, //!< DWG Release 2.10
AC1003, //!< DWG Release 2.6 AC1002, //!< DWG Release 2.5
AC1004, //!< DWG Relase 9 AC1003, //!< DWG Release 2.6
AC1006, //!< DWG Release 10 (R10) AC1004, //!< DWG Relase 9
AC1009, //!< DWG Release 11/12 (LT R1/R2) (R11 & R12) AC1006, //!< DWG Release 10 (R10)
AC1012, //!< DWG Release 13 (LT95) (R13) AC1009, //!< DWG Release 11/12 (LT R1/R2) (R11 & R12)
AC1014, //!< DWG Release 14/14.01 (LT97/LT98) (R14) AC1012, //!< DWG Release 13 (LT95) (R13)
AC1015, //!< AutoCAD 2000/2000i/2002 (ACAD 2000) AC1014, //!< DWG Release 14/14.01 (LT97/LT98) (R14)
AC1018, //!< AutoCAD 2004/2005/2006 (ACAD 2004) AC1015, //!< AutoCAD 2000/2000i/2002 (ACAD 2000)
AC1021, //!< AutoCAD 2007/2008/2009 (ACAD 2007) AC1018, //!< AutoCAD 2004/2005/2006 (ACAD 2004)
AC1024, //!< AutoCAD 2010/2011/2012 (ACAD 2010) AC1021, //!< AutoCAD 2007/2008/2009 (ACAD 2007)
AC1027, //!< AutoCAD 2013/2014/2015/2016/2017 (ACAD 2013) AC1024, //!< AutoCAD 2010/2011/2012 (ACAD 2010)
AC1032, //!< AutoCAD 2018/2019/2020 (ACAD 2018) AC1027, //!< AutoCAD 2013/2014/2015/2016/2017 (ACAD 2013)
AC1032, //!< AutoCAD 2018/2019/2020 (ACAD 2018)
}; };
const std::unordered_map< const char*, DRW::Version > dwgVersionStrings { const std::unordered_map<const char *, DRW::Version> dwgVersionStrings{
{ "MC0.0", DRW::MC00 }, {"MC0.0", DRW::MC00}, {"AC1.2", DRW::AC12}, {"AC1.4", DRW::AC14}, {"AC1.50", DRW::AC150},
{ "AC1.2", DRW::AC12 }, {"AC2.10", DRW::AC210}, {"AC1002", DRW::AC1002}, {"AC1003", DRW::AC1003}, {"AC1004", DRW::AC1004},
{ "AC1.4", DRW::AC14 }, {"AC1006", DRW::AC1006}, {"AC1009", DRW::AC1009}, {"AC1012", DRW::AC1012}, {"AC1014", DRW::AC1014},
{ "AC1.50", DRW::AC150 }, {"AC1015", DRW::AC1015}, {"AC1018", DRW::AC1018}, {"AC1021", DRW::AC1021}, {"AC1024", DRW::AC1024},
{ "AC2.10", DRW::AC210 }, {"AC1027", DRW::AC1027}, {"AC1032", DRW::AC1032},
{ "AC1002", DRW::AC1002 },
{ "AC1003", DRW::AC1003 },
{ "AC1004", DRW::AC1004 },
{ "AC1006", DRW::AC1006 },
{ "AC1009", DRW::AC1009 },
{ "AC1012", DRW::AC1012 },
{ "AC1014", DRW::AC1014 },
{ "AC1015", DRW::AC1015 },
{ "AC1018", DRW::AC1018 },
{ "AC1021", DRW::AC1021 },
{ "AC1024", DRW::AC1024 },
{ "AC1027", DRW::AC1027 },
{ "AC1032", DRW::AC1032 },
}; };
enum error { enum error
BAD_NONE, /*!< No error. */ {
BAD_UNKNOWN, /*!< UNKNOWN. */ BAD_NONE, /*!< No error. */
BAD_OPEN, /*!< error opening file. */ BAD_UNKNOWN, /*!< UNKNOWN. */
BAD_VERSION, /*!< unsupported version. */ BAD_OPEN, /*!< error opening file. */
BAD_READ_METADATA, /*!< error reading matadata. */ BAD_VERSION, /*!< unsupported version. */
BAD_READ_FILE_HEADER, /*!< error in file header read process. */ BAD_READ_METADATA, /*!< error reading matadata. */
BAD_READ_HEADER, /*!< error in header vars read process. */ BAD_READ_FILE_HEADER, /*!< error in file header read process. */
BAD_READ_HANDLES, /*!< error in object map read process. */ BAD_READ_HEADER, /*!< error in header vars read process. */
BAD_READ_CLASSES, /*!< error in classes read process. */ BAD_READ_HANDLES, /*!< error in object map read process. */
BAD_READ_TABLES, /*!< error in tables read process. */ BAD_READ_CLASSES, /*!< error in classes read process. */
BAD_READ_BLOCKS, /*!< error in block read process. */ BAD_READ_TABLES, /*!< error in tables read process. */
BAD_READ_ENTITIES, /*!< error in entities read process. */ BAD_READ_BLOCKS, /*!< error in block read process. */
BAD_READ_OBJECTS, /*!< error in objects read process. */ BAD_READ_ENTITIES, /*!< error in entities read process. */
BAD_READ_SECTION, /*!< error in sections read process. */ BAD_READ_OBJECTS, /*!< error in objects read process. */
BAD_CODE_PARSED, /*!< error in any parseCodes() method. */ BAD_READ_SECTION, /*!< error in sections read process. */
BAD_CODE_PARSED, /*!< error in any parseCodes() method. */
}; };
enum class DebugLevel { enum class DebugLevel
{
None, None,
Debug Debug
}; };
@ -184,18 +179,29 @@ enum class DebugLevel {
* *
* The base class is silent and ignores all debugging. * The base class is silent and ignores all debugging.
*/ */
class DebugPrinter { class DebugPrinter
{
public: public:
virtual void printS(const std::string &s){(void)s;} virtual void printS(const std::string &s) { (void)s; }
virtual void printI(long long int i){(void)i;} virtual void printI(long long int i) { (void)i; }
virtual void printUI(long long unsigned int i){(void)i;} virtual void printUI(long long unsigned int i) { (void)i; }
virtual void printD(double d){(void)d;} virtual void printD(double d) { (void)d; }
virtual void printH(long long int i){(void)i;} virtual void printH(long long int i) { (void)i; }
virtual void printB(int i){(void)i;} virtual void printB(int i) { (void)i; }
virtual void printHL(int c, int s, int h){(void)c;(void)s;(void)h;} virtual void printHL(int c, int s, int h)
virtual void printPT(double x, double y, double z){(void)x;(void)y;(void)z;} {
DebugPrinter()=default; (void)c;
virtual ~DebugPrinter()=default; (void)s;
(void)h;
}
virtual void printPT(double x, double y, double z)
{
(void)x;
(void)y;
(void)z;
}
DebugPrinter() = default;
virtual ~DebugPrinter() = default;
}; };
/** /**
@ -203,10 +209,11 @@ public:
* *
* Ownership of `printer` is transferred. * Ownership of `printer` is transferred.
*/ */
void setCustomDebugPrinter( DebugPrinter* printer ); void setCustomDebugPrinter(DebugPrinter *printer);
//! Special codes for colors //! Special codes for colors
enum ColorCodes { enum ColorCodes
{
black = 250, black = 250,
green = 3, green = 3,
red = 1, red = 1,
@ -228,18 +235,21 @@ enum ColorCodes {
}; };
//! Spaces //! Spaces
enum Space { enum Space
{
ModelSpace = 0, ModelSpace = 0,
PaperSpace = 1 PaperSpace = 1
}; };
//! Special kinds of handles //! Special kinds of handles
enum HandleCodes { enum HandleCodes
{
NoHandle = 0 NoHandle = 0
}; };
//! Shadow mode //! Shadow mode
enum ShadowMode { enum ShadowMode
{
CastAndReceieveShadows = 0, CastAndReceieveShadows = 0,
CastShadows = 1, CastShadows = 1,
ReceiveShadows = 2, ReceiveShadows = 2,
@ -247,17 +257,20 @@ enum ShadowMode {
}; };
//! Special kinds of materials //! Special kinds of materials
enum MaterialCodes { enum MaterialCodes
{
MaterialByLayer = 0 MaterialByLayer = 0
}; };
//! Special kinds of plot styles //! Special kinds of plot styles
enum PlotStyleCodes { enum PlotStyleCodes
{
DefaultPlotStyle = 0 DefaultPlotStyle = 0
}; };
//! Special kinds of transparencies //! Special kinds of transparencies
enum TransparencyCodes { enum TransparencyCodes
{
Opaque = 0, Opaque = 0,
Transparent = -1 Transparent = -1
}; };
@ -267,7 +280,7 @@ enum TransparencyCodes {
Q_REQUIRED_RESULT static inline auto DRW_FuzzyComparePossibleNulls(double p1, double p2) -> bool; Q_REQUIRED_RESULT static inline auto DRW_FuzzyComparePossibleNulls(double p1, double p2) -> bool;
static inline auto DRW_FuzzyComparePossibleNulls(double p1, double p2) -> bool static inline auto DRW_FuzzyComparePossibleNulls(double p1, double p2) -> bool
{ {
if(qFuzzyIsNull(p1)) if (qFuzzyIsNull(p1))
{ {
return qFuzzyIsNull(p2); return qFuzzyIsNull(p2);
} }
@ -286,24 +299,27 @@ static inline auto DRW_FuzzyComparePossibleNulls(double p1, double p2) -> bool
* Class to handle 3D coordinate point * Class to handle 3D coordinate point
* @author Rallaz * @author Rallaz
*/ */
class DRW_Coord { class DRW_Coord
{
public: public:
DRW_Coord() = default; DRW_Coord() = default;
DRW_Coord(double ix, double iy, double iz) DRW_Coord(double ix, double iy, double iz)
: x(ix), : x(ix),
y(iy), y(iy),
z(iz) z(iz)
{} {
}
DRW_Coord(const DRW_Coord &data) DRW_Coord(const DRW_Coord &data)
: x(data.x), : x(data.x),
y(data.y), y(data.y),
z(data.z) z(data.z)
{} {
}
auto operator=(const DRW_Coord &data) -> DRW_Coord & auto operator=(const DRW_Coord &data) -> DRW_Coord &
{ {
if ( &data == this ) if (&data == this)
{ {
return *this; return *this;
} }
@ -313,136 +329,141 @@ public:
z = data.z; z = data.z;
return *this; return *this;
} }
/*!< convert to unitary vector */ /*!< convert to unitary vector */
void unitize(){ void unitize()
{
double dist; double dist;
dist = hypot(hypot(x, y), z); dist = hypot(hypot(x, y), z);
if (dist > 0.0) { if (dist > 0.0)
x= x/dist; {
y= y/dist; x = x / dist;
z= z/dist; y = y / dist;
z = z / dist;
} }
} }
public: public:
double x {0}; double x{0};
double y {0}; double y{0};
double z {0}; double z{0};
}; };
//! Class to handle vertex //! Class to handle vertex
/*! /*!
* Class to handle vertex for lwpolyline entity * Class to handle vertex for lwpolyline entity
* @author Rallaz * @author Rallaz
*/ */
class DRW_Vertex2D { class DRW_Vertex2D
{
public: public:
DRW_Vertex2D() DRW_Vertex2D()
: x(), : x(),
y(), y(),
stawidth(0), stawidth(0),
endwidth(0), endwidth(0),
bulge(0) bulge(0)
{ {
// eType = DRW::LWPOLYLINE; // eType = DRW::LWPOLYLINE;
} }
DRW_Vertex2D(double sx, double sy, double b = 0.0) DRW_Vertex2D(double sx, double sy, double b = 0.0)
: x(sx), : x(sx),
y(sy), y(sy),
stawidth(0), stawidth(0),
endwidth(0), endwidth(0),
bulge(b) bulge(b)
{} {
}
public: public:
double x; /*!< x coordinate, code 10 */ double x; /*!< x coordinate, code 10 */
double y; /*!< y coordinate, code 20 */ double y; /*!< y coordinate, code 20 */
double stawidth; /*!< Start width, code 40 */ double stawidth; /*!< Start width, code 40 */
double endwidth; /*!< End width, code 41 */ double endwidth; /*!< End width, code 41 */
double bulge; /*!< bulge, code 42 */ double bulge; /*!< bulge, code 42 */
}; };
//! Class to handle header vars //! Class to handle header vars
/*! /*!
* Class to handle header vars * Class to handle header vars
* @author Rallaz * @author Rallaz
*/ */
class DRW_Variant { class DRW_Variant
{
public: public:
enum TYPE { enum TYPE
{
STRING, STRING,
INTEGER, INTEGER,
DOUBLE, DOUBLE,
COORD, COORD,
INVALID INVALID
}; };
//TODO: add INT64 support // TODO: add INT64 support
DRW_Variant() DRW_Variant()
: content(), : content(),
type(INVALID), type(INVALID),
code(), code(),
sdata(), sdata(),
vdata() vdata()
{} {
}
DRW_Variant(int c, dint32 i) DRW_Variant(int c, dint32 i)
: content(), : content(),
type(), type(),
code(c), code(c),
sdata(), sdata(),
vdata() vdata()
{ {
addInt(i); addInt(i);
} }
DRW_Variant(int c, duint32 i) DRW_Variant(int c, duint32 i)
: content(), : content(),
type(), type(),
code(c), code(c),
sdata(), sdata(),
vdata() vdata()
{ {
addInt(static_cast<dint32>(i));//RLZ: verify if work with big numbers addInt(static_cast<dint32>(i)); // RLZ: verify if work with big numbers
} }
DRW_Variant(int c, double d) DRW_Variant(int c, double d)
: content(), : content(),
type(), type(),
code(c), code(c),
sdata(), sdata(),
vdata() vdata()
{ {
addDouble(d); addDouble(d);
} }
DRW_Variant(int c, const UTF8STRING &s) DRW_Variant(int c, const UTF8STRING &s)
: content(), : content(),
type(), type(),
code(c), code(c),
sdata(), sdata(),
vdata() vdata()
{ {
addString(s); addString(s);
} }
DRW_Variant(int c, const DRW_Coord &crd) DRW_Variant(int c, const DRW_Coord &crd)
: content(), : content(),
type(), type(),
code(c), code(c),
sdata(), sdata(),
vdata() vdata()
{ {
addCoord(crd); addCoord(crd);
} }
DRW_Variant(const DRW_Variant& d) DRW_Variant(const DRW_Variant &d)
: content(d.content), : content(d.content),
type(d.type), type(d.type),
code(d.code), code(d.code),
sdata(), sdata(),
vdata() vdata()
{ {
if (d.type == COORD) if (d.type == COORD)
{ {
@ -459,18 +480,56 @@ public:
~DRW_Variant() = default; ~DRW_Variant() = default;
void addString(const UTF8STRING &s) {setType(STRING); sdata = s; content.s = &sdata;} void addString(const UTF8STRING &s)
void addInt(int i) {setType(INTEGER); content.i = i;} {
void addDouble(double d) {setType(DOUBLE); content.d = d;} setType(STRING);
void addCoord() {setType(COORD); vdata.x=0.0; vdata.y=0.0; vdata.z=0.0; content.v = &vdata;} sdata = s;
void addCoord(const DRW_Coord &v) {setType(COORD); vdata = v; content.v = &vdata;} content.s = &sdata;
void setType(TYPE t) { type = t;} }
void setCoordX(double d) { if (type == COORD) vdata.x = d;} void addInt(int i)
void setCoordY(double d) { if (type == COORD) vdata.y = d;} {
void setCoordZ(double d) { if (type == COORD) vdata.z = d;} setType(INTEGER);
content.i = i;
}
void addDouble(double d)
{
setType(DOUBLE);
content.d = d;
}
void addCoord()
{
setType(COORD);
vdata.x = 0.0;
vdata.y = 0.0;
vdata.z = 0.0;
content.v = &vdata;
}
void addCoord(const DRW_Coord &v)
{
setType(COORD);
vdata = v;
content.v = &vdata;
}
void setType(TYPE t) { type = t; }
void setCoordX(double d)
{
if (type == COORD)
vdata.x = d;
}
void setCoordY(double d)
{
if (type == COORD)
vdata.y = d;
}
void setCoordZ(double d)
{
if (type == COORD)
vdata.z = d;
}
private: private:
typedef union { typedef union
{
UTF8STRING *s; UTF8STRING *s;
dint32 i; dint32 i;
double d; double d;
@ -480,7 +539,7 @@ private:
public: public:
DRW_VarContent content; DRW_VarContent content;
TYPE type; TYPE type;
int code; /*!< dxf code of this value*/ int code; /*!< dxf code of this value*/
private: private:
auto operator=(const DRW_Variant &) -> DRW_Variant &Q_DECL_EQ_DELETE; auto operator=(const DRW_Variant &) -> DRW_Variant &Q_DECL_EQ_DELETE;
@ -490,14 +549,16 @@ private:
//! Class to convert between line width and integer //! Class to convert between line width and integer
/*! /*!
* Class to convert between line width and integer * Class to convert between line width and integer
* verifing valid values, if value is not valid * verifing valid values, if value is not valid
* returns widthDefault. * returns widthDefault.
* @author Rallaz * @author Rallaz
*/ */
class DRW_LW_Conv{ class DRW_LW_Conv
{
public: public:
enum lineWidth { enum lineWidth
{
width00 = 0, /*!< 0.00mm (dxf 0)*/ width00 = 0, /*!< 0.00mm (dxf 0)*/
width01 = 1, /*!< 0.05mm (dxf 5)*/ width01 = 1, /*!< 0.05mm (dxf 5)*/
width02 = 2, /*!< 0.09mm (dxf 9)*/ width02 = 2, /*!< 0.09mm (dxf 9)*/
@ -529,71 +590,73 @@ public:
static auto lineWidth2dxfInt(lineWidth lw) -> int static auto lineWidth2dxfInt(lineWidth lw) -> int
{ {
switch (lw){ switch (lw)
case widthByLayer: {
return -1; case widthByLayer:
case widthByBlock: return -1;
return -2; case widthByBlock:
case widthDefault: return -2;
return -3; case widthDefault:
case width00: return -3;
return 0; case width00:
case width01: return 0;
return 5; case width01:
case width02: return 5;
return 9; case width02:
case width03: return 9;
return 13; case width03:
case width04: return 13;
return 15; case width04:
case width05: return 15;
return 18; case width05:
case width06: return 18;
return 20; case width06:
case width07: return 20;
return 25; case width07:
case width08: return 25;
return 30; case width08:
case width09: return 30;
return 35; case width09:
case width10: return 35;
return 40; case width10:
case width11: return 40;
return 50; case width11:
case width12: return 50;
return 53; case width12:
case width13: return 53;
return 60; case width13:
case width14: return 60;
return 70; case width14:
case width15: return 70;
return 80; case width15:
case width16: return 80;
return 90; case width16:
case width17: return 90;
return 100; case width17:
case width18: return 100;
return 106; case width18:
case width19: return 106;
return 120; case width19:
case width20: return 120;
return 140; case width20:
case width21: return 140;
return 158; case width21:
case width22: return 158;
return 200; case width22:
case width23: return 200;
return 211; case width23:
default: return 211;
break; default:
break;
} }
return -3; return -3;
} }
static auto dxfInt2lineWidth(int i) -> lineWidth static auto dxfInt2lineWidth(int i) -> lineWidth
{ {
if (i<0) { if (i < 0)
if (i==-1) {
if (i == -1)
return widthByLayer; return widthByLayer;
if (i == -2) if (i == -2)
return widthByBlock; return widthByBlock;
@ -696,7 +759,7 @@ public:
{ {
return width23; return width23;
} }
//default by default // default by default
return widthDefault; return widthDefault;
} }
}; };

View file

@ -13,20 +13,25 @@
#ifndef LIBDXFRW_H #ifndef LIBDXFRW_H
#define LIBDXFRW_H #define LIBDXFRW_H
#include <string>
#include <unordered_map>
#include "drw_entities.h" #include "drw_entities.h"
#include "drw_objects.h"
#include "drw_header.h" #include "drw_header.h"
#include "drw_interface.h" #include "drw_interface.h"
#include <ciso646> #include "drw_objects.h"
#include <string>
#include <unordered_map>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
class dxfReader; class dxfReader;
class dxfWriter; class dxfWriter;
class dxfRW { class dxfRW
{
public: public:
explicit dxfRW(const char* name); explicit dxfRW(const char *name);
~dxfRW(); ~dxfRW();
static void setDebug(DRW::DebugLevel lvl); static void setDebug(DRW::DebugLevel lvl);
/// reads the file specified in constructor /// reads the file specified in constructor
@ -38,8 +43,8 @@ public:
* @return true for success * @return true for success
*/ */
auto read(DRW_Interface *interface_, bool ext) -> bool; auto read(DRW_Interface *interface_, bool ext) -> bool;
void setBinary(bool b) {binFile = b;} void setBinary(bool b) { binFile = b; }
void AddXSpaceBlock(bool add) {m_xSpaceBlock = add;} void AddXSpaceBlock(bool add) { m_xSpaceBlock = add; }
auto write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool; auto write(DRW_Interface *interface_, DRW::Version ver, bool bin) -> bool;
auto writeLineType(DRW_LType *ent) -> bool; auto writeLineType(DRW_LType *ent) -> bool;
@ -72,7 +77,7 @@ public:
auto writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef *; auto writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef *;
auto writeLeader(DRW_Leader *ent) -> bool; auto writeLeader(DRW_Leader *ent) -> bool;
auto writeDimension(DRW_Dimension *ent) -> bool; auto writeDimension(DRW_Dimension *ent) -> bool;
void setEllipseParts(int parts){elParts = parts;} /*!< set parts number when convert ellipse to polyline */ void setEllipseParts(int parts) { elParts = parts; } /*!< set parts number when convert ellipse to polyline */
auto writePlotSettings(DRW_PlotSettings *ent) -> bool; auto writePlotSettings(DRW_PlotSettings *ent) -> bool;
auto ErrorString() const -> std::string; auto ErrorString() const -> std::string;
@ -135,7 +140,7 @@ private:
private: private:
DRW::Version version; DRW::Version version;
DRW::error error {DRW::BAD_NONE}; DRW::error error{DRW::BAD_NONE};
std::string fileName; std::string fileName;
std::string codePage; std::string codePage;
bool binFile; bool binFile;
@ -144,16 +149,16 @@ private:
dxfWriter *writer; dxfWriter *writer;
DRW_Interface *iface; DRW_Interface *iface;
DRW_Header header; DRW_Header header;
// int section; // int section;
std::string nextentity; std::string nextentity;
int entCount; int entCount;
bool wlayer0; bool wlayer0;
bool dimstyleStd; bool dimstyleStd;
bool applyExt; bool applyExt;
bool writingBlock; bool writingBlock;
int elParts; /*!< parts number when convert ellipse to polyline */ int elParts; /*!< parts number when convert ellipse to polyline */
std::unordered_map<std::string,int> blockMap; std::unordered_map<std::string, int> blockMap;
std::vector<DRW_ImageDef*> imageDef; /*!< imageDef list */ std::vector<DRW_ImageDef *> imageDef; /*!< imageDef list */
int currHandle; int currHandle;

View file

@ -33,6 +33,11 @@
#include <QString> #include <QString>
#include <QtMath> #include <QtMath>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#endif #endif

View file

@ -32,9 +32,13 @@
#include <QPainterPath> #include <QPainterPath>
#include <QSize> #include <QSize>
#include <QTransform> #include <QTransform>
#include <ciso646>
#include <climits> #include <climits>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
enum class LayoutExportFormats : qint8 enum class LayoutExportFormats : qint8
{ {
SVG = 0, SVG = 0,

View file

@ -50,7 +50,10 @@
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
// Backport of relaxed constexpr // Backport of relaxed constexpr
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)

View file

@ -53,6 +53,11 @@
#include "../vmisc/backport/text.h" #include "../vmisc/backport/text.h"
#endif #endif
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
class QPaintDevice; class QPaintDevice;
class QPixmap; class QPixmap;
class QPoint; class QPoint;
@ -60,8 +65,6 @@ class QPointF;
class QPolygonF; class QPolygonF;
class QRectF; class QRectF;
#include <ciso646>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
static inline auto svgEngineFeatures() -> QPaintEngine::PaintEngineFeatures static inline auto svgEngineFeatures() -> QPaintEngine::PaintEngineFeatures
{ {

View file

@ -21,7 +21,6 @@
#ifndef VPROPERTY_H #ifndef VPROPERTY_H
#define VPROPERTY_H #define VPROPERTY_H
#include <QAbstractItemDelegate> #include <QAbstractItemDelegate>
#include <QEvent> #include <QEvent>
#include <QMap> #include <QMap>
@ -32,30 +31,39 @@
#include <QStringList> #include <QStringList>
#include <QStyleOptionViewItem> #include <QStyleOptionViewItem>
#include <QVariant> #include <QVariant>
#include <Qt>
#include <QtGlobal>
#include <QtCore/qcontainerfwd.h> #include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
#include "vpropertyexplorer_global.h" #include "vpropertyexplorer_global.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#include "vpropertydef.h" #include "vpropertydef.h"
namespace VPE namespace VPE
{ {
enum class Property : qint8 {Simple, Complex}; enum class Property : qint8
{
Simple,
Complex
};
static const int MyCustomEventType = 1099; static const int MyCustomEventType = 1099;
class VPROPERTYEXPLORERSHARED_EXPORT UserChangeEvent : public QEvent class VPROPERTYEXPLORERSHARED_EXPORT UserChangeEvent : public QEvent
{ {
public: public:
UserChangeEvent() : QEvent(static_cast<QEvent::Type>(MyCustomEventType)) {} UserChangeEvent()
: QEvent(static_cast<QEvent::Type>(MyCustomEventType))
{
}
virtual ~UserChangeEvent() override; virtual ~UserChangeEvent() override;
}; };
@ -68,6 +76,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
enum DPC_DisplayColumn enum DPC_DisplayColumn
{ {
@ -76,7 +85,7 @@ public:
}; };
//! Standard constructor, takes a name and a parent property as argument //! Standard constructor, takes a name and a parent property as argument
explicit VProperty(const QString& name, explicit VProperty(const QString &name,
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMetaType::Type type = QMetaType::QString); QMetaType::Type type = QMetaType::QString);
#else #else
@ -122,7 +131,7 @@ public:
virtual auto flags(int column = DPC_Name) const -> Qt::ItemFlags; virtual auto flags(int column = DPC_Name) const -> Qt::ItemFlags;
//! Sets the value of the property //! Sets the value of the property
virtual void setValue(const QVariant& value); virtual void setValue(const QVariant &value);
//! Returns the value of the property as a QVariant //! Returns the value of the property as a QVariant
virtual auto getValue() const -> QVariant; virtual auto getValue() const -> QVariant;
@ -131,7 +140,7 @@ public:
virtual auto serialize() const -> QString; virtual auto serialize() const -> QString;
//! Deserializes the value from a string //! Deserializes the value from a string
virtual void deserialize(const QString& value); virtual void deserialize(const QString &value);
// The following functions are experimental and not yet implemented. // The following functions are experimental and not yet implemented.
/*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be /*//! Returns a pointer to the data stored and handled by this property. In most cases this function shouldn't be
@ -146,13 +155,13 @@ public:
virtual bool setDataPointer(void* pointer);*/ virtual bool setDataPointer(void* pointer);*/
//! Sets the name of the property //! Sets the name of the property
virtual void setName(const QString& name); virtual void setName(const QString &name);
//! Gets the name of the property //! Gets the name of the property
virtual auto getName() const -> QString; virtual auto getName() const -> QString;
//! Sets the name of the property //! Sets the name of the property
virtual void setDescription(const QString& desc); virtual void setDescription(const QString &desc);
//! Gets the name of the property //! Gets the name of the property
virtual auto getDescription() const -> QString; virtual auto getDescription() const -> QString;
@ -176,10 +185,10 @@ public:
virtual auto getParent() const -> VProperty *; virtual auto getParent() const -> VProperty *;
//! Sets the parent of this property //! Sets the parent of this property
virtual void setParent(VProperty* parent); virtual void setParent(VProperty *parent);
//! Removes a child from the children list, doesn't delete the child! //! Removes a child from the children list, doesn't delete the child!
virtual void removeChild(VProperty* child); virtual void removeChild(VProperty *child);
//! Returns the row the child has //! Returns the row the child has
virtual auto getChildRow(VProperty *child) const -> vpesizetype; virtual auto getChildRow(VProperty *child) const -> vpesizetype;
@ -195,13 +204,13 @@ public:
//! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item //! Sets the settings by calling the overloaded setSetting(const QString& key, const QVariant& value) for each item
//! in the map. //! in the map.
virtual void setSettings(const QMap<QString, QVariant>& settings); virtual void setSettings(const QMap<QString, QVariant> &settings);
//! Get the settings. //! Get the settings.
virtual auto getSettings() const -> QMap<QString, QVariant>; virtual auto getSettings() const -> QMap<QString, QVariant>;
//! Sets the settings. This function has to be implemented in a subclass in order to have an effect //! Sets the settings. This function has to be implemented in a subclass in order to have an effect
virtual void setSetting(const QString& key, const QVariant& value); virtual void setSetting(const QString &key, const QVariant &value);
//! Get the settings. This function has to be implemented in a subclass in order to have an effect //! Get the settings. This function has to be implemented in a subclass in order to have an effect
virtual auto getSetting(const QString &key) const -> QVariant; virtual auto getSetting(const QString &key) const -> QVariant;
@ -218,7 +227,7 @@ public:
-> VProperty *; -> VProperty *;
auto propertyType() const -> Property; auto propertyType() const -> Property;
void setPropertyType(const Property &type); void setPropertyType(const Property &type);
virtual void UpdateParent(const QVariant &value); virtual void UpdateParent(const QVariant &value);
public slots: public slots:
@ -228,10 +237,10 @@ signals:
protected: protected:
//! Protected constructor //! Protected constructor
explicit VProperty(VPropertyPrivate* d); explicit VProperty(VPropertyPrivate *d);
//! The protected structure holding the member variables (to assure binary compatibility) //! The protected structure holding the member variables (to assure binary compatibility)
VPropertyPrivate* d_ptr; VPropertyPrivate *d_ptr;
private: private:
// Provide access functions for the d_ptr // Provide access functions for the d_ptr
@ -241,6 +250,6 @@ private:
QT_WARNING_POP QT_WARNING_POP
} } // namespace VPE
#endif // VPROPERTY_H #endif // VPROPERTY_H

View file

@ -44,7 +44,10 @@
#include "../vlayout/vrawsapoint.h" #include "../vlayout/vrawsapoint.h"
#include "../vlayout/vsapoint.h" #include "../vlayout/vsapoint.h"
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#ifdef __GNUC__ #ifdef __GNUC__
#define V_UNUSED __attribute__((unused)) #define V_UNUSED __attribute__((unused))
@ -81,7 +84,9 @@ class VRawSAPoint;
class AbstractTest : public QObject class AbstractTest : public QObject
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public : explicit AbstractTest(QObject *parent = nullptr);
public:
explicit AbstractTest(QObject *parent = nullptr);
template <class T> static auto VectorFromJson(const QString &json) -> QVector<T>; template <class T> static auto VectorFromJson(const QString &json) -> QVector<T>;

View file

@ -29,11 +29,15 @@
#include <QPainter> #include <QPainter>
#include <QTextLayout> #include <QTextLayout>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VElidedLabel::VElidedLabel(QWidget *parent) VElidedLabel::VElidedLabel(QWidget *parent)
: QFrame(parent) : QFrame(parent)
{ {
// reserve size for one line of text // reserve size for one line of text
setMinimumHeight(fontMetrics().lineSpacing()); setMinimumHeight(fontMetrics().lineSpacing());
@ -41,8 +45,8 @@ VElidedLabel::VElidedLabel(QWidget *parent)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VElidedLabel::VElidedLabel(const QString &text, QWidget *parent) VElidedLabel::VElidedLabel(const QString &text, QWidget *parent)
: QFrame(parent), : QFrame(parent),
m_content(text) m_content(text)
{ {
// reserve size for one line of text // reserve size for one line of text
setMinimumHeight(fontMetrics().lineSpacing()); setMinimumHeight(fontMetrics().lineSpacing());
@ -71,7 +75,7 @@ void VElidedLabel::paintEvent(QPaintEvent *event)
if (not DrawParagraph(painter, paragraphs.at(i), y, didElide)) if (not DrawParagraph(painter, paragraphs.at(i), y, didElide))
{ {
// It text has empty strings a user will not see elided string, but we still want to show a tooltip. // It text has empty strings a user will not see elided string, but we still want to show a tooltip.
if (i != paragraphs.size()-1 && !didElide) if (i != paragraphs.size() - 1 && !didElide)
{ {
didElide = true; didElide = true;
} }
@ -90,7 +94,7 @@ void VElidedLabel::paintEvent(QPaintEvent *event)
// Show a tooltip in case we cannot show a whole text in the widget // Show a tooltip in case we cannot show a whole text in the widget
// Use dumb html tag to separate paragraphs. // Use dumb html tag to separate paragraphs.
QString toolTip; QString toolTip;
for(int i = 0; i < paragraphs.size(); ++i) for (int i = 0; i < paragraphs.size(); ++i)
{ {
if (i != 0) if (i != 0)
{ {

View file

@ -27,20 +27,23 @@
*************************************************************************/ *************************************************************************/
#include "vplaintextedit.h" #include "vplaintextedit.h"
#include <ciso646> // Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlainTextEdit::VPlainTextEdit(QWidget * parent) VPlainTextEdit::VPlainTextEdit(QWidget *parent)
: QPlainTextEdit(parent), : QPlainTextEdit(parent),
m_highlighter(document()) m_highlighter(document())
{ {
connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses); connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlainTextEdit::VPlainTextEdit(const QString & text, QWidget * parent) VPlainTextEdit::VPlainTextEdit(const QString &text, QWidget *parent)
: QPlainTextEdit(text, parent), : QPlainTextEdit(text, parent),
m_highlighter(document()) m_highlighter(document())
{ {
connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses); connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses);
} }
@ -54,13 +57,13 @@ VPlainTextEdit::~VPlainTextEdit()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPlainTextEdit::SetFilter(const QString &filter) void VPlainTextEdit::SetFilter(const QString &filter)
{ {
if(m_filter.isEmpty() && not filter.isEmpty()) if (m_filter.isEmpty() && not filter.isEmpty())
{ {
QTextDocument *doc = document(); QTextDocument *doc = document();
m_allLines.clear(); m_allLines.clear();
m_allLines.reserve(doc->lineCount()); m_allLines.reserve(doc->lineCount());
for(int i=0; i < doc->blockCount(); ++i) for (int i = 0; i < doc->blockCount(); ++i)
{ {
m_allLines.append(doc->findBlockByNumber(i).text()); m_allLines.append(doc->findBlockByNumber(i).text());
} }
@ -70,7 +73,7 @@ void VPlainTextEdit::SetFilter(const QString &filter)
Filter(); Filter();
if(m_filter.isEmpty()) if (m_filter.isEmpty())
{ {
m_allLines.clear(); m_allLines.clear();
} }
@ -232,9 +235,9 @@ void VPlainTextEdit::CreateParenthesisSelection(int pos, bool match)
void VPlainTextEdit::Filter() void VPlainTextEdit::Filter()
{ {
clear(); clear();
if(not m_filter.isEmpty()) if (not m_filter.isEmpty())
{ {
for(auto &line : m_allLines) for (auto &line : m_allLines)
{ {
if (line.contains(m_filter)) if (line.contains(m_filter))
{ {
@ -244,7 +247,7 @@ void VPlainTextEdit::Filter()
} }
else else
{ {
for(auto &line : m_allLines) for (auto &line : m_allLines)
{ {
QPlainTextEdit::appendPlainText(line); QPlainTextEdit::appendPlainText(line);
} }

View file

@ -32,7 +32,11 @@
#include <QFile> #include <QFile>
#include <QObject> #include <QObject>
#include <QSharedPointer> #include <QSharedPointer>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"

View file

@ -30,11 +30,15 @@
#include "../vmisc/commandoptions.h" #include "../vmisc/commandoptions.h"
#include <QtTest> #include <QtTest>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TST_VCommandLine::TST_VCommandLine(QObject *parent) TST_VCommandLine::TST_VCommandLine(QObject *parent)
:QObject(parent) : QObject(parent)
{ {
} }

View file

@ -30,11 +30,15 @@
#include "../vmisc/vlockguard.h" #include "../vmisc/vlockguard.h"
#include <QtTest> #include <QtTest>
#include <ciso646>
// Header <ciso646> is removed in C++20.
#if __cplusplus <= 201703L
#include <ciso646> // and, not, or
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TST_VLockGuard::TST_VLockGuard(QObject *parent) TST_VLockGuard::TST_VLockGuard(QObject *parent)
:QObject(parent) : QObject(parent)
{ {
} }