3636#include " ParameterAdaptation.h"
3737#include " Utility.h"
3838#include < errno.h>
39+ #include < convert.hpp>
3940
4041#define base CParameterType
4142
@@ -147,14 +148,17 @@ bool CIntegerParameterType::toBlackboard(const string &strValue, uint32_t &uiVal
147148 // Get integer value from the string provided
148149 int64_t iData;
149150
150- if (!convertValueFromString (strValue, iData, parameterAccessContext)) {
151-
152- return false ;
153- }
154-
155151 // Check against Min / Max
156152 if (_bSigned) {
157153
154+ if (not convertTo (strValue, iData)) {
155+ string strError;
156+ strError = " Impossible to convert value " + strValue + " for " + getKind ();
157+
158+ parameterAccessContext.setError (strError);
159+ return false ;
160+ }
161+
158162 if (bValueProvidedAsHexa && isEncodable ((uint64_t )iData, !bValueProvidedAsHexa)) {
159163
160164 // Sign extend
@@ -168,6 +172,14 @@ bool CIntegerParameterType::toBlackboard(const string &strValue, uint32_t &uiVal
168172 }
169173 } else {
170174
175+ if (not convertTo (strValue, (uint64_t &)iData)) {
176+ string strError;
177+ strError = " Impossible to convert value " + strValue + " for " + getKind ();
178+
179+ parameterAccessContext.setError (strError);
180+ return false ;
181+ }
182+
171183 if (!checkValueAgainstRange<uint64_t >(strValue, iData, _uiMin, _uiMax,
172184 parameterAccessContext, bValueProvidedAsHexa)) {
173185
@@ -362,39 +374,6 @@ int CIntegerParameterType::toPlainInteger(int iSizeOptimizedData) const
362374 return base::toPlainInteger (iSizeOptimizedData);
363375}
364376
365- // Convert value provided by the user as a string into an int64
366- bool CIntegerParameterType::convertValueFromString (
367- const string &strValue, int64_t &iData, CParameterAccessContext ¶meterAccessContext) const
368- {
369-
370- // Reset errno to check if it is updated during the conversion (strtol/strtoul)
371- errno = 0 ;
372- char *pcStrEnd;
373-
374- // Convert the input string
375- if (_bSigned) {
376-
377- iData = strtoll (strValue.c_str (), &pcStrEnd, 0 );
378- } else {
379-
380- iData = strtoull (strValue.c_str (), &pcStrEnd, 0 );
381- }
382-
383- // Conversion error when the input string does not contain only digits or the number is out of
384- // range (int32_t type)
385- if (errno || (*pcStrEnd != ' \0 ' )) {
386-
387- string strError;
388- strError = " Impossible to convert value " + strValue + " for " + getKind ();
389-
390- parameterAccessContext.setError (strError);
391-
392- return false ;
393- }
394-
395- return true ;
396- }
397-
398377// Range checking
399378template <typename type>
400379bool CIntegerParameterType::checkValueAgainstRange (const string &strValue, type value,
0 commit comments