Commit 070d1bc7 authored by snuverink_j's avatar snuverink_j
Browse files

template NumToStr

parent 8f0a66f9
......@@ -1106,7 +1106,6 @@ src/Track/TrackSave.h -text
src/Track/TrackStart.cpp -text
src/Track/TrackStart.h -text
src/Utilities/CMakeLists.txt -text
src/Utilities/NumToStr.cpp -text
src/Utilities/NumToStr.h -text
src/Utilities/OpalException.cpp -text
src/Utilities/OpalException.h -text
......@@ -1148,7 +1147,7 @@ src/opal.h -text
tests/CMakeLists.txt -text
tests/Main.cpp -text
tests/classic_src/CMakeLists.txt -text
tests/classic_src/AbsBeamline//CMakeLists.txt -text
tests/classic_src/AbsBeamline/CMakeLists.txt -text
tests/classic_src/AbsBeamline/OffsetTest.cpp -text
tests/classic_src/AbsBeamline/RingTest.cpp -text
tests/classic_src/AbsBeamline/SBend3DTest.cpp -text
......
......@@ -73,7 +73,6 @@
#include "Physics/Physics.h"
#include "Utilities/NumToStr.h"
#include "Utilities/OpalException.h"
#include "BasicActions/DumpFields.h"
......@@ -333,8 +332,7 @@ void ParallelCyclotronTracker::visitRing(const Ring &ring) {
*gmsg << "* ----------------------------- Adding Ring ------------------------------ *" << endl;
if (opalRing_m != NULL)
delete opalRing_m;
delete opalRing_m;
opalRing_m = dynamic_cast<Ring*>(ring.clone());
......
......@@ -676,7 +676,7 @@ namespace {
zt = ::implicitIntStep(zt, f, gradf, ya * dsc, nx);
} catch(ConvergenceError &cnverr) {
if(++ci > cx) {
std::string msg = "Convergence not achieved within " + NumToStr(cx) + " cuts of step-size!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(cx) + " cuts of step-size!";
throw ConvergenceError("ThickMapper::implicitInt4()", msg);
}
//std::cerr << " cutting step size in half" << std::endl;
......@@ -720,7 +720,7 @@ namespace {
int ni = 0;
while(bcount < PSdim) {
if(ni == nx) {
std::string msg = "Convergence not achieved within " + NumToStr(nx) + " iterations!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(nx) + " iterations!";
throw ConvergenceError("ThickMapper::implicitIntStep()", msg);
}
......
......@@ -36,7 +36,7 @@
#include "FixedAlgebra/FVps.h"
#include "Physics/Physics.h"
#include "Utilities/NumToStr.h"
//#include "Utilities/NumToStr.h"
#include "Elements/OpalBeamline.h"
class Beamline;
......@@ -495,7 +495,7 @@ namespace {
zt = ::implicitIntStep(zt, f, gradf, ya * dsc, nx);
} catch(ConvergenceError &cnverr) {
if(++ci > cx) {
std::string msg = "Convergence not achieved within " + NumToStr(cx) + " cuts of step-size!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(cx) + " cuts of step-size!";
throw ConvergenceError("ThickTracker::implicitInt4()", msg);
}
if(!cnvWarn) {
......@@ -546,7 +546,7 @@ namespace {
int ni = 0;
while(bcount < PSdim) {
if(ni == nx) {
std::string msg = "Convergence not achieved within " + NumToStr(nx) + " iterations!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(nx) + " iterations!";
throw ConvergenceError("ThickTracker::implicitIntStep()", msg);
}
......@@ -610,7 +610,7 @@ namespace {
int ni = 0;
while(bcount < PSdim) {
if(ni == nx) {
std::string msg = "Convergence not achieved within " + NumToStr(nx) + " iterations!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(nx) + " iterations!";
throw ConvergenceError("ThickTracker::fixedPointInt2()", msg);
}
......@@ -669,7 +669,7 @@ namespace {
zt = ::fixedPointInt2(zt, f, ya * dsc, nx);
} catch(ConvergenceError &cnverr) {
if(++ci > cx) {
std::string msg = "Convergence not achieved within " + NumToStr(cx) + " cuts of step-size!";
std::string msg = "Convergence not achieved within " + NumToStr<int>(cx) + " cuts of step-size!";
throw ConvergenceError("ThickTracker::fixedPointInt4()", msg);
}
if(!cnvWarn) {
......
set (_SRCS
NumToStr.cpp
OpalException.cpp
OpalFilter.cpp
OpalSection.cpp
......
// ------------------------------------------------------------------------
// $RCSfile: NumToStr.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.2.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Functions: std::string NumToStr(short)
// std::string NumToStr(unsigned short)
// std::string NumToStr(int)
// std::string NumToStr(unsigned int)
// std::string NumToStr(long)
// std::string NumToStr(unsigned long)
// std::string NumToStr(float)
// std::string NumToStr(double)
// std::string NumToStr(long double)
// Convert number to string.
//
// ------------------------------------------------------------------------
//
// $Date: 2004/11/12 20:10:12 $
// $Author: adelmann $
//
// ------------------------------------------------------------------------
#include "Utilities/NumToStr.h"
std::string NumToStr(short s) {
std::ostringstream oss;
oss << s;
return oss.str();
}
std::string NumToStr(unsigned short s) {
std::ostringstream oss;
oss << s;
return oss.str();
}
std::string NumToStr(int i) {
std::ostringstream oss;
oss << i;
return oss.str();
}
std::string NumToStr(unsigned int i) {
std::ostringstream oss;
oss << i;
return oss.str();
}
std::string NumToStr(long l) {
std::ostringstream oss;
oss << l;
return oss.str();
}
std::string NumToStr(unsigned long l) {
std::ostringstream oss;
oss << l;
return oss.str();
}
std::string NumToStr(float f) {
std::ostringstream oss;
oss << f;
return oss.str();
}
std::string NumToStr(double d) {
std::ostringstream oss;
oss << d;
return oss.str();
}
std::string NumToStr(long double d) {
std::ostringstream oss;
oss << d;
return oss.str();
}
......@@ -9,16 +9,6 @@
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Functions: string NumToStr(short)
// string NumToStr(unsigned short)
// string NumToStr(int)
// string NumToStr(unsigned int)
// string NumToStr(long)
// string NumToStr(unsigned long)
// string NumToStr(float)
// string NumToStr(double)
// string NumToStr(long double)
//
// ------------------------------------------------------------------------
//
// $Date: 2004/11/12 20:10:12 $
......@@ -27,27 +17,16 @@
// ------------------------------------------------------------------------
#include <sstream>
#include <string>
/// Convert number to string.
// Return the string corresponding to the numeric argument.
std::string NumToStr(short s);
std::string NumToStr(unsigned short s);
std::string NumToStr(int i);
std::string NumToStr(unsigned int i);
std::string NumToStr(long l);
std::string NumToStr(unsigned long l);
std::string NumToStr(float f);
std::string NumToStr(double d);
std::string NumToStr(long double d);
template <typename T>
std::string NumToStr(T t) {
std::ostringstream oss;
oss << t;
return oss.str();
}
#endif // OPAL_NumToStr_HH
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