ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis
CommonTools
ExpressionEvaluation
Root
IUnitInterpreter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// IUnitInterpreter.cxx, (c) ATLAS Detector software
8
// Author: Thomas Gillam (thomas.gillam@cern.ch)
9
// ExpressionParsing library
11
12
#include "
ExpressionEvaluation/IUnitInterpreter.h
"
13
14
#include <stdexcept>
15
16
namespace
ExpressionParsing
{
17
bool
IUnitInterpreter::isKnownUnit
(
const
std::string &unitname)
const
18
{
19
return
(
unitMap
().
count
(unitname) > 0);
20
}
21
22
double
IUnitInterpreter::unitValue
(
const
std::string &unitname)
const
23
{
24
typedef
std::map<std::string, double>::const_iterator
Iterator
;
25
const
std::map<std::string, double> &theMap =
unitMap
();
26
for
(
Iterator
it = theMap.begin(); it != theMap.end(); ++it) {
27
if
(it->first == unitname) {
28
return
it->second;
29
}
30
}
31
32
throw
std::runtime_error(
"Trying to access unknown unit: "
+unitname);
33
}
34
}
IUnitInterpreter.h
ExpressionParsing::IUnitInterpreter::unitValue
double unitValue(const std::string &unitname) const
Definition
IUnitInterpreter.cxx:22
ExpressionParsing::IUnitInterpreter::unitMap
virtual const std::map< std::string, double > & unitMap() const =0
ExpressionParsing::IUnitInterpreter::isKnownUnit
bool isKnownUnit(const std::string &unitname) const
Definition
IUnitInterpreter.cxx:17
Iterator
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:146
ExpressionParsing
Namespace holding all the expression evaluation code.
Definition
ExpressionParser.h:26
Generated on
for ATLAS Offline Software by
1.14.0