Mercurial > hg > orthanc
comparison Core/EnumerationDictionary.h @ 2975:e62e296a5714
use Toolbox::IsIntegeer instead of try_lexical_convert that is not available on some platform
author | am@osimis.io |
---|---|
date | Thu, 06 Dec 2018 11:16:23 +0100 |
parents | 146eaed9b02c |
children | 4e43e67f8ecf |
comparison
equal
deleted
inserted
replaced
2974:5f64ecbdfcb4 | 2975:e62e296a5714 |
---|---|
35 | 35 |
36 #include "OrthancException.h" | 36 #include "OrthancException.h" |
37 | 37 |
38 #include "Toolbox.h" | 38 #include "Toolbox.h" |
39 #include <boost/lexical_cast.hpp> | 39 #include <boost/lexical_cast.hpp> |
40 #include <boost/lexical_cast/try_lexical_convert.hpp> | |
41 #include <string> | 40 #include <string> |
42 #include <map> | 41 #include <map> |
43 | 42 |
44 namespace Orthanc | 43 namespace Orthanc |
45 { | 44 { |
83 stringToEnumeration_[boost::lexical_cast<std::string>(static_cast<int>(value))] = value; | 82 stringToEnumeration_[boost::lexical_cast<std::string>(static_cast<int>(value))] = value; |
84 } | 83 } |
85 | 84 |
86 Enumeration Translate(const std::string& str) const | 85 Enumeration Translate(const std::string& str) const |
87 { | 86 { |
88 int numericalValue; // at this stage, we don't know if str is an alias or a numerical value | 87 if (Toolbox::IsInteger(str)) |
89 if (boost::conversion::try_lexical_convert<int>(str, numericalValue)) | |
90 { | 88 { |
91 return static_cast<Enumeration>(numericalValue); | 89 return static_cast<Enumeration>(boost::lexical_cast<int>(str)); |
92 } | 90 } |
93 | 91 |
94 typename StringToEnumeration::const_iterator | 92 typename StringToEnumeration::const_iterator |
95 found = stringToEnumeration_.find(str); | 93 found = stringToEnumeration_.find(str); |
96 | 94 |