ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
FillFromStringUtility.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
3
/*
4
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#ifndef FillFromStringUtility_h
8
#define FillFromStringUtility_h
9
10
// Include STL stuff
11
#include <limits>
12
#include <string>
13
14
// Include boost stuff
15
#include "boost/tokenizer.hpp"
16
#include "boost/lexical_cast.hpp"
17
18
namespace
{
19
template
<
typename
C>
20
bool
fillArrayFromString(
const
std::string& source,
C
& userContainer) {
21
if
(
source
.empty())
return
false
;
22
typedef
typename
C::value_type V_t;
23
V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0};
24
boost::char_separator<char>
sep
{
" "
};
25
typedef
boost::tokenizer<boost::char_separator<char> >
Tokenizer
;
26
Tokenizer
tok{
source
,
sep
};
27
bool
noNan{
true
};
28
const
Tokenizer::iterator
end
{tok.end()};
29
int
j
{0};
30
for
(Tokenizer::iterator i{tok.begin()};
i
!=
end
; ++
i
) {
31
try
{
32
userContainer[
j
]=boost::lexical_cast<V_t>(*i);
33
}
catch
(
const
boost::bad_lexical_cast&) {
34
userContainer[
j
]=errVal;
35
noNan=
false
;
36
}
37
++
j
;
38
}
39
return
noNan;
40
}
41
template
<
typename
C>
42
bool
fillEmptyVectorFromString(
const
std::string& source,
C
& userContainer) {
43
if
(
source
.empty())
return
false
;
44
typedef
typename
C::value_type V_t;
45
V_t errVal{std::numeric_limits<V_t>::has_quiet_NaN ? (std::numeric_limits<V_t>::quiet_NaN()) : 0};
46
boost::char_separator<char>
sep
{
" "
};
47
typedef
boost::tokenizer<boost::char_separator<char> >
Tokenizer
;
48
Tokenizer
tok{
source
,
sep
};
49
bool
noNan{
true
};
50
const
Tokenizer::iterator
end
{tok.end()};
51
for
(Tokenizer::iterator i{tok.begin()};
i
!=
end
; ++
i
) {
52
try
{
53
userContainer.push_back(boost::lexical_cast<V_t>(*i));
54
}
catch
(
const
boost::bad_lexical_cast&) {
55
userContainer.push_back(errVal);
56
noNan=
false
;
57
}
58
}
59
return
noNan;
60
}
61
}
// end of anonymous namespace
62
63
#endif
// FillFromStringUtility_h
C
struct color C
CP::DetailSelectionExprParser::Tokenizer
boost::tokenizer< Separator > Tokenizer
Definition
SelectionExprParser.h:34
TauHitVars::j
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
Definition
ConstituentLoaderTauHit.cxx:102
copySelective.source
str source
Definition
copySelective.py:31
grepfile.sep
sep
Definition
grepfile.py:38
lumiFormat.i
int i
Definition
lumiFormat.py:85
mergePhysValFiles.end
end
Definition
DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
Generated on
for ATLAS Offline Software by
1.17.0