ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
14#include <stdexcept>
15
16namespace 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}
double unitValue(const std::string &unitname) const
virtual const std::map< std::string, double > & unitMap() const =0
bool isKnownUnit(const std::string &unitname) const
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Namespace holding all the expression evaluation code.