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[])
// with missing file.
try
{
std::vector<std::string> arguments = {"ErrorStream", "missing.xml"};
std::vector<char*> 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)
......
......@@ -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);
......
......@@ -104,8 +104,6 @@ template <typename tKey, // reference tag (e.g. string, int)
class NekFactory
{
public:
/// Description datatype
typedef std::string tDescription;
/// Comparison predicator of key
typedef std::less<tKey> 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);
......
......@@ -40,7 +40,6 @@
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/cuthill_mckee_ordering.hpp>
......@@ -838,7 +837,7 @@ namespace Nektar
boost::replace_all(strat_str, "<BBAL>", "0.1");
boost::replace_all(
strat_str, "<TSTS>",
"vert>"+boost::lexical_cast<std::string>(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<std::string>(i));
+ std::to_string(i));
}
// If we were passed a graph with disconnected regions, we need
......
......@@ -34,7 +34,6 @@
////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/CADSystem/OCE/CADSurfOCE.h>
#include <boost/lexical_cast.hpp>
using namespace std;
......
......@@ -43,7 +43,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
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<int>(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<int>(tmp2[1]);
int id = std::stoi(tmp2[1]);
boost::erase_all(tmp1[1], " ");
boost::erase_all(tmp1[1], "{");
......
......@@ -40,15 +40,8 @@
#include <string>
#include <map>
#include <boost/filesystem.hpp>
#include <exception>
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 <TestException.hpp>
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
......@@ -37,8 +37,7 @@
#include <boost/algorithm/string.hpp>
#include <TestData.h>
#define ASSERTL0(condition,msg)
#include <TestException.hpp>
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