lib3mf 2.5 :
- aggiornamento versione - utilizzate le nostre librerie esterne libzip e zlib e non quelle incluse in lib3mf.
This commit is contained in:
@@ -38,6 +38,7 @@ correctly and Exception-safe
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <charconv>
|
||||
|
||||
namespace NMR {
|
||||
|
||||
@@ -153,18 +154,24 @@ namespace NMR {
|
||||
__NMRASSERT(pwszValue);
|
||||
nfDouble dResult = 0.0;
|
||||
|
||||
// Convert to double and make a input and range check!
|
||||
nfChar * pEndPtr;
|
||||
//skip leading whitespaces
|
||||
for (; *pszValue && *pszValue == ' '; pszValue++);
|
||||
|
||||
dResult = strtod(pszValue, &pEndPtr);
|
||||
// Convert to double and make a input and range check!
|
||||
auto answer = fast_float::from_chars(pszValue, pszValue + strlen(pszValue), dResult);
|
||||
|
||||
// Check if any conversion happened
|
||||
if ((pEndPtr == pszValue) || (!pEndPtr))
|
||||
if (answer.ec != std::errc())
|
||||
{
|
||||
throw CNMRException(NMR_ERROR_EMPTYSTRINGTODOUBLECONVERSION);
|
||||
|
||||
if ((*pEndPtr != '\0') && (*pEndPtr != ' '))
|
||||
throw CNMRException(NMR_ERROR_INVALIDSTRINGTODOUBLECONVERSION);
|
||||
|
||||
}
|
||||
else if (answer.ptr) // Invalidate comma as decimal separator
|
||||
{
|
||||
if (answer.ptr[0] == ',')
|
||||
{
|
||||
throw CNMRException(NMR_ERROR_INVALIDSTRINGTODOUBLECONVERSION);
|
||||
}
|
||||
}
|
||||
if ((dResult == HUGE_VAL) || (dResult == -HUGE_VAL))
|
||||
throw CNMRException(NMR_ERROR_STRINGTODOUBLECONVERSIONOUTOFRANGE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user