diff --git a/Framework/DataHandling/src/LoadRaw/isisraw.h b/Framework/DataHandling/src/LoadRaw/isisraw.h index bef41bc1531cb1cfe6491181b3765109f563dd58..e89b48ef4a2ab4e57ffb48fd42e0754ff39b9b27 100644 --- a/Framework/DataHandling/src/LoadRaw/isisraw.h +++ b/Framework/DataHandling/src/LoadRaw/isisraw.h @@ -12,7 +12,7 @@ struct ISISCRPT_STRUCT; #include <cstdlib> #include <cstring> #ifdef _WIN32 /* _WIN32 */ -#include <time.h> +#include <ctime> #endif #include "MantidKernel/System.h" diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index 1a64e6d16ffdb741d0c2a77eac38646e06409873..59d7a73503e6fa4ac50115d68e9e100da3723e92 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -2,7 +2,7 @@ #define MANTID_DATAOBJECTS_EVENTLIST_H_ 1 #ifdef _WIN32 /* _WIN32 */ -#include <time.h> +#include <ctime> #endif #include "MantidAPI/IEventList.h" #include "MantidDataObjects/Events.h" diff --git a/Framework/DataObjects/inc/MantidDataObjects/Events.h b/Framework/DataObjects/inc/MantidDataObjects/Events.h index daa7916ca5616224203e50ce1ec6f9ad18e1dd50..dd2704f07894847fa5311ce0d61a26ab3c84af3c 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Events.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Events.h @@ -2,7 +2,7 @@ #define MANTID_DATAOBJECTS_EVENTS_H_ #ifdef _WIN32 /* _WIN32 */ -#include <time.h> +#include <ctime> #endif #include <cstddef> #include <iosfwd> diff --git a/Framework/ICat/src/ICat3/ICat3Helper.cpp b/Framework/ICat/src/ICat3/ICat3Helper.cpp index 35491cabdd366969706dde322a6dfaec6b127ca0..f613f2b30bee89f706f3ff36c39f1e8d039cc698 100644 --- a/Framework/ICat/src/ICat3/ICat3Helper.cpp +++ b/Framework/ICat/src/ICat3/ICat3Helper.cpp @@ -11,7 +11,7 @@ GCC_DIAG_OFF(literal-suffix) #include "MantidAPI/ITableWorkspace.h" #include "MantidKernel/Logger.h" #include <iomanip> -#include <time.h> +#include <ctime> #include <boost/lexical_cast.hpp> namespace Mantid { diff --git a/Framework/Kernel/inc/MantidKernel/DateAndTime.h b/Framework/Kernel/inc/MantidKernel/DateAndTime.h index b0ad7e71719cf20ebb646d95d969db3b57f6991b..1f1a0c5e2a7d1ad222fa3aada199737778d71c32 100644 --- a/Framework/Kernel/inc/MantidKernel/DateAndTime.h +++ b/Framework/Kernel/inc/MantidKernel/DateAndTime.h @@ -5,9 +5,9 @@ #ifndef Q_MOC_RUN #include <boost/date_time/posix_time/posix_time.hpp> #endif -#include <time.h> +#include <cstdint> +#include <ctime> #include <iosfwd> -#include <stdint.h> #include <string> #include <vector> diff --git a/Framework/Kernel/inc/MantidKernel/Timer.h b/Framework/Kernel/inc/MantidKernel/Timer.h index c8f4e883bdbca074454c6e665df4b1e8dcd74ddc..fbf03dd155353453af14082808a7ee10776690ee 100644 --- a/Framework/Kernel/inc/MantidKernel/Timer.h +++ b/Framework/Kernel/inc/MantidKernel/Timer.h @@ -5,15 +5,13 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/DllConfig.h" +#include <chrono> #include <iosfwd> - -#ifdef _WIN32 -#include <time.h> -#else -#include <sys/time.h> -#endif #include <string> +// forward declaration +// class std::chrono::time_point; + namespace Mantid { namespace Kernel { /** A simple class that provides a wall-clock (not processor time) timer. @@ -53,12 +51,7 @@ public: void reset(); private: -// The type of this variable is different depending on the platform -#ifdef _WIN32 - clock_t -#else - timeval -#endif + std::chrono::time_point<std::chrono::high_resolution_clock> m_start; ///< The starting time (implementation dependent format) }; diff --git a/Framework/Kernel/src/ArrayLengthValidator.cpp b/Framework/Kernel/src/ArrayLengthValidator.cpp index 967bc41c12b26a709dfe1e96e494e856bda3419e..7527a2c4a5f3c58b7966a70f67767f1967cf2f25 100644 --- a/Framework/Kernel/src/ArrayLengthValidator.cpp +++ b/Framework/Kernel/src/ArrayLengthValidator.cpp @@ -1,7 +1,7 @@ #include "MantidKernel/ArrayLengthValidator.h" #include <boost/make_shared.hpp> -#include <stdint.h> +#include <cstdint> using namespace Mantid::Kernel; diff --git a/Framework/Kernel/src/ArrayOrderedPairsValidator.cpp b/Framework/Kernel/src/ArrayOrderedPairsValidator.cpp index 5c27f6ab365b98f0257f43d580b9cc91601552e4..a970917f819d560c3d176f39a2c4cea54bce2977 100644 --- a/Framework/Kernel/src/ArrayOrderedPairsValidator.cpp +++ b/Framework/Kernel/src/ArrayOrderedPairsValidator.cpp @@ -1,7 +1,7 @@ #include "MantidKernel/ArrayOrderedPairsValidator.h" #include <boost/make_shared.hpp> -#include <stdint.h> +#include <cstdint> #include <sstream> namespace Mantid { diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index 59ca2639dfb3f5ecfb7605f28ae18f7c238ddf6a..39bd962fa83b833e06d067b1c766e1bb14310de5 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -46,13 +46,13 @@ #include <boost/regex.hpp> #include <algorithm> +#include <cctype> #include <exception> #include <fstream> #include <functional> #include <iostream> #include <stdexcept> #include <utility> -#include <ctype.h> #ifdef __APPLE__ #include <mach-o/dyld.h> diff --git a/Framework/Kernel/src/DateAndTime.cpp b/Framework/Kernel/src/DateAndTime.cpp index 8d2bd358fc52ca7993fd0aedf0618150192e6413..5261abd79ab50b17fd7a331a142b7781a6cae634 100644 --- a/Framework/Kernel/src/DateAndTime.cpp +++ b/Framework/Kernel/src/DateAndTime.cpp @@ -9,7 +9,7 @@ #include <boost/date_time/time.hpp> #include <boost/date_time/date.hpp> -#include <math.h> +#include <cmath> #include <exception> #include <limits> #include <memory> diff --git a/Framework/Kernel/src/DateValidator.cpp b/Framework/Kernel/src/DateValidator.cpp index 7f4e6eed7c14c8d231ae156288aac35d54aec178..de697257c74900aec28174de602234a896b988a7 100644 --- a/Framework/Kernel/src/DateValidator.cpp +++ b/Framework/Kernel/src/DateValidator.cpp @@ -1,7 +1,7 @@ #include "MantidKernel/DateValidator.h" #include <boost/lexical_cast.hpp> #include <boost/make_shared.hpp> -#include <time.h> +#include <ctime> namespace Mantid { namespace Kernel { diff --git a/Framework/Kernel/src/Memory.cpp b/Framework/Kernel/src/Memory.cpp index 98e99486c72066aeec357a17c7b1c3e02a13e33e..499287d795a7ac530095b8d4b6a5dcf842c8f3c3 100644 --- a/Framework/Kernel/src/Memory.cpp +++ b/Framework/Kernel/src/Memory.cpp @@ -2,8 +2,8 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/System.h" +#include <cstdio> #include <sstream> -#include <stdio.h> #ifdef __linux__ #include <unistd.h> diff --git a/Framework/Kernel/src/PropertyHistory.cpp b/Framework/Kernel/src/PropertyHistory.cpp index 8ef321fb5463fdf2c9e1538273c1f8312c3c779e..b3cc6a8cd5728382582e07f137d5dc36c1e30731 100644 --- a/Framework/Kernel/src/PropertyHistory.cpp +++ b/Framework/Kernel/src/PropertyHistory.cpp @@ -6,9 +6,9 @@ #include "MantidKernel/Property.h" #include "MantidKernel/Strings.h" -#include <boost/lexical_cast.hpp> #include <algorithm> -#include <stdint.h> +#include <boost/lexical_cast.hpp> +#include <cstdint> #include <ostream> namespace Mantid { diff --git a/Framework/Kernel/src/Timer.cpp b/Framework/Kernel/src/Timer.cpp index 2d8e1b9368e04657e4704294f6750f6e428f119a..72d83dccc4b7d08c6515ebfc59c1ea7cf419076f 100644 --- a/Framework/Kernel/src/Timer.cpp +++ b/Framework/Kernel/src/Timer.cpp @@ -2,6 +2,7 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/Timer.h" +#include <chrono> #include <ostream> #include <sstream> @@ -11,13 +12,7 @@ namespace Kernel { /** Constructor. * Instantiating the object starts the timer. */ -Timer::Timer() { -#ifdef _WIN32 - m_start = clock(); -#else /* linux & mac */ - gettimeofday(&m_start, nullptr); -#endif -} +Timer::Timer() { m_start = std::chrono::high_resolution_clock::now(); } /** Returns the wall-clock time elapsed in seconds since the Timer object's *creation, or the last call to elapsed @@ -38,29 +33,14 @@ float Timer::elapsed(bool reset) { * @return time in seconds */ float Timer::elapsed_no_reset() const { -#ifdef _WIN32 - clock_t now = clock(); - const float retval = float(now - m_start) / CLOCKS_PER_SEC; -#else /* linux & mac */ - timeval now; - gettimeofday(&now, nullptr); - const float retval = - float(now.tv_sec - m_start.tv_sec) + - float(static_cast<float>(now.tv_usec - m_start.tv_usec) / 1e6); -#endif - return retval; + const auto now = std::chrono::high_resolution_clock::now(); + std::chrono::duration<float> duration = now - m_start; + + return duration.count(); } /// Explicitly reset the timer. -void Timer::reset() { -#ifdef _WIN32 - m_start = clock(); -#else /* linux & mac */ - timeval now; - gettimeofday(&now, nullptr); - m_start = now; -#endif -} +void Timer::reset() { m_start = std::chrono::high_resolution_clock::now(); } /// Convert the elapsed time (without reseting) to a string. std::string Timer::str() const { diff --git a/Framework/Kernel/src/VMD.cpp b/Framework/Kernel/src/VMD.cpp index 6b013d20052ff1928cbc3890035680f5446ee069..a3925ff1987e8f9f9cde6306a1fbbd1e399e507a 100644 --- a/Framework/Kernel/src/VMD.cpp +++ b/Framework/Kernel/src/VMD.cpp @@ -6,9 +6,9 @@ #include "MantidKernel/V3D.h" #include <algorithm> +#include <cmath> #include <cstddef> #include <iterator> -#include <math.h> #include <sstream> #include <stdexcept> diff --git a/Framework/Kernel/test/DateAndTimeTest.h b/Framework/Kernel/test/DateAndTimeTest.h index 0beb5146a429227c55010f13edddd9ff3ebfd4ae..408c7aa7ecb43ab7dbf2864d2f8e0a57452ce666 100644 --- a/Framework/Kernel/test/DateAndTimeTest.h +++ b/Framework/Kernel/test/DateAndTimeTest.h @@ -8,12 +8,12 @@ #ifndef DATEANDTIMETEST_H_ #define DATEANDTIMETEST_H_ -#include <cxxtest/TestSuite.h> #include "MantidKernel/DateAndTime.h" #include "MantidKernel/System.h" -#include <sys/stat.h> -#include <time.h> +#include <ctime> +#include <cxxtest/TestSuite.h> #include <sstream> +#include <sys/stat.h> using namespace Mantid; using namespace Mantid::Kernel; diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index fc9010bc2a65aef1d17f09b351baf7f7b5f2719d..c82e88beaa95855330593c773e89f0b0ce63032b 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -130,9 +130,9 @@ #include "Mantid/InstrumentWidget/InstrumentWindow.h" #include "Mantid/RemoveErrorsDialog.h" -#include <stdio.h> -#include <stdlib.h> #include <cassert> +#include <cstdio> +#include <cstdlib> #include <iostream> #include <qwt_scale_engine.h> diff --git a/MantidPlot/src/AxesDialog.cpp b/MantidPlot/src/AxesDialog.cpp index 3212e4ea1d0e99651e4140c02b0d621ad5e11f87..98b5fced059f3de562f5fb154401516eacfa4a86 100644 --- a/MantidPlot/src/AxesDialog.cpp +++ b/MantidPlot/src/AxesDialog.cpp @@ -26,22 +26,21 @@ Description : General plot options dialog * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "MantidQtWidgets/Common/qwt_compat.h" #include "AxesDialog.h" #include "ApplicationWindow.h" -#include "TextDialog.h" #include "ColorBox.h" +#include "ColorButton.h" #include "Graph.h" #include "Grid.h" -#include "Plot.h" -#include "MyParser.h" -#include "ColorButton.h" -#include "TextFormatButtons.h" -#include "Table.h" #include "MantidQtWidgets/Common/DoubleSpinBox.h" +#include "MantidQtWidgets/Common/qwt_compat.h" +#include "MyParser.h" +#include "Plot.h" #include "ScaleDraw.h" -#include <float.h> - +#include "Table.h" +#include "TextDialog.h" +#include "TextFormatButtons.h" +#include <cfloat> #include <cmath> #include "MantidKernel/Logger.h" diff --git a/MantidPlot/src/Cone3D.cpp b/MantidPlot/src/Cone3D.cpp index 8401a8cebd304421e2dcaeb5ab85f1fcb150a948..4148e3073c98e323b821b6f1eee3dd6cd0dcf0ac 100644 --- a/MantidPlot/src/Cone3D.cpp +++ b/MantidPlot/src/Cone3D.cpp @@ -27,11 +27,11 @@ * Boston, MA 02110-1301 USA * * * ***************************************************************************/ +#include "Cone3D.h" #include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include <math.h> #include "qwt3d_color.h" #include "qwt3d_plot.h" -#include "Cone3D.h" +#include <cmath> using namespace Qwt3D; diff --git a/MantidPlot/src/FitDialog.cpp b/MantidPlot/src/FitDialog.cpp index 75e86d2e80aea7ad562b31306482fe57fc36f333..c2199216e5235aedf704d6d2f46f6996313564bc 100644 --- a/MantidPlot/src/FitDialog.cpp +++ b/MantidPlot/src/FitDialog.cpp @@ -61,7 +61,7 @@ #include <QTableWidget> #include <QWidget> #include <QWidgetList> -#include <stdio.h> +#include <cstdio> #include <qwt_plot_curve.h> diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp index 7ce3600f25a3b72d2f075d3196237c290303ec3a..7b80152826bd31258fe06e03a53c0757f11f5931 100644 --- a/MantidPlot/src/Graph.cpp +++ b/MantidPlot/src/Graph.cpp @@ -106,10 +106,10 @@ #include <qwt_text_label.h> #include <climits> -#include <math.h> -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> +#include <cmath> +#include <cstddef> +#include <cstdio> +#include <cstdlib> using namespace MantidQt::API; using CurveType = GraphOptions::CurveType; diff --git a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp index a7c813160c6ed446e560c38987f3fb735458b941..02e4a6ff67852b0030e45526c57b265c855f3f08 100644 --- a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp +++ b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp @@ -20,9 +20,9 @@ #include <QTemporaryFile> #include <QTextStream> -#include <numeric> +#include <cstdio> #include <fstream> -#include <stdio.h> +#include <numeric> using namespace Mantid::Kernel; using namespace Mantid::API; diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index 3863eabb10ebd141bbe9be158f9e3cf3978f8951..e6ac056bb0eae12a7db1f1b3ba928a9e21172fcb 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -72,8 +72,8 @@ #include <QToolBar> #include <algorithm> +#include <ctime> #include <qwt_plot_curve.h> -#include <time.h> #ifdef _WIN32 #include <windows.h> diff --git a/MantidPlot/src/Matrix.cpp b/MantidPlot/src/Matrix.cpp index 36ea4be18f3795f033f8c4b25edf486d1cb0ee2a..85c053c789291121b429e3cbefefcd5fd9de0efa 100644 --- a/MantidPlot/src/Matrix.cpp +++ b/MantidPlot/src/Matrix.cpp @@ -63,8 +63,8 @@ #include <boost/algorithm/string.hpp> -#include <stdio.h> -#include <stdlib.h> +#include <cstdio> +#include <cstdlib> #include <gsl/gsl_linalg.h> #include <gsl/gsl_math.h> diff --git a/MantidPlot/src/MatrixModel.cpp b/MantidPlot/src/MatrixModel.cpp index 52a39bd670cbaccb817cf5e0f755bd7d913817d4..919dd6e4c3d7e964805e8d9af84ca36dc3fc2f1e 100644 --- a/MantidPlot/src/MatrixModel.cpp +++ b/MantidPlot/src/MatrixModel.cpp @@ -44,8 +44,8 @@ #include <gsl/gsl_linalg.h> #include <gsl/gsl_errno.h> +#include <cstdlib> #include <qwt_color_map.h> -#include <stdlib.h> MatrixModel::MatrixModel(QObject *parent) : QAbstractTableModel(parent), d_matrix(dynamic_cast<Matrix *>(parent)) { diff --git a/MantidPlot/src/Spectrogram.cpp b/MantidPlot/src/Spectrogram.cpp index 142ae32e330a7cf2f9e098b9d3fd046c9ca11e95..d715ba45ee8281cc74a0322b71eff38b98cf26d0 100644 --- a/MantidPlot/src/Spectrogram.cpp +++ b/MantidPlot/src/Spectrogram.cpp @@ -25,15 +25,15 @@ * Boston, MA 02110-1301 USA * * * ***************************************************************************/ -#include "MantidQtWidgets/Common/qwt_compat.h" #include "Spectrogram.h" -#include <math.h> -#include <QPen> -#include <qwt_scale_widget.h> +#include "MantidQtWidgets/Common/qwt_compat.h" #include <QColor> +#include <QPainter> +#include <QPen> +#include <cmath> #include <qwt_painter.h> #include <qwt_scale_engine.h> -#include <QPainter> +#include <qwt_scale_widget.h> #include <qwt_symbol.h> #include "Mantid/MantidMatrix.h" diff --git a/MantidPlot/src/analysis/fft2D.cpp b/MantidPlot/src/analysis/fft2D.cpp index eff9fbd6a74df76033bb113e397e63120f68065f..155b783d1bdabfaa884d02f0aa0eb62a799db889 100644 --- a/MantidPlot/src/analysis/fft2D.cpp +++ b/MantidPlot/src/analysis/fft2D.cpp @@ -29,8 +29,8 @@ #include "fft2D.h" #include "../Matrix.h" //#define _USE_MATH_DEFINES -#include <math.h> #include <QVarLengthArray> +#include <cmath> void fft(double *x_int_re, double *x_int_im, int taille) { int size_2 = taille >> 1; double base = 2 * M_PI / taille; diff --git a/MantidPlot/src/fit_gsl.cpp b/MantidPlot/src/fit_gsl.cpp index 4040b71619db0bedb4398c5aaf6fa54e198c4984..2721839781cf4d031c6344f039f4e4374551c7c5 100644 --- a/MantidPlot/src/fit_gsl.cpp +++ b/MantidPlot/src/fit_gsl.cpp @@ -1,12 +1,12 @@ -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <stddef.h> -#include <qmessagebox.h> -#include <gsl/gsl_blas.h> -#include <gsl/gsl_math.h> #include "fit_gsl.h" #include "MyParser.h" +#include <cmath> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <gsl/gsl_blas.h> +#include <gsl/gsl_math.h> +#include <qmessagebox.h> int expd3_f(const gsl_vector *x, void *params, gsl_vector *f) { size_t n = ((struct FitData *)params)->n; double *X = ((struct FitData *)params)->X; diff --git a/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp b/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp index 7a0ef642f9bc0a5bad626595b971123ced055e44..47175a44e49e9bbb94af222a5b98e69ac002c300 100644 --- a/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp +++ b/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp @@ -44,25 +44,25 @@ ** ****************************************************************************/ +#include <QtCore/QMap> #include <QtGui/QApplication> -#include <QtGui/QDesktopWidget> -#include <QtGui/QPainter> -#include <QtGui/QPushButton> #include <QtGui/QColorDialog> -#include <QtCore/QMap> -#include <QtGui/QLayout> -#include <QtGui/QStyle> -#include <QtGui/QLabel> -#include <QtGui/QToolTip> -#include <QtGui/QPixmap> +#include <QtGui/QDesktopWidget> #include <QtGui/QFocusEvent> -#include <QtGui/QPaintEvent> #include <QtGui/QGridLayout> #include <QtGui/QHideEvent> #include <QtGui/QKeyEvent> -#include <QtGui/QShowEvent> +#include <QtGui/QLabel> +#include <QtGui/QLayout> #include <QtGui/QMouseEvent> -#include <math.h> +#include <QtGui/QPaintEvent> +#include <QtGui/QPainter> +#include <QtGui/QPixmap> +#include <QtGui/QPushButton> +#include <QtGui/QShowEvent> +#include <QtGui/QStyle> +#include <QtGui/QToolTip> +#include <cmath> #include "qtcolorpicker.h" diff --git a/MantidPlot/src/nrutil.cpp b/MantidPlot/src/nrutil.cpp index 0c5204bbd201465c1314c854d1fd2e40d130b127..3096a606de40276d2a491f137431266ad90bf5eb 100644 --- a/MantidPlot/src/nrutil.cpp +++ b/MantidPlot/src/nrutil.cpp @@ -1,7 +1,7 @@ -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <stddef.h> +#include <cmath> +#include <cstddef> +#include <cstdio> +#include <cstdlib> #include "nrutil.h" diff --git a/MantidPlot/src/origin/OPJFile.cpp b/MantidPlot/src/origin/OPJFile.cpp index 855d8c818a37a2ca470fcd46b8f0ffae14ece0f3..d577d34c91733c5ce58c6217b731f93881ac3e50 100644 --- a/MantidPlot/src/origin/OPJFile.cpp +++ b/MantidPlot/src/origin/OPJFile.cpp @@ -35,13 +35,13 @@ #pragma warning disable 181 #endif -#include <stdio.h> -#include <stdlib.h> -#include <limits.h> -#include <math.h> -#include <cstring> -#include <algorithm> //required for std::swap #include "OPJFile.h" +#include <algorithm> //required for std::swap +#include <climits> +#include <cmath> +#include <cstdio> +#include <cstdlib> +#include <cstring> using std::vector; using std::string; diff --git a/Testing/Tools/cxxtest/cxxtest/XmlFormatter.h b/Testing/Tools/cxxtest/cxxtest/XmlFormatter.h index afd3ec08739ae0b4afda48b9c7d636a485cdfee5..53a79e2c17c15985b765feb6d343c5e4b5128a61 100644 --- a/Testing/Tools/cxxtest/cxxtest/XmlFormatter.h +++ b/Testing/Tools/cxxtest/cxxtest/XmlFormatter.h @@ -23,26 +23,19 @@ #define CXXTEST_STACK_TRACE_FILELINE_PREFIX "\" location=\"" #define CXXTEST_STACK_TRACE_FILELINE_SUFFIX "" - -#include <cxxtest/TestRunner.h> +#include <chrono> +#include <cstring> +#include <ctime> +#include <cxxtest/ErrorFormatter.h> +#include <cxxtest/StdHeaders.h> #include <cxxtest/TestListener.h> +#include <cxxtest/TestRunner.h> #include <cxxtest/TestTracker.h> #include <cxxtest/ValueTraits.h> -#include <cxxtest/ErrorFormatter.h> -#include <cxxtest/StdHeaders.h> -#include <ctime> -#ifdef _WIN32 -#include <time.h> -#else -#include <sys/time.h> -#endif -#include <time.h> #include <iostream> #include <sstream> -#include <cstring> #include <stdexcept> - namespace CxxTest { class TeeOutputStreams @@ -144,16 +137,16 @@ namespace CxxTest std::map<std::string,std::string>::iterator curr=attribute.begin(); std::map<std::string,std::string>::iterator end =attribute.end(); while (curr != end) { - os << curr->first.c_str() - << "=\"" << curr->second.c_str() << "\" "; + os << curr->first.c_str() << "=\"" << curr->second.c_str() + << "\" "; curr++; } if (value.str().empty()) { os << "/>"; } else { - os << ">" << escape(value.str()).c_str() - << "</" << name.c_str() << ">"; + os << ">" << escape(value.str()).c_str() << "</" << name.c_str() + << ">"; } os.endl(os); } @@ -263,36 +256,28 @@ namespace CxxTest class XmlFormatter : public TestListener { public: - XmlFormatter( OutputStream *o, OutputStream *ostr, std::ostringstream *os) - : cpuStartTime(0), cpuStopTime(0), _o(o), _ostr(ostr), _os(os), stream_redirect(NULL) - {} - - virtual ~XmlFormatter() - { - delete _ostr; - } - - std::list<TestCaseInfo> info; - std::list<TestCaseInfo>::iterator testcase; - typedef std::list<ElementInfo>::iterator element_t; - std::string classname; - int ntests; - int nfail; - int nerror; - double totaltime; - // The type of this variable is different depending on the platform - #ifdef _WIN32 - clock_t - #else - timeval - #endif - testStartTime, testStopTime, testRunStartTime, testRunStopTime; - - /// CPU time (for all processors) - clock_t cpuStartTime, cpuStopTime; - - int run() - { + XmlFormatter(OutputStream *o, OutputStream *ostr, + std::ostringstream *os) + : cpuStartTime(0), cpuStopTime(0), _o(o), _ostr(ostr), _os(os), + stream_redirect(NULL) {} + + virtual ~XmlFormatter() { delete _ostr; } + + std::list<TestCaseInfo> info; + std::list<TestCaseInfo>::iterator testcase; + typedef std::list<ElementInfo>::iterator element_t; + std::string classname; + int ntests; + int nfail; + int nerror; + double totaltime; + std::chrono::time_point<std::chrono::high_resolution_clock> + testStartTime, testStopTime, testRunStartTime, testRunStopTime; + + /// CPU time (for all processors) + clock_t cpuStartTime, cpuStopTime; + + int run() { TestRunner::runAllTests( *this ); return tracker().failedTests(); } @@ -309,7 +294,7 @@ namespace CxxTest { char s[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; const WorldDescription &wd = tracker().world(); - o << wd.strTotalTests( s ) + o << wd.strTotalTests(s) << (wd.numTotalTests() == 1 ? " test" : " tests"); } @@ -324,7 +309,7 @@ namespace CxxTest while ( ! classname.empty() && classname[0] == '.' ) classname.erase(0,1); - //CXXTEST_STD(cout) << "HERE " << desc.file() << " " + // CXXTEST_STD(cout) << "HERE " << desc.file() << " " // << classname << CXXTEST_STD(endl); //classname=desc.suiteName(); @@ -355,23 +340,19 @@ namespace CxxTest void enterTest( const TestDescription & desc ) { - #ifdef _WIN32 - testStartTime = clock(); - #else - gettimeofday(&testStartTime, 0); - #endif - testcase = info.insert(info.end(),TestCaseInfo()); - testcase->testName = desc.testName(); - testcase->className = classname; - std::ostringstream os; - os << desc.line(); - testcase->line = os.str(); - - if ( stream_redirect ) - CXXTEST_STD(cerr) << "ERROR: The stream_redirect != NULL" - << CXXTEST_STD(endl); - - stream_redirect = + testStartTime = std::chrono::high_resolution_clock::now(); + testcase = info.insert(info.end(), TestCaseInfo()); + testcase->testName = desc.testName(); + testcase->className = classname; + std::ostringstream os; + os << desc.line(); + testcase->line = os.str(); + + if (stream_redirect) + CXXTEST_STD(cerr) + << "ERROR: The stream_redirect != NULL" << CXXTEST_STD(endl); + + stream_redirect = new TeeOutputStreams(CXXTEST_STD(cout), CXXTEST_STD(cerr)); } @@ -384,11 +365,7 @@ namespace CxxTest cpuStartTime = clock(); // Record the time now. - #ifdef _WIN32 - testRunStartTime = clock(); - #else - gettimeofday(&testRunStartTime, 0); - #endif + testRunStartTime = std::chrono::high_resolution_clock::now(); } /** Call this method after the run() call, but before tearDown() @@ -399,12 +376,7 @@ namespace CxxTest //Also CPU time. cpuStopTime = clock(); - // Record the time now. - #ifdef _WIN32 - testRunStopTime = clock(); - #else - gettimeofday(&testRunStopTime, 0); - #endif + testRunStopTime = std::chrono::high_resolution_clock::now(); } void leaveTest( const TestDescription & ) @@ -425,25 +397,20 @@ namespace CxxTest stream_redirect = NULL; } + testStopTime = std::chrono::high_resolution_clock::now(); + const std::chrono::duration<double> duration_total = + testStopTime - testStartTime; + const double testTime = duration_total.count(); - #ifdef _WIN32 - const double testTime = double(clock() - testStartTime)/CLOCKS_PER_SEC; - const double testRunTime = double(testRunStopTime - testRunStartTime)/CLOCKS_PER_SEC; - #else - gettimeofday(&testStopTime, 0); - double sec = double(testStopTime.tv_sec - testStartTime.tv_sec); - double usec = double(testStopTime.tv_usec - testStartTime.tv_usec); - double testTime = sec + (usec / 1000000.0); - - sec = double(testRunStopTime.tv_sec - testRunStartTime.tv_sec); - usec = double(testRunStopTime.tv_usec - testRunStartTime.tv_usec); - double testRunTime = sec + (usec / 1000000.0); - #endif + const std::chrono::duration<double> duration_test = + testRunStopTime - testRunStartTime; + const double testRunTime = duration_test.count(); // The CPU runtime, which on linux will be from all processors. Don't know about windows, think it's wall-clock time. - double cpuTime = double(cpuStopTime - cpuStartTime)/CLOCKS_PER_SEC; + const double cpuTime = + static_cast<double>(cpuStopTime - cpuStartTime) / CLOCKS_PER_SEC; // CPU fraction = what fraction of the CPU(s) was used. - double CPUFraction = cpuTime / testRunTime; + const double CPUFraction = cpuTime / testRunTime; // Changed: we show the run() time, EXCLUDING the setup time. // Set the run time for this test @@ -460,11 +427,10 @@ namespace CxxTest timeStream << totaltime; (*_o) << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl; (*_o) << "<testsuite name=\"" << desc.worldName() << "\" "; - (*_o) << " tests=\"" << ntests - << "\" errors=\"" << nerror - << "\" failures=\"" << nfail - << "\" package=\"" << desc.worldName() - << "\" time=\"" << timeStream.str().c_str() << "\" >"; + (*_o) << " tests=\"" << ntests << "\" errors=\"" << nerror + << "\" failures=\"" << nfail << "\" package=\"" + << desc.worldName() << "\" time=\"" + << timeStream.str().c_str() << "\" >"; _o->endl(*_o); (*_o) << _os->str().c_str(); _os->clear(); @@ -496,8 +462,8 @@ namespace CxxTest void failedAssert( const char *file, unsigned line, const char *expression ) { - testFailure( file, line, "failedAssert" ) - << "Assertion failed: " << expression; + testFailure(file, line, "failedAssert") + << "Assertion failed: " << expression; } void failedAssertEquals( const char *file, unsigned line, @@ -514,10 +480,10 @@ namespace CxxTest const char *xStr, const char *yStr, const char *sizeStr, const void* /*x*/, const void* /*y*/, unsigned size ) { - testFailure( file, line, "failedAssertSameData") - << "Error: Expected " << sizeStr - << " (" << size << ") bytes to be equal at (" - << xStr << ") and (" << yStr << "), found"; + testFailure(file, line, "failedAssertSameData") + << "Error: Expected " << sizeStr << " (" << size + << ") bytes to be equal at (" << xStr << ") and (" << yStr + << "), found"; } void failedAssertSameFiles( const char *file, unsigned line, @@ -533,21 +499,18 @@ namespace CxxTest const char *xStr, const char *yStr, const char *dStr, const char *x, const char *y, const char *d ) { - testFailure( file, line, "failedAssertDelta" ) - << "Error: Expected (" - << xStr << " == " << yStr << ") up to " << dStr - << " (" << d << "), found (" - << x << " != " << y << ")"; + testFailure(file, line, "failedAssertDelta") + << "Error: Expected (" << xStr << " == " << yStr << ") up to " + << dStr << " (" << d << "), found (" << x << " != " << y << ")"; } void failedAssertDiffers( const char *file, unsigned line, const char *xStr, const char *yStr, const char *value ) { - testFailure( file, line, "failedAssertDiffers" ) - << "Error: Expected (" - << xStr << " != " << yStr << "), found (" - << value << ")"; + testFailure(file, line, "failedAssertDiffers") + << "Error: Expected (" << xStr << " != " << yStr << "), found (" + << value << ")"; } void failedAssertLessThan( const char *file, unsigned line, @@ -574,10 +537,9 @@ namespace CxxTest const char *relation, const char *xStr, const char *yStr, const char *x, const char *y ) { - testFailure( file, line, "failedAssertRelation" ) - << "Error: Expected " << relation << "( " << - xStr << ", " << yStr << " ), found !" << relation - << "( " << x << ", " << y << " )"; + testFailure(file, line, "failedAssertRelation") + << "Error: Expected " << relation << "( " << xStr << ", " << yStr + << " ), found !" << relation << "( " << x << ", " << y << " )"; } void failedAssertPredicate( const char *file, unsigned line, @@ -592,17 +554,17 @@ namespace CxxTest const char *expression, const char *type, bool otherThrown ) { - testFailure( file, line, "failedAssertThrows" ) - << "Error: Expected (" << expression << ") to throw (" << - type << ") but it " - << (otherThrown ? "threw something else" : "didn't throw"); + testFailure(file, line, "failedAssertThrows") + << "Error: Expected (" << expression << ") to throw (" << type + << ") but it " + << (otherThrown ? "threw something else" : "didn't throw"); } void failedAssertThrowsNot( const char *file, unsigned line, const char *expression ) { - testFailure( file, line, "failedAssertThrowsNot" ) - << "Error: Expected (" << expression - << ") not to throw, but it did"; + testFailure(file, line, "failedAssertThrowsNot") + << "Error: Expected (" << expression + << ") not to throw, but it did"; } protected: @@ -684,4 +646,3 @@ namespace CxxTest // Copyright 2008 Sandia Corporation. Under the terms of Contract // DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government // retains certain rights in this software. - diff --git a/qt/widgets/common/src/DoubleSpinBox.cpp b/qt/widgets/common/src/DoubleSpinBox.cpp index 2097fcc436f4edccc923e106d881f431fe7ac29e..295e076e4bd632e05e67353d6dd19b765ef08847 100644 --- a/qt/widgets/common/src/DoubleSpinBox.cpp +++ b/qt/widgets/common/src/DoubleSpinBox.cpp @@ -29,11 +29,11 @@ #include "MantidQtWidgets/Common/DoubleSpinBox.h" //#include <MyParser.h> -#include <QLineEdit> -#include <QHBoxLayout> #include <QCloseEvent> -#include <float.h> -#include <math.h> +#include <QHBoxLayout> +#include <QLineEdit> +#include <cfloat> +#include <cmath> DoubleSpinBox::DoubleSpinBox(const char format, QWidget *parent) : QAbstractSpinBox(parent), d_format(format), d_min_val(-DBL_MAX), diff --git a/qt/widgets/common/src/MantidWSIndexDialog.cpp b/qt/widgets/common/src/MantidWSIndexDialog.cpp index 194f357a1de49ee82dc90f28f76091ed871580a5..b79171e12acf4067735238ed926afc474ec4b614 100644 --- a/qt/widgets/common/src/MantidWSIndexDialog.cpp +++ b/qt/widgets/common/src/MantidWSIndexDialog.cpp @@ -5,14 +5,14 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectraDetectorTypes.h" +#include <QMessageBox> #include <QPalette> #include <QPushButton> #include <QRegExp> #include <QtAlgorithms> -#include <QMessageBox> #include <boost/lexical_cast.hpp> +#include <cstdlib> #include <exception> -#include <stdlib.h> namespace MantidQt { namespace MantidWidgets { diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp index 2a75e80b62be0273307388dd35dc341be44b1653..2094dd957531f0af304b2f774424343239a6cccc 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp @@ -100,9 +100,9 @@ #include <QtGui/QPainter> #include <QtGui/QLabel> -#include <limits.h> -#include <float.h> -#include <math.h> +#include <cfloat> +#include <climits> +#include <cmath> #if defined(Q_CC_MSVC) #pragma warning( \ diff --git a/qt/widgets/common/src/QwtRasterDataMD.cpp b/qt/widgets/common/src/QwtRasterDataMD.cpp index be2a543997ba009b66d2b7714163fcc75c9c6173..c2bc620f81eee05fb974863e50da378c8a7058dc 100644 --- a/qt/widgets/common/src/QwtRasterDataMD.cpp +++ b/qt/widgets/common/src/QwtRasterDataMD.cpp @@ -1,9 +1,9 @@ #include "MantidQtWidgets/Common/QwtRasterDataMD.h" -#include <math.h> -#include "MantidGeometry/MDGeometry/MDTypes.h" -#include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidAPI/IMDWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidGeometry/MDGeometry/MDTypes.h" +#include <cmath> namespace MantidQt { namespace API { diff --git a/qt/widgets/common/src/ScaleEngine.cpp b/qt/widgets/common/src/ScaleEngine.cpp index 88c3b993c06504c9bd6ece21b57d66c769a08335..796cec888288926efb00a05a8e760971c201849e 100644 --- a/qt/widgets/common/src/ScaleEngine.cpp +++ b/qt/widgets/common/src/ScaleEngine.cpp @@ -30,7 +30,7 @@ #include "MantidQtWidgets/Common/ScaleEngine.h" #include "MantidQtWidgets/Common/PowerScaleEngine.h" #include "MantidQtWidgets/Common/qwt_compat.h" -#include <limits.h> +#include <climits> QwtScaleTransformation *ScaleEngine::transformation() const { return new ScaleTransformation(this); diff --git a/qt/widgets/common/src/SlitCalculator.cpp b/qt/widgets/common/src/SlitCalculator.cpp index 7a082649280610d4568bd4ebab87912870bfe1f8..fe50a063f6dc3851c8b15d7dc138c02e018d6fc8 100644 --- a/qt/widgets/common/src/SlitCalculator.cpp +++ b/qt/widgets/common/src/SlitCalculator.cpp @@ -5,7 +5,7 @@ #include "MantidKernel/Strings.h" #include "MantidGeometry/Instrument/InstrumentDefinitionParser.h" -#include <math.h> +#include <cmath> namespace MantidQt { namespace MantidWidgets { diff --git a/qt/widgets/instrumentview/src/GLActorCollection.cpp b/qt/widgets/instrumentview/src/GLActorCollection.cpp index 66af3b7a0537d77fb5fd59d329764ca29dc40201..1951e41685315208ad0d190654c742a7db06fe5d 100644 --- a/qt/widgets/instrumentview/src/GLActorCollection.cpp +++ b/qt/widgets/instrumentview/src/GLActorCollection.cpp @@ -4,10 +4,10 @@ #include "MantidKernel/Exception.h" -#include <stdexcept> -#include <functional> #include <algorithm> -#include <float.h> +#include <cfloat> +#include <functional> +#include <stdexcept> namespace MantidQt { namespace MantidWidgets { diff --git a/qt/widgets/instrumentview/src/Viewport.cpp b/qt/widgets/instrumentview/src/Viewport.cpp index 9ad7f352cbcb4a1c9413da66094b912de4b1d743..93ab20a277c9a029a939e1dd7beca4b426d92621 100644 --- a/qt/widgets/instrumentview/src/Viewport.cpp +++ b/qt/widgets/instrumentview/src/Viewport.cpp @@ -1,9 +1,9 @@ #include "MantidQtWidgets/InstrumentView/Viewport.h" -#include "MantidQtWidgets/Common/TSVSerialiser.h" -#include <math.h> #include "MantidGeometry/Rendering/OpenGL_Headers.h" #include "MantidKernel/V3D.h" +#include "MantidQtWidgets/Common/TSVSerialiser.h" #include "MantidQtWidgets/InstrumentView/OpenGLError.h" +#include <cmath> #include <limits> namespace MantidQt { diff --git a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp index fae7f35bb3f122619837b2d17a6af968b11d9f4d..e24c41590bb93e407a2a080f554d0af804f956fb 100644 --- a/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/ArrayDataSource.cpp @@ -1,5 +1,5 @@ -#include <math.h> +#include <cmath> #include "MantidQtWidgets/SpectrumViewer/ArrayDataSource.h" #include "MantidQtWidgets/SpectrumViewer/SVUtils.h" diff --git a/qt/widgets/spectrumviewer/src/ColorMaps.cpp b/qt/widgets/spectrumviewer/src/ColorMaps.cpp index 3fcfbce33a124ba691f0903eca242ddf0ebcdeba..ccfd75d87c68e44843e69ef322ef01de78f2f3c4 100644 --- a/qt/widgets/spectrumviewer/src/ColorMaps.cpp +++ b/qt/widgets/spectrumviewer/src/ColorMaps.cpp @@ -1,6 +1,6 @@ +#include <cmath> #include <sstream> -#include <math.h> #include "MantidQtWidgets/SpectrumViewer/ColorMaps.h" diff --git a/qt/widgets/spectrumviewer/src/DataArray.cpp b/qt/widgets/spectrumviewer/src/DataArray.cpp index 4b881a6fe72bba110e6d8e9976860f211577c8b1..b7b05ba3dff3f363b60da8ed81d62cb2ee0f8b46 100644 --- a/qt/widgets/spectrumviewer/src/DataArray.cpp +++ b/qt/widgets/spectrumviewer/src/DataArray.cpp @@ -2,7 +2,7 @@ * File DataArray.cpp */ -#include <math.h> +#include <cmath> #include "MantidQtWidgets/SpectrumViewer/DataArray.h" diff --git a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp index 2995c3739febaab055a2abbc9370e953f250a208..4d0e5264d9060aeac4df4362706354312820c44f 100644 --- a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp @@ -3,8 +3,8 @@ */ #include <boost/lexical_cast.hpp> +#include <cmath> #include <sstream> -#include <math.h> #include <QThread> diff --git a/qt/widgets/spectrumviewer/src/SVUtils.cpp b/qt/widgets/spectrumviewer/src/SVUtils.cpp index 83dd8a152bc30fd519814f3111418c884de5bcc8..bca8c23394b3dc4a569bdcdd9f5a052a2b0d61a8 100644 --- a/qt/widgets/spectrumviewer/src/SVUtils.cpp +++ b/qt/widgets/spectrumviewer/src/SVUtils.cpp @@ -1,6 +1,6 @@ +#include <cmath> #include <iostream> #include <sstream> -#include <math.h> #include "MantidQtWidgets/SpectrumViewer/SVUtils.h" diff --git a/qt/widgets/spectrumviewer/src/SpectrumDataSource.cpp b/qt/widgets/spectrumviewer/src/SpectrumDataSource.cpp index f447cd72ab4b19b3e9e7c7a546ecf337051b1003..a97845c5e71d5c484d704865bfd6fe6450364306 100644 --- a/qt/widgets/spectrumviewer/src/SpectrumDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/SpectrumDataSource.cpp @@ -1,5 +1,5 @@ -#include <math.h> +#include <cmath> #include "MantidQtWidgets/SpectrumViewer/SpectrumDataSource.h"