From 394d54e9c12fec0181331e01778591a75b855886 Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 10 Dec 2014 20:01:33 +0200 Subject: [PATCH] Convertor need throw exceptions. --HG-- branch : feature --- src/app/app.pri | 1 - src/app/container/vcontainer.h | 2 +- src/app/core/vapplication.cpp | 10 +- src/app/dialogs/app/dialogundo.cpp | 2 +- src/app/geometry/vsplinepath.cpp | 2 +- src/app/options.h | 78 +----------- src/app/tools/drawTools/vdrawtool.cpp | 2 +- src/app/tools/drawTools/vtoolalongline.cpp | 2 +- src/app/xml/vdomdocument.cpp | 6 +- src/app/xml/vpattern.cpp | 10 +- src/{app => libs/ifc}/exception/exception.pri | 0 .../ifc}/exception/vexception.cpp | 1 - src/{app => libs/ifc}/exception/vexception.h | 3 +- .../ifc}/exception/vexceptionbadid.cpp | 1 - .../ifc}/exception/vexceptionbadid.h | 0 .../exception/vexceptionconversionerror.cpp | 0 .../exception/vexceptionconversionerror.h | 0 .../exception/vexceptionemptyparameter.cpp | 0 .../ifc}/exception/vexceptionemptyparameter.h | 0 .../ifc}/exception/vexceptionobjecterror.cpp | 0 .../ifc}/exception/vexceptionobjecterror.h | 0 .../ifc}/exception/vexceptionundo.cpp | 0 .../ifc}/exception/vexceptionundo.h | 0 .../ifc}/exception/vexceptionwrongid.cpp | 0 .../ifc}/exception/vexceptionwrongid.h | 0 src/libs/ifc/ifc.pri | 9 +- src/libs/ifc/ifcdef.h | 111 ++++++++++++++++++ src/libs/ifc/{ => xml}/vabstractconverter.cpp | 0 src/libs/ifc/{ => xml}/vabstractconverter.h | 0 src/libs/ifc/xml/xml.pri | 8 ++ 30 files changed, 145 insertions(+), 103 deletions(-) rename src/{app => libs/ifc}/exception/exception.pri (100%) rename src/{app => libs/ifc}/exception/vexception.cpp (99%) rename src/{app => libs/ifc}/exception/vexception.h (98%) rename src/{app => libs/ifc}/exception/vexceptionbadid.cpp (99%) rename src/{app => libs/ifc}/exception/vexceptionbadid.h (100%) rename src/{app => libs/ifc}/exception/vexceptionconversionerror.cpp (100%) rename src/{app => libs/ifc}/exception/vexceptionconversionerror.h (100%) rename src/{app => libs/ifc}/exception/vexceptionemptyparameter.cpp (100%) rename src/{app => libs/ifc}/exception/vexceptionemptyparameter.h (100%) rename src/{app => libs/ifc}/exception/vexceptionobjecterror.cpp (100%) rename src/{app => libs/ifc}/exception/vexceptionobjecterror.h (100%) rename src/{app => libs/ifc}/exception/vexceptionundo.cpp (100%) rename src/{app => libs/ifc}/exception/vexceptionundo.h (100%) rename src/{app => libs/ifc}/exception/vexceptionwrongid.cpp (100%) rename src/{app => libs/ifc}/exception/vexceptionwrongid.h (100%) create mode 100644 src/libs/ifc/ifcdef.h rename src/libs/ifc/{ => xml}/vabstractconverter.cpp (100%) rename src/libs/ifc/{ => xml}/vabstractconverter.h (100%) create mode 100644 src/libs/ifc/xml/xml.pri diff --git a/src/app/app.pri b/src/app/app.pri index 89a39befa..bfc1e20c3 100644 --- a/src/app/app.pri +++ b/src/app/app.pri @@ -1,7 +1,6 @@ # Suport subdirectories. Just better project code tree. include(container/container.pri) include(dialogs/dialogs.pri) -include(exception/exception.pri) include(geometry/geometry.pri) include(tools/tools.pri) include(widgets/widgets.pri) diff --git a/src/app/container/vcontainer.h b/src/app/container/vcontainer.h index 1b00c557d..cb40925d9 100644 --- a/src/app/container/vcontainer.h +++ b/src/app/container/vcontainer.h @@ -32,7 +32,7 @@ #include "variables.h" #include "../geometry/vdetail.h" #include "../geometry/vgobject.h" -#include "../exception/vexceptionbadid.h" +#include "../libs/ifc/exception/vexceptionbadid.h" #include "../geometry/vabstractcurve.h" #include diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 042b383c6..f42e18c3a 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -27,11 +27,11 @@ *************************************************************************/ #include "vapplication.h" -#include "../exception/vexceptionobjecterror.h" -#include "../exception/vexceptionbadid.h" -#include "../exception/vexceptionconversionerror.h" -#include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionwrongid.h" +#include "../libs/ifc/exception/vexceptionobjecterror.h" +#include "../libs/ifc/exception/vexceptionbadid.h" +#include "../libs/ifc/exception/vexceptionconversionerror.h" +#include "../libs/ifc/exception/vexceptionemptyparameter.h" +#include "../libs/ifc/exception/vexceptionwrongid.h" #include "vmaingraphicsview.h" #include "../container/calculator.h" #include "../version.h" diff --git a/src/app/dialogs/app/dialogundo.cpp b/src/app/dialogs/app/dialogundo.cpp index 8e5e1223e..705adee55 100644 --- a/src/app/dialogs/app/dialogundo.cpp +++ b/src/app/dialogs/app/dialogundo.cpp @@ -29,7 +29,7 @@ #include "dialogundo.h" #include "ui_dialogundo.h" #include "../../core/vapplication.h" -#include "../../exception/vexceptionundo.h" +#include "../../libs/ifc/exception/vexceptionundo.h" #include #include diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index 33df03750..d2c49976b 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -28,7 +28,7 @@ #include "vsplinepath.h" #include "vsplinepath_p.h" -#include "../exception/vexception.h" +#include "../libs/ifc/exception/vexception.h" //--------------------------------------------------------------------------------------------------------------------- VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode) diff --git a/src/app/options.h b/src/app/options.h index fb12f3d19..beaf82dbf 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -29,8 +29,8 @@ #ifndef OPTIONS_H #define OPTIONS_H -#include #include +#include "../libs/ifc/ifcdef.h" #ifdef Q_OS_WIN32 # if defined( Q_CC_MSVC ) // MSVC USED @@ -46,12 +46,8 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; class QString; class QStringList; -static const quint32 null_id = 0; - #define SceneSize 50000 #define DefPointRadius 2.0//mm -#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value. -#define NULL_ID_STR "0" extern const QString nameRegExp; extern const QString degreeSymbol; @@ -324,76 +320,4 @@ extern const QString cm_Oprt; extern const QString mm_Oprt; extern const QString in_Oprt; -/* - * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow - * you to continue afterwards should you choose to. - * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 - * Usefull links: - * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - - * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func - * - * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx - * - * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx - * - * 4. Continue to debug after failed assertion on Linux? [C/C++] - - * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c - */ -#ifndef QT_NO_DEBUG -#ifdef Q_OS_WIN32 -#ifdef Q_CC_MSVC -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __FUNCSIG__, __FILE__, __LINE__); \ - DebugBreak(); \ - } \ -} \ - -#else - -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ - DebugBreak(); \ - } \ -} \ - -#endif /*Q_CC_MSVC*/ -#else -#define SCASSERT(cond) \ -{ \ - if (!(cond)) \ - { \ - qDebug("ASSERT: %s in %s (%s:%u)", \ - #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ - std::raise(SIGTRAP); \ - } \ -} \ - -#endif /* Q_OS_WIN32 */ -#else // define but disable this function if debugging is not set -#define SCASSERT(cond) qt_noop(); -#endif /* QT_NO_DEBUG */ - -// Detect whether the compiler supports C++11 noexcept exception specifications. -# if defined(__clang__) -# if __has_feature(cxx_noexcept) -# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept -# endif -# elif defined(__GNUC__) -# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept -# endif -# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114 -# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) -# else -# define V_NOEXCEPT_EXPR(x) -# endif - #endif // OPTIONS_H diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index 228a9f85b..0902db7ba 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -34,7 +34,7 @@ #include "../container/calculator.h" #include "../../undocommands/addtocalc.h" #include "../../undocommands/savetooloptions.h" -#include "../../exception/vexceptionundo.h" +#include "../../libs/ifc/exception/vexceptionundo.h" qreal VDrawTool::factor = 1; diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 9d610b7a5..597618386 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -30,7 +30,7 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialogalongline.h" #include "../../geometry/vpointf.h" -#include "../../exception/vexceptionobjecterror.h" +#include "../../libs/ifc/exception/vexceptionobjecterror.h" #include "../../visualization/vistoolalongline.h" const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); diff --git a/src/app/xml/vdomdocument.cpp b/src/app/xml/vdomdocument.cpp index 56ecdcc94..1d5ac15a0 100644 --- a/src/app/xml/vdomdocument.cpp +++ b/src/app/xml/vdomdocument.cpp @@ -27,9 +27,9 @@ *************************************************************************/ #include "vdomdocument.h" -#include "../exception/vexceptionconversionerror.h" -#include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionbadid.h" +#include "../libs/ifc/exception/vexceptionconversionerror.h" +#include "../libs/ifc/exception/vexceptionemptyparameter.h" +#include "../libs/ifc/exception/vexceptionbadid.h" #include "../options.h" #include "../core/vapplication.h" diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 1d7f20c0b..38b329be0 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -32,11 +32,11 @@ #include "../tools/vtooluniondetails.h" #include "../tools/drawTools/drawtools.h" #include "../tools/nodeDetails/nodedetails.h" -#include "../exception/vexceptionobjecterror.h" -#include "../exception/vexceptionwrongid.h" -#include "../exception/vexceptionconversionerror.h" -#include "../exception/vexceptionemptyparameter.h" -#include "../exception/vexceptionundo.h" +#include "../libs/ifc/exception/vexceptionobjecterror.h" +#include "../libs/ifc/exception/vexceptionwrongid.h" +#include "../libs/ifc/exception/vexceptionconversionerror.h" +#include "../libs/ifc/exception/vexceptionemptyparameter.h" +#include "../libs/ifc/exception/vexceptionundo.h" #include "../core/undoevent.h" #include "../core/vsettings.h" #include "vstandardmeasurements.h" diff --git a/src/app/exception/exception.pri b/src/libs/ifc/exception/exception.pri similarity index 100% rename from src/app/exception/exception.pri rename to src/libs/ifc/exception/exception.pri diff --git a/src/app/exception/vexception.cpp b/src/libs/ifc/exception/vexception.cpp similarity index 99% rename from src/app/exception/vexception.cpp rename to src/libs/ifc/exception/vexception.cpp index 25ab65a2b..051c6d60f 100644 --- a/src/app/exception/vexception.cpp +++ b/src/libs/ifc/exception/vexception.cpp @@ -31,7 +31,6 @@ #include #include #include -#include "../options.h" #include Q_LOGGING_CATEGORY(vExcep, "v.excep") diff --git a/src/app/exception/vexception.h b/src/libs/ifc/exception/vexception.h similarity index 98% rename from src/app/exception/vexception.h rename to src/libs/ifc/exception/vexception.h index ebd560157..3cf192406 100644 --- a/src/app/exception/vexception.h +++ b/src/libs/ifc/exception/vexception.h @@ -31,8 +31,7 @@ #include #include -#include -#include "../options.h" +#include "ifcdef.h" class QWidget; diff --git a/src/app/exception/vexceptionbadid.cpp b/src/libs/ifc/exception/vexceptionbadid.cpp similarity index 99% rename from src/app/exception/vexceptionbadid.cpp rename to src/libs/ifc/exception/vexceptionbadid.cpp index c26f03182..7b2dad8f1 100644 --- a/src/app/exception/vexceptionbadid.cpp +++ b/src/libs/ifc/exception/vexceptionbadid.cpp @@ -27,7 +27,6 @@ *************************************************************************/ #include "vexceptionbadid.h" -#include "../options.h" //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/exception/vexceptionbadid.h b/src/libs/ifc/exception/vexceptionbadid.h similarity index 100% rename from src/app/exception/vexceptionbadid.h rename to src/libs/ifc/exception/vexceptionbadid.h diff --git a/src/app/exception/vexceptionconversionerror.cpp b/src/libs/ifc/exception/vexceptionconversionerror.cpp similarity index 100% rename from src/app/exception/vexceptionconversionerror.cpp rename to src/libs/ifc/exception/vexceptionconversionerror.cpp diff --git a/src/app/exception/vexceptionconversionerror.h b/src/libs/ifc/exception/vexceptionconversionerror.h similarity index 100% rename from src/app/exception/vexceptionconversionerror.h rename to src/libs/ifc/exception/vexceptionconversionerror.h diff --git a/src/app/exception/vexceptionemptyparameter.cpp b/src/libs/ifc/exception/vexceptionemptyparameter.cpp similarity index 100% rename from src/app/exception/vexceptionemptyparameter.cpp rename to src/libs/ifc/exception/vexceptionemptyparameter.cpp diff --git a/src/app/exception/vexceptionemptyparameter.h b/src/libs/ifc/exception/vexceptionemptyparameter.h similarity index 100% rename from src/app/exception/vexceptionemptyparameter.h rename to src/libs/ifc/exception/vexceptionemptyparameter.h diff --git a/src/app/exception/vexceptionobjecterror.cpp b/src/libs/ifc/exception/vexceptionobjecterror.cpp similarity index 100% rename from src/app/exception/vexceptionobjecterror.cpp rename to src/libs/ifc/exception/vexceptionobjecterror.cpp diff --git a/src/app/exception/vexceptionobjecterror.h b/src/libs/ifc/exception/vexceptionobjecterror.h similarity index 100% rename from src/app/exception/vexceptionobjecterror.h rename to src/libs/ifc/exception/vexceptionobjecterror.h diff --git a/src/app/exception/vexceptionundo.cpp b/src/libs/ifc/exception/vexceptionundo.cpp similarity index 100% rename from src/app/exception/vexceptionundo.cpp rename to src/libs/ifc/exception/vexceptionundo.cpp diff --git a/src/app/exception/vexceptionundo.h b/src/libs/ifc/exception/vexceptionundo.h similarity index 100% rename from src/app/exception/vexceptionundo.h rename to src/libs/ifc/exception/vexceptionundo.h diff --git a/src/app/exception/vexceptionwrongid.cpp b/src/libs/ifc/exception/vexceptionwrongid.cpp similarity index 100% rename from src/app/exception/vexceptionwrongid.cpp rename to src/libs/ifc/exception/vexceptionwrongid.cpp diff --git a/src/app/exception/vexceptionwrongid.h b/src/libs/ifc/exception/vexceptionwrongid.h similarity index 100% rename from src/app/exception/vexceptionwrongid.h rename to src/libs/ifc/exception/vexceptionwrongid.h diff --git a/src/libs/ifc/ifc.pri b/src/libs/ifc/ifc.pri index ee70c94c8..124d558f1 100644 --- a/src/libs/ifc/ifc.pri +++ b/src/libs/ifc/ifc.pri @@ -1,10 +1,13 @@ +# Suport subdirectories. Just better project code tree. +include(exception/exception.pri) +include(xml/xml.pri) + # ADD TO EACH PATH $$PWD VARIABLE!!!!!! # This need for corect working file translations.pro HEADERS += \ - $$PWD/vabstractconverter.h \ - $$PWD/stable.h + $$PWD/stable.h \ + $$PWD/ifcdef.h SOURCES += \ - $$PWD/vabstractconverter.cpp \ $$PWD/stable.cpp diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h new file mode 100644 index 000000000..6b8915473 --- /dev/null +++ b/src/libs/ifc/ifcdef.h @@ -0,0 +1,111 @@ +/************************************************************************ + ** + ** @file ifcdef.h + ** @author Roman Telezhynskyi + ** @date 10 12, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef IFCDEF_H +#define IFCDEF_H + +#include + +static const quint32 null_id = 0; + +#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value. +#define NULL_ID_STR "0" + +/* + * This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow + * you to continue afterwards should you choose to. + * idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148 + * Usefull links: + * 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? - + * https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func + * + * 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx + * + * 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx + * + * 4. Continue to debug after failed assertion on Linux? [C/C++] - + * https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c + */ +#ifndef QT_NO_DEBUG +#ifdef Q_OS_WIN32 +#ifdef Q_CC_MSVC +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __FUNCSIG__, __FILE__, __LINE__); \ + DebugBreak(); \ + } \ +} \ + +#else + +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + DebugBreak(); \ + } \ +} \ + +#endif /*Q_CC_MSVC*/ +#else +#define SCASSERT(cond) \ +{ \ + if (!(cond)) \ + { \ + qDebug("ASSERT: %s in %s (%s:%u)", \ + #cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\ + std::raise(SIGTRAP); \ + } \ +} \ + +#endif /* Q_OS_WIN32 */ +#else // define but disable this function if debugging is not set +#define SCASSERT(cond) qt_noop(); +#endif /* QT_NO_DEBUG */ + +// Detect whether the compiler supports C++11 noexcept exception specifications. +# if defined(__clang__) +# if __has_feature(cxx_noexcept) +# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept +# endif +# elif defined(__GNUC__) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept +# endif +# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114 +# define QMUP_NOEXCEPT_EXPR(x) noexcept(x) +# else +# define V_NOEXCEPT_EXPR(x) +# endif + +#endif // IFCDEF_H diff --git a/src/libs/ifc/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp similarity index 100% rename from src/libs/ifc/vabstractconverter.cpp rename to src/libs/ifc/xml/vabstractconverter.cpp diff --git a/src/libs/ifc/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h similarity index 100% rename from src/libs/ifc/vabstractconverter.h rename to src/libs/ifc/xml/vabstractconverter.h diff --git a/src/libs/ifc/xml/xml.pri b/src/libs/ifc/xml/xml.pri new file mode 100644 index 000000000..9c8d74470 --- /dev/null +++ b/src/libs/ifc/xml/xml.pri @@ -0,0 +1,8 @@ +# ADD TO EACH PATH $$PWD VARIABLE!!!!!! +# This need for corect working file translations.pro + +HEADERS += \ + $$PWD/vabstractconverter.h + +SOURCES += \ + $$PWD/vabstractconverter.cpp