diff --git a/library/Demos/LibUtilities/ErrorStream.cpp b/library/Demos/LibUtilities/ErrorStream.cpp index cd532652bec009719d65e32b3725c5ba3c9cda9a..b36bc2874c6f5075c6e46487c236a9d802d34309 100644 --- a/library/Demos/LibUtilities/ErrorStream.cpp +++ b/library/Demos/LibUtilities/ErrorStream.cpp @@ -55,16 +55,9 @@ int main(int argc, char *argv[]) // with missing file. try { - std::vector arguments = {"ErrorStream", "missing.xml"}; - std::vector argv; - for (const auto& arg : arguments) - { - argv.push_back((char*)arg.data()); - } - argv.push_back(nullptr); - + char const *fake_argv[2] = {"ErrorStream", "missing.xml"}; LibUtilities::SessionReaderSharedPtr session = - LibUtilities::SessionReader::CreateInstance(2, &argv[0]); + LibUtilities::SessionReader::CreateInstance(2, &fake_argv[0]); session->InitSession(); } catch (const ErrorUtil::NekError &e) diff --git a/library/LibUtilities/BasicUtils/ErrorUtil.hpp b/library/LibUtilities/BasicUtils/ErrorUtil.hpp index 45fabe0684089d5663fc67ecc6f3b77f5a171476..98232ee67ee7712235e3e19ecd685b92724ca472 100644 --- a/library/LibUtilities/BasicUtils/ErrorUtil.hpp +++ b/library/LibUtilities/BasicUtils/ErrorUtil.hpp @@ -52,8 +52,9 @@ namespace Nektar { -struct ErrorUtil +class ErrorUtil { +public: class NekError : public std::runtime_error { public: @@ -75,7 +76,7 @@ struct ErrorUtil inline static bool HasCustomErrorStream() { - return m_outStream == &std::cerr; + return m_outStream != &std::cerr; } inline static void Error(ErrType type, @@ -94,7 +95,7 @@ struct ErrorUtil " assertion violation\n"; #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) baseMsg += "Where : " + std::string(routine) + "[" + - std::to_string(lineNumber) + "]\n"; + std::to_string(lineNumber) + "]\n Message : "; #endif baseMsg += std::string(msg); diff --git a/library/LibUtilities/BasicUtils/NekFactory.hpp b/library/LibUtilities/BasicUtils/NekFactory.hpp index 88b4fb00fc35f449d24c2ebd793f5edb9fce8264..c24fb103481d4553d63aa49a476f9c0b5f578856 100644 --- a/library/LibUtilities/BasicUtils/NekFactory.hpp +++ b/library/LibUtilities/BasicUtils/NekFactory.hpp @@ -104,8 +104,6 @@ template tPredicator; /// Shared pointer to an object of baseclass type. @@ -117,7 +115,7 @@ public: /// Define a struct to hold the information about a module. struct ModuleEntry { - ModuleEntry(CreatorFunction pFunc, const tDescription pDesc) + ModuleEntry(CreatorFunction pFunc, const std::string pDesc) : m_func(pFunc), m_desc(pDesc) { @@ -126,7 +124,7 @@ public: /// Function used to create instance of class. CreatorFunction m_func; /// Description of class for use in listing available classes. - tDescription m_desc; + std::string m_desc; }; /// Factory map between key and module data. @@ -200,7 +198,7 @@ public: * @returns The given key \c idKey. */ tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, - tDescription pDesc = "") + std::string pDesc = "") { #ifdef NEKTAR_USE_THREAD_SAFETY WriteLock vWriteLock(m_mutex); @@ -261,7 +259,7 @@ public: /** * @brief Retrieves a key, given a description */ - tKey GetKey(tDescription pDesc) + tKey GetKey(std::string pDesc) { #ifdef NEKTAR_USE_THREAD_SAFETY ReadLock vReadLock(m_mutex); diff --git a/library/MultiRegions/SubStructuredGraph.cpp b/library/MultiRegions/SubStructuredGraph.cpp index ecd4d01e2cc2a6ae07f49ab7fd67c0c8e8917471..8b0539460c891dbc49ac559424ea3df8180eff45 100644 --- a/library/MultiRegions/SubStructuredGraph.cpp +++ b/library/MultiRegions/SubStructuredGraph.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -838,7 +837,7 @@ namespace Nektar boost::replace_all(strat_str, "", "0.1"); boost::replace_all( strat_str, "", - "vert>"+boost::lexical_cast(mdswitch)); + "vert>"+std::to_string(mdswitch)); // Set up the re-ordering strategy. SCOTCH_Strat strat; @@ -931,7 +930,7 @@ namespace Nektar for (i = 0; i < nGraphVerts; ++i) { ASSERTL1(perm[iperm[i]] == i, "Perm error " - + boost::lexical_cast(i)); + + std::to_string(i)); } // If we were passed a graph with disconnected regions, we need diff --git a/library/NekMeshUtils/CADSystem/OCE/CADSurfOCE.cpp b/library/NekMeshUtils/CADSystem/OCE/CADSurfOCE.cpp index cac1895e29485fcdf21b01946f58bca5de0dc8d7..8b51b44a0294db6bba2cc1abea91acf5e6df00b7 100644 --- a/library/NekMeshUtils/CADSystem/OCE/CADSurfOCE.cpp +++ b/library/NekMeshUtils/CADSystem/OCE/CADSurfOCE.cpp @@ -34,7 +34,6 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include using namespace std; diff --git a/library/NekMeshUtils/CADSystem/OCE/CADSystemOCE.cpp b/library/NekMeshUtils/CADSystem/OCE/CADSystemOCE.cpp index d4630c56f7f44871ae0e4cf4cc3173205424474f..e851119d2ca70d77cc1d7114c42d93525c65d0c0 100644 --- a/library/NekMeshUtils/CADSystem/OCE/CADSystemOCE.cpp +++ b/library/NekMeshUtils/CADSystem/OCE/CADSystemOCE.cpp @@ -43,7 +43,6 @@ #include #include -#include using namespace std; @@ -418,7 +417,7 @@ TopoDS_Shape CADSystemOCE::BuildNACA(string naca) ParseUtils::GenerateVector(m_naca, data); ASSERTL0(data.size() == 5, "not a vaild domain"); - int n = boost::lexical_cast(naca); + int n = std::stoi(naca); NekDouble T = (n % 100) / 100.0; n /= 100; NekDouble P = (n % 10) / 10.0; @@ -577,7 +576,7 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo) string type = tmp2[0]; boost::erase_all(tmp2[1], ")"); boost::erase_all(tmp2[1], " "); - int id = boost::lexical_cast(tmp2[1]); + int id = std::stoi(tmp2[1]); boost::erase_all(tmp1[1], " "); boost::erase_all(tmp1[1], "{"); diff --git a/tests/Metric.h b/tests/Metric.h index 4f46a11c8fb8607ab692823af31201f4cf13e84a..f184d13e04292b805f8b67e562a33988f06d3ff8 100644 --- a/tests/Metric.h +++ b/tests/Metric.h @@ -40,15 +40,8 @@ #include #include #include -#include -struct TesterException : public std::runtime_error -{ - TesterException(const std::string &msg) : std::runtime_error(msg) {} -}; - -#define ASSERTL0(condition, msg) \ - if (!(condition)) { throw TesterException(msg); } +#include namespace fs = boost::filesystem; @@ -56,7 +49,6 @@ std::string PortablePath(const boost::filesystem::path& path); namespace Nektar { - /** * @brief Check to see whether the given string @p s is empty (or null). */ @@ -88,7 +80,7 @@ namespace Nektar { return m_id; } - + protected: /// Stores the ID of this metric. int m_id; @@ -110,8 +102,9 @@ namespace Nektar /// Datatype of the NekFactory used to instantiate classes derived from the /// Advection class. - struct MetricFactory + class MetricFactory { + public: typedef MetricSharedPtr (*CreatorFunction)(TiXmlElement *, bool); std::string RegisterCreatorFunction(std::string key, CreatorFunction func) @@ -133,5 +126,4 @@ namespace Nektar MetricFactory& GetMetricFactory(); } - #endif diff --git a/tests/TestData.cpp b/tests/TestData.cpp index 73fd99323e09a75b8aae1c8fa44962703c50bdd3..29ddb01b04373dcc72333b45dc56a0064be3eedc 100644 --- a/tests/TestData.cpp +++ b/tests/TestData.cpp @@ -37,8 +37,7 @@ #include #include - -#define ASSERTL0(condition,msg) +#include using namespace std; diff --git a/tests/TestException.hpp b/tests/TestException.hpp new file mode 100644 index 0000000000000000000000000000000000000000..92f35546394d32d795e8906ccd9d596e6dfe5199 --- /dev/null +++ b/tests/TestException.hpp @@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// File: Metric.h +// +// For more information, please see: http://www.nektar.info +// +// The MIT License +// +// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA), +// Department of Aeronautics, Imperial College London (UK), and Scientific +// Computing and Imaging Institute, University of Utah (USA). +// +// License for the specific language governing rights and limitations under +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// Description: Definition of the metric base class. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef NEKTAR_TESTS_TESTEXCEPTION_H +#define NEKTAR_TESTS_TESTEXCEPTION_H + +#include + +namespace Nektar +{ + +/** + * @brief Subclass of std::runtime_error to handle exceptions raised by Tester. + */ +struct TesterException : public std::runtime_error +{ + TesterException(const std::string &msg) : std::runtime_error(msg) + { + } +}; + +#define ASSERTL0(condition, msg) \ + if (!(condition)) { throw TesterException(msg); } + +} + +#endif