Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
src
Commits
070d1bc7
Commit
070d1bc7
authored
Jan 19, 2018
by
snuverink_j
Browse files
template NumToStr
parent
8f0a66f9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
124 deletions
+16
-124
.gitattributes
.gitattributes
+1
-2
src/Algorithms/ParallelCyclotronTracker.cpp
src/Algorithms/ParallelCyclotronTracker.cpp
+1
-3
src/Algorithms/ThickMapper.cpp
src/Algorithms/ThickMapper.cpp
+2
-2
src/Algorithms/ThickTracker.cpp
src/Algorithms/ThickTracker.cpp
+5
-5
src/Utilities/CMakeLists.txt
src/Utilities/CMakeLists.txt
+0
-1
src/Utilities/NumToStr.cpp
src/Utilities/NumToStr.cpp
+0
-83
src/Utilities/NumToStr.h
src/Utilities/NumToStr.h
+7
-28
No files found.
.gitattributes
View file @
070d1bc7
...
...
@@ -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
...
...
src/Algorithms/ParallelCyclotronTracker.cpp
View file @
070d1bc7
...
...
@@ -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
());
...
...
src/Algorithms/ThickMapper.cpp
View file @
070d1bc7
...
...
@@ -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
);
}
...
...
src/Algorithms/ThickTracker.cpp
View file @
070d1bc7
...
...
@@ -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) {
...
...
src/Utilities/CMakeLists.txt
View file @
070d1bc7
set
(
_SRCS
NumToStr.cpp
OpalException.cpp
OpalFilter.cpp
OpalSection.cpp
...
...
src/Utilities/NumToStr.cpp
deleted
100644 → 0
View file @
8f0a66f9
// ------------------------------------------------------------------------
// $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
();
}
src/Utilities/NumToStr.h
View file @
070d1bc7
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment