Commit 39029706 authored by David Moxey's avatar David Moxey

Update for Chris' comments

parent 3e3f1e50
...@@ -55,16 +55,9 @@ int main(int argc, char *argv[]) ...@@ -55,16 +55,9 @@ int main(int argc, char *argv[])
// with missing file. // with missing file.
try try
{ {
std::vector<std::string> arguments = {"ErrorStream", "missing.xml"}; char const *fake_argv[2] = {"ErrorStream", "missing.xml"};
std::vector<char*> argv;
for (const auto& arg : arguments)
{
argv.push_back((char*)arg.data());
}
argv.push_back(nullptr);
LibUtilities::SessionReaderSharedPtr session = LibUtilities::SessionReaderSharedPtr session =
LibUtilities::SessionReader::CreateInstance(2, &argv[0]); LibUtilities::SessionReader::CreateInstance(2, &fake_argv[0]);
session->InitSession(); session->InitSession();
} }
catch (const ErrorUtil::NekError &e) catch (const ErrorUtil::NekError &e)
......
...@@ -52,8 +52,9 @@ ...@@ -52,8 +52,9 @@
namespace Nektar namespace Nektar
{ {
struct ErrorUtil class ErrorUtil
{ {
public:
class NekError : public std::runtime_error class NekError : public std::runtime_error
{ {
public: public:
...@@ -75,7 +76,7 @@ struct ErrorUtil ...@@ -75,7 +76,7 @@ struct ErrorUtil
inline static bool HasCustomErrorStream() inline static bool HasCustomErrorStream()
{ {
return m_outStream == &std::cerr; return m_outStream != &std::cerr;
} }
inline static void Error(ErrType type, inline static void Error(ErrType type,
...@@ -94,7 +95,7 @@ struct ErrorUtil ...@@ -94,7 +95,7 @@ struct ErrorUtil
" assertion violation\n"; " assertion violation\n";
#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
baseMsg += "Where : " + std::string(routine) + "[" + baseMsg += "Where : " + std::string(routine) + "[" +
std::to_string(lineNumber) + "]\n"; std::to_string(lineNumber) + "]\n Message : ";
#endif #endif
baseMsg += std::string(msg); baseMsg += std::string(msg);
......
...@@ -104,8 +104,6 @@ template <typename tKey, // reference tag (e.g. string, int) ...@@ -104,8 +104,6 @@ template <typename tKey, // reference tag (e.g. string, int)
class NekFactory class NekFactory
{ {
public: public:
/// Description datatype
typedef std::string tDescription;
/// Comparison predicator of key /// Comparison predicator of key
typedef std::less<tKey> tPredicator; typedef std::less<tKey> tPredicator;
/// Shared pointer to an object of baseclass type. /// Shared pointer to an object of baseclass type.
...@@ -117,7 +115,7 @@ public: ...@@ -117,7 +115,7 @@ public:
/// Define a struct to hold the information about a module. /// Define a struct to hold the information about a module.
struct ModuleEntry struct ModuleEntry
{ {
ModuleEntry(CreatorFunction pFunc, const tDescription pDesc) ModuleEntry(CreatorFunction pFunc, const std::string pDesc)
: m_func(pFunc), : m_func(pFunc),
m_desc(pDesc) m_desc(pDesc)
{ {
...@@ -126,7 +124,7 @@ public: ...@@ -126,7 +124,7 @@ public:
/// Function used to create instance of class. /// Function used to create instance of class.
CreatorFunction m_func; CreatorFunction m_func;
/// Description of class for use in listing available classes. /// Description of class for use in listing available classes.
tDescription m_desc; std::string m_desc;
}; };
/// Factory map between key and module data. /// Factory map between key and module data.
...@@ -200,7 +198,7 @@ public: ...@@ -200,7 +198,7 @@ public:
* @returns The given key \c idKey. * @returns The given key \c idKey.
*/ */
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator,
tDescription pDesc = "") std::string pDesc = "")
{ {
#ifdef NEKTAR_USE_THREAD_SAFETY #ifdef NEKTAR_USE_THREAD_SAFETY
WriteLock vWriteLock(m_mutex); WriteLock vWriteLock(m_mutex);
...@@ -261,7 +259,7 @@ public: ...@@ -261,7 +259,7 @@ public:
/** /**
* @brief Retrieves a key, given a description * @brief Retrieves a key, given a description
*/ */
tKey GetKey(tDescription pDesc) tKey GetKey(std::string pDesc)
{ {
#ifdef NEKTAR_USE_THREAD_SAFETY #ifdef NEKTAR_USE_THREAD_SAFETY
ReadLock vReadLock(m_mutex); ReadLock vReadLock(m_mutex);
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <algorithm> #include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_list.hpp>
#include <boost/graph/cuthill_mckee_ordering.hpp> #include <boost/graph/cuthill_mckee_ordering.hpp>
...@@ -838,7 +837,7 @@ namespace Nektar ...@@ -838,7 +837,7 @@ namespace Nektar
boost::replace_all(strat_str, "<BBAL>", "0.1"); boost::replace_all(strat_str, "<BBAL>", "0.1");
boost::replace_all( boost::replace_all(
strat_str, "<TSTS>", strat_str, "<TSTS>",
"vert>"+boost::lexical_cast<std::string>(mdswitch)); "vert>"+std::to_string(mdswitch));
// Set up the re-ordering strategy. // Set up the re-ordering strategy.
SCOTCH_Strat strat; SCOTCH_Strat strat;
...@@ -931,7 +930,7 @@ namespace Nektar ...@@ -931,7 +930,7 @@ namespace Nektar
for (i = 0; i < nGraphVerts; ++i) for (i = 0; i < nGraphVerts; ++i)
{ {
ASSERTL1(perm[iperm[i]] == i, "Perm error " ASSERTL1(perm[iperm[i]] == i, "Perm error "
+ boost::lexical_cast<std::string>(i)); + std::to_string(i));
} }
// If we were passed a graph with disconnected regions, we need // If we were passed a graph with disconnected regions, we need
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/CADSystem/OCE/CADSurfOCE.h> #include <NekMeshUtils/CADSystem/OCE/CADSurfOCE.h>
#include <boost/lexical_cast.hpp>
using namespace std; using namespace std;
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
using namespace std; using namespace std;
...@@ -418,7 +417,7 @@ TopoDS_Shape CADSystemOCE::BuildNACA(string naca) ...@@ -418,7 +417,7 @@ TopoDS_Shape CADSystemOCE::BuildNACA(string naca)
ParseUtils::GenerateVector(m_naca, data); ParseUtils::GenerateVector(m_naca, data);
ASSERTL0(data.size() == 5, "not a vaild domain"); ASSERTL0(data.size() == 5, "not a vaild domain");
int n = boost::lexical_cast<int>(naca); int n = std::stoi(naca);
NekDouble T = (n % 100) / 100.0; NekDouble T = (n % 100) / 100.0;
n /= 100; n /= 100;
NekDouble P = (n % 10) / 10.0; NekDouble P = (n % 10) / 10.0;
...@@ -577,7 +576,7 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo) ...@@ -577,7 +576,7 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
string type = tmp2[0]; string type = tmp2[0];
boost::erase_all(tmp2[1], ")"); boost::erase_all(tmp2[1], ")");
boost::erase_all(tmp2[1], " "); boost::erase_all(tmp2[1], " ");
int id = boost::lexical_cast<int>(tmp2[1]); int id = std::stoi(tmp2[1]);
boost::erase_all(tmp1[1], " "); boost::erase_all(tmp1[1], " ");
boost::erase_all(tmp1[1], "{"); boost::erase_all(tmp1[1], "{");
......
...@@ -40,15 +40,8 @@ ...@@ -40,15 +40,8 @@
#include <string> #include <string>
#include <map> #include <map>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <exception>
struct TesterException : public std::runtime_error #include <TestException.hpp>
{
TesterException(const std::string &msg) : std::runtime_error(msg) {}
};
#define ASSERTL0(condition, msg) \
if (!(condition)) { throw TesterException(msg); }
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
...@@ -56,7 +49,6 @@ std::string PortablePath(const boost::filesystem::path& path); ...@@ -56,7 +49,6 @@ std::string PortablePath(const boost::filesystem::path& path);
namespace Nektar namespace Nektar
{ {
/** /**
* @brief Check to see whether the given string @p s is empty (or null). * @brief Check to see whether the given string @p s is empty (or null).
*/ */
...@@ -88,7 +80,7 @@ namespace Nektar ...@@ -88,7 +80,7 @@ namespace Nektar
{ {
return m_id; return m_id;
} }
protected: protected:
/// Stores the ID of this metric. /// Stores the ID of this metric.
int m_id; int m_id;
...@@ -110,8 +102,9 @@ namespace Nektar ...@@ -110,8 +102,9 @@ namespace Nektar
/// Datatype of the NekFactory used to instantiate classes derived from the /// Datatype of the NekFactory used to instantiate classes derived from the
/// Advection class. /// Advection class.
struct MetricFactory class MetricFactory
{ {
public:
typedef MetricSharedPtr (*CreatorFunction)(TiXmlElement *, bool); typedef MetricSharedPtr (*CreatorFunction)(TiXmlElement *, bool);
std::string RegisterCreatorFunction(std::string key, CreatorFunction func) std::string RegisterCreatorFunction(std::string key, CreatorFunction func)
...@@ -133,5 +126,4 @@ namespace Nektar ...@@ -133,5 +126,4 @@ namespace Nektar
MetricFactory& GetMetricFactory(); MetricFactory& GetMetricFactory();
} }
#endif #endif
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <TestData.h> #include <TestData.h>
#include <TestException.hpp>
#define ASSERTL0(condition,msg)
using namespace std; using namespace std;
......
///////////////////////////////////////////////////////////////////////////////
//
// 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 <exception>
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment