NumericString.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. //
  2. // NumericString.h
  3. //
  4. // Library: Foundation
  5. // Package: Core
  6. // Module: NumericString
  7. //
  8. // Numeric string utility functions.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef Foundation_NumericString_INCLUDED
  16. #define Foundation_NumericString_INCLUDED
  17. #include "Poco/Foundation.h"
  18. #include "Poco/Buffer.h"
  19. #include "Poco/FPEnvironment.h"
  20. #ifdef min
  21. #undef min
  22. #endif
  23. #ifdef max
  24. #undef max
  25. #endif
  26. #include <limits>
  27. #include <cmath>
  28. #include <cctype>
  29. #if !defined(POCO_NO_LOCALE)
  30. #include <locale>
  31. #endif
  32. #include <type_traits>
  33. #if defined(POCO_NOINTMAX)
  34. typedef Poco::UInt64 uintmax_t;
  35. typedef Poco::Int64 intmax_t;
  36. #endif
  37. #if !defined (INTMAX_MAX)
  38. #define INTMAX_MAX std::numeric_limits<intmax_t>::max()
  39. #endif
  40. #ifdef POCO_COMPILER_MSVC
  41. #pragma warning(push)
  42. #pragma warning(disable : 4146)
  43. #endif // POCO_COMPILER_MSVC
  44. // binary numbers are supported, thus 64 (bits) + 1 (string terminating zero)
  45. #define POCO_MAX_INT_STRING_LEN 65
  46. // value from strtod.cc (double_conversion::kMaxSignificantDecimalDigits)
  47. #define POCO_MAX_FLT_STRING_LEN 780
  48. #define POCO_FLT_INF "inf"
  49. #define POCO_FLT_NAN "nan"
  50. #define POCO_FLT_EXP 'e'
  51. namespace Poco {
  52. namespace Impl {
  53. template<bool SIGNED, typename T>
  54. class IsNegativeImpl;
  55. template<typename T>
  56. class IsNegativeImpl<true, T>
  57. {
  58. public:
  59. bool operator()(T x) { return x < 0; }
  60. };
  61. template<typename T>
  62. class IsNegativeImpl<false, T>
  63. {
  64. public:
  65. bool operator()(T) { return false; }
  66. };
  67. }
  68. template<typename T>
  69. inline bool isNegative(T x)
  70. {
  71. using namespace Impl;
  72. return IsNegativeImpl<std::numeric_limits<T>::is_signed, T>()(x);
  73. }
  74. template<typename To, typename From>
  75. inline bool isIntOverflow(From val)
  76. {
  77. poco_assert_dbg (std::numeric_limits<From>::is_integer);
  78. poco_assert_dbg (std::numeric_limits<To>::is_integer);
  79. bool ret;
  80. if (std::numeric_limits<To>::is_signed)
  81. {
  82. ret = (!std::numeric_limits<From>::is_signed &&
  83. (uintmax_t)val > (uintmax_t)INTMAX_MAX) ||
  84. (intmax_t)val < (intmax_t)std::numeric_limits<To>::min() ||
  85. (intmax_t)val > (intmax_t)std::numeric_limits<To>::max();
  86. }
  87. else
  88. {
  89. ret = isNegative(val) ||
  90. (uintmax_t)val > (uintmax_t)std::numeric_limits<To>::max();
  91. }
  92. return ret;
  93. }
  94. template<typename R, typename F, typename S>
  95. bool safeMultiply(R& result, F f, S s)
  96. {
  97. if ((f == 0) || (s==0))
  98. {
  99. result = 0;
  100. return true;
  101. }
  102. if (f > 0)
  103. {
  104. if (s > 0)
  105. {
  106. if (f > (std::numeric_limits<R>::max() / s))
  107. return false;
  108. }
  109. else
  110. {
  111. if (s < (std::numeric_limits<R>::min() / f))
  112. return false;
  113. }
  114. }
  115. else
  116. {
  117. if (s > 0)
  118. {
  119. if (f < (std::numeric_limits<R>::min() / s))
  120. return false;
  121. }
  122. else
  123. {
  124. if (s < (std::numeric_limits<R>::max() / f))
  125. return false;
  126. }
  127. }
  128. result = f * s;
  129. return true;
  130. }
  131. template <typename F, typename T>
  132. inline T& isSafeIntCast(F from)
  133. /// Returns true if it is safe to cast
  134. /// integer from F to T.
  135. {
  136. if (!isIntOverflow<T, F>(from)) return true;
  137. return false;
  138. }
  139. template <typename F, typename T>
  140. inline T& safeIntCast(F from, T& to)
  141. /// Returns cast value if it is safe
  142. /// to cast integer from F to T,
  143. /// otherwise throws BadCastException.
  144. {
  145. if (!isIntOverflow<T, F>(from))
  146. {
  147. to = static_cast<T>(from);
  148. return to;
  149. }
  150. throw BadCastException("safeIntCast: Integer overflow");
  151. }
  152. inline char decimalSeparator()
  153. /// Returns decimal separator from global locale or
  154. /// default '.' for platforms where locale is unavailable.
  155. {
  156. #if !defined(POCO_NO_LOCALE)
  157. return std::use_facet<std::numpunct<char>>(std::locale()).decimal_point();
  158. #else
  159. return '.';
  160. #endif
  161. }
  162. inline char thousandSeparator()
  163. /// Returns thousand separator from global locale or
  164. /// default ',' for platforms where locale is unavailable.
  165. {
  166. #if !defined(POCO_NO_LOCALE)
  167. return std::use_facet<std::numpunct<char>>(std::locale()).thousands_sep();
  168. #else
  169. return ',';
  170. #endif
  171. }
  172. //
  173. // String to Number Conversions
  174. //
  175. template <typename I>
  176. bool strToInt(const char* pStr, I& outResult, short base, char thSep = ',')
  177. /// Converts zero-terminated character array to integer number;
  178. /// Thousand separators are recognized for base10 and current locale;
  179. /// they are silently skipped and not verified for correct positioning.
  180. /// It is not allowed to convert a negative number to anything except
  181. /// 10-base signed integer.
  182. /// For hexadecimal numbers, the case of the digits is not relevant.
  183. ///
  184. /// Function returns true if successful. If parsing was unsuccessful,
  185. /// the return value is false with the result value undetermined.
  186. {
  187. poco_assert_dbg (base == 2 || base == 8 || base == 10 || base == 16);
  188. if (!pStr) return false;
  189. while (std::isspace(*pStr)) ++pStr;
  190. if ((*pStr == '\0') || ((*pStr == '-') && ((base != 10) || (std::is_unsigned<I>::value))))
  191. return false;
  192. bool negative = false;
  193. if ((base == 10) && (*pStr == '-'))
  194. {
  195. if (!std::numeric_limits<I>::is_signed) return false;
  196. negative = true;
  197. ++pStr;
  198. }
  199. else if (*pStr == '+') ++pStr;
  200. // numbers are parsed as unsigned, for negative numbers the sign is applied after parsing
  201. // overflow is checked in every parse step
  202. uintmax_t limitCheck = std::numeric_limits<I>::max();
  203. if (negative) ++limitCheck;
  204. uintmax_t result = 0;
  205. unsigned char add = 0;
  206. for (; *pStr != '\0'; ++pStr)
  207. {
  208. if (*pStr == thSep)
  209. {
  210. if (base == 10) continue;
  211. throw Poco::SyntaxException("strToInt: thousand separators only allowed for base 10");
  212. }
  213. if (result > (limitCheck / base)) return false;
  214. if (!safeMultiply(result, result, base)) return false;
  215. switch (*pStr)
  216. {
  217. case '0': case '1': case '2': case '3':
  218. case '4': case '5': case '6': case '7':
  219. add = (*pStr - '0');
  220. break;
  221. case '8': case '9':
  222. if ((base == 10) || (base == 0x10)) add = (*pStr - '0');
  223. else return false;
  224. break;
  225. case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
  226. if (base != 0x10) return false;
  227. add = (*pStr - 'a') + 10;
  228. break;
  229. case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
  230. if (base != 0x10) return false;
  231. add = (*pStr - 'A') + 10;
  232. break;
  233. default:
  234. return false;
  235. }
  236. if ((limitCheck - static_cast<uintmax_t>(result)) < add) return false;
  237. result += add;
  238. }
  239. if (negative && (base == 10))
  240. outResult = static_cast<I>(-result);
  241. else
  242. outResult = static_cast<I>(result);
  243. return true;
  244. }
  245. template <typename I>
  246. bool strToInt(const std::string& str, I& result, short base, char thSep = ',')
  247. /// Converts string to integer number;
  248. /// This is a wrapper function, for details see see the
  249. /// bool strToInt(const char*, I&, short, char) implementation.
  250. {
  251. return strToInt(str.c_str(), result, base, thSep);
  252. }
  253. //
  254. // Number to String Conversions
  255. //
  256. namespace Impl {
  257. class Ptr
  258. /// Utility char pointer wrapper class.
  259. /// Class ensures increment/decrement remain within boundaries.
  260. {
  261. public:
  262. Ptr(char* ptr, std::size_t offset): _beg(ptr), _cur(ptr), _end(ptr + offset)
  263. {
  264. }
  265. char*& operator ++ () // prefix
  266. {
  267. checkBounds(_cur + 1);
  268. return ++_cur;
  269. }
  270. char* operator ++ (int) // postfix
  271. {
  272. checkBounds(_cur + 1);
  273. char* tmp = _cur++;
  274. return tmp;
  275. }
  276. char*& operator -- () // prefix
  277. {
  278. checkBounds(_cur - 1);
  279. return --_cur;
  280. }
  281. char* operator -- (int) // postfix
  282. {
  283. checkBounds(_cur - 1);
  284. char* tmp = _cur--;
  285. return tmp;
  286. }
  287. char*& operator += (int incr)
  288. {
  289. checkBounds(_cur + incr);
  290. return _cur += incr;
  291. }
  292. char*& operator -= (int decr)
  293. {
  294. checkBounds(_cur - decr);
  295. return _cur -= decr;
  296. }
  297. operator char* () const
  298. {
  299. return _cur;
  300. }
  301. std::size_t span() const
  302. {
  303. return _end - _beg;
  304. }
  305. private:
  306. void checkBounds(char* ptr)
  307. {
  308. if (ptr > _end) throw RangeException();
  309. }
  310. const char* _beg;
  311. char* _cur;
  312. const char* _end;
  313. };
  314. template <typename T>
  315. using EnableSigned = typename std::enable_if< std::is_signed<T>::value >::type*;
  316. template <typename T>
  317. using EnableUnsigned = typename std::enable_if< std::is_unsigned<T>::value >::type*;
  318. } // namespace Impl
  319. template <typename T, Impl::EnableSigned<T> = nullptr>
  320. bool intToStr(T value,
  321. unsigned short base,
  322. char* result,
  323. std::size_t& size,
  324. bool prefix = false,
  325. int width = -1,
  326. char fill = ' ',
  327. char thSep = 0,
  328. bool lowercase = false)
  329. /// Converts signed integer to string. Standard numeric bases from binary to hexadecimal
  330. /// are supported.
  331. /// If width is non-zero, it pads the return value with fill character to the specified width.
  332. /// When padding is zero character ('0'), it is prepended to the number itself; all other
  333. /// paddings are prepended to the formatted result with minus sign or base prefix included
  334. /// If prefix is true and base is octal or hexadecimal, respective prefix ('0' for octal,
  335. /// "0x" for hexadecimal) is prepended. For all other bases, prefix argument is ignored.
  336. /// Formatted string has at least [width] total length.
  337. {
  338. poco_assert_dbg (((value < 0) && (base == 10)) || (value >= 0));
  339. if (base < 2 || base > 0x10)
  340. {
  341. *result = '\0';
  342. return false;
  343. }
  344. Impl::Ptr ptr(result, size);
  345. int thCount = 0;
  346. T tmpVal;
  347. do
  348. {
  349. tmpVal = value;
  350. value /= base;
  351. *ptr++ = (lowercase ? "fedcba9876543210123456789abcdef" : "FEDCBA9876543210123456789ABCDEF")[15 + (tmpVal - value * base)];
  352. if (thSep && (base == 10) && (++thCount == 3))
  353. {
  354. *ptr++ = thSep;
  355. thCount = 0;
  356. }
  357. } while (value);
  358. if ('0' == fill)
  359. {
  360. if (tmpVal < 0) --width;
  361. if (prefix && base == 010) --width;
  362. if (prefix && base == 0x10) width -= 2;
  363. while ((ptr - result) < width) *ptr++ = fill;
  364. }
  365. if (prefix && base == 010) *ptr++ = '0';
  366. else if (prefix && base == 0x10)
  367. {
  368. *ptr++ = 'x';
  369. *ptr++ = '0';
  370. }
  371. if (tmpVal < 0) *ptr++ = '-';
  372. if ('0' != fill)
  373. {
  374. while ((ptr - result) < width) *ptr++ = fill;
  375. }
  376. size = ptr - result;
  377. poco_assert_dbg (size <= ptr.span());
  378. poco_assert_dbg ((-1 == width) || (size >= size_t(width)));
  379. *ptr-- = '\0';
  380. char* ptrr = result;
  381. char tmp;
  382. while(ptrr < ptr)
  383. {
  384. tmp = *ptr;
  385. *ptr-- = *ptrr;
  386. *ptrr++ = tmp;
  387. }
  388. return true;
  389. }
  390. template <typename T, Impl::EnableUnsigned<T> = nullptr>
  391. bool intToStr(T value,
  392. unsigned short base,
  393. char* result,
  394. std::size_t& size,
  395. bool prefix = false,
  396. int width = -1,
  397. char fill = ' ',
  398. char thSep = 0,
  399. bool lowercase = false)
  400. /// Converts unsigned integer to string. Numeric bases from binary to hexadecimal are supported.
  401. /// If width is non-zero, it pads the return value with fill character to the specified width.
  402. /// When padding is zero character ('0'), it is prepended to the number itself; all other
  403. /// paddings are prepended to the formatted result with minus sign or base prefix included
  404. /// If prefix is true and base is octal or hexadecimal, respective prefix ('0' for octal,
  405. /// "0x" for hexadecimal) is prepended. For all other bases, prefix argument is ignored.
  406. /// Formatted string has at least [width] total length.
  407. {
  408. if (base < 2 || base > 0x10)
  409. {
  410. *result = '\0';
  411. return false;
  412. }
  413. Impl::Ptr ptr(result, size);
  414. int thCount = 0;
  415. T tmpVal;
  416. do
  417. {
  418. tmpVal = value;
  419. value /= base;
  420. *ptr++ = (lowercase ? "fedcba9876543210123456789abcdef" : "FEDCBA9876543210123456789ABCDEF")[15 + (tmpVal - value * base)];
  421. if (thSep && (base == 10) && (++thCount == 3))
  422. {
  423. *ptr++ = thSep;
  424. thCount = 0;
  425. }
  426. } while (value);
  427. if ('0' == fill)
  428. {
  429. if (prefix && base == 010) --width;
  430. if (prefix && base == 0x10) width -= 2;
  431. while ((ptr - result) < width) *ptr++ = fill;
  432. }
  433. if (prefix && base == 010) *ptr++ = '0';
  434. else if (prefix && base == 0x10)
  435. {
  436. *ptr++ = 'x';
  437. *ptr++ = '0';
  438. }
  439. if ('0' != fill)
  440. {
  441. while ((ptr - result) < width) *ptr++ = fill;
  442. }
  443. size = ptr - result;
  444. poco_assert_dbg (size <= ptr.span());
  445. poco_assert_dbg ((-1 == width) || (size >= size_t(width)));
  446. *ptr-- = '\0';
  447. char* ptrr = result;
  448. char tmp;
  449. while(ptrr < ptr)
  450. {
  451. tmp = *ptr;
  452. *ptr-- = *ptrr;
  453. *ptrr++ = tmp;
  454. }
  455. return true;
  456. }
  457. template <typename T>
  458. [[deprecated("use intToStr instead")]]
  459. bool uIntToStr(T value,
  460. unsigned short base,
  461. char* result,
  462. std::size_t& size,
  463. bool prefix = false,
  464. int width = -1,
  465. char fill = ' ',
  466. char thSep = 0,
  467. bool lowercase = false)
  468. /// Converts unsigned integer to string. Numeric bases from binary to hexadecimal are supported.
  469. /// If width is non-zero, it pads the return value with fill character to the specified width.
  470. /// When padding is zero character ('0'), it is prepended to the number itself; all other
  471. /// paddings are prepended to the formatted result with minus sign or base prefix included
  472. /// If prefix is true and base is octal or hexadecimal, respective prefix ('0' for octal,
  473. /// "0x" for hexadecimal) is prepended. For all other bases, prefix argument is ignored.
  474. /// Formatted string has at least [width] total length.
  475. ///
  476. /// This function is deprecated; use intToStr instead.
  477. {
  478. return intToStr(value, base, result, size, prefix, width, fill, thSep, lowercase);
  479. }
  480. template <typename T>
  481. bool intToStr (T number,
  482. unsigned short base,
  483. std::string& result,
  484. bool prefix = false,
  485. int width = -1,
  486. char fill = ' ',
  487. char thSep = 0,
  488. bool lowercase = false)
  489. /// Converts integer to string; This is a wrapper function, for details see the
  490. /// bool intToStr(T, unsigned short, char*, int, int, char, char) implementation.
  491. {
  492. char res[POCO_MAX_INT_STRING_LEN] = {0};
  493. std::size_t size = POCO_MAX_INT_STRING_LEN;
  494. bool ret = intToStr(number, base, res, size, prefix, width, fill, thSep, lowercase);
  495. result.assign(res, size);
  496. return ret;
  497. }
  498. template <typename T>
  499. [[deprecated("use intToStr instead")]]
  500. bool uIntToStr (T number,
  501. unsigned short base,
  502. std::string& result,
  503. bool prefix = false,
  504. int width = -1,
  505. char fill = ' ',
  506. char thSep = 0,
  507. bool lowercase = false)
  508. /// Converts unsigned integer to string; This is a wrapper function, for details see the
  509. /// bool uIntToStr(T, unsigned short, char*, int, int, char, char) implementation.
  510. ///
  511. /// This function is deprecated; use intToStr instead.
  512. {
  513. return intToStr(number, base, result, prefix, width, fill, thSep, lowercase);
  514. }
  515. //
  516. // Wrappers for double-conversion library (http://code.google.com/p/double-conversion/).
  517. //
  518. // Library is the implementation of the algorithm described in Florian Loitsch's paper:
  519. // http://florian.loitsch.com/publications/dtoa-pldi2010.pdf
  520. //
  521. Foundation_API void floatToStr(char* buffer,
  522. int bufferSize,
  523. float value,
  524. int lowDec = -std::numeric_limits<float>::digits10,
  525. int highDec = std::numeric_limits<float>::digits10);
  526. /// Converts a float value to string. Converted string must be shorter than bufferSize.
  527. /// Conversion is done by computing the shortest string of digits that correctly represents
  528. /// the input number. Depending on lowDec and highDec values, the function returns
  529. /// decimal or exponential representation.
  530. Foundation_API void floatToFixedStr(char* buffer,
  531. int bufferSize,
  532. float value,
  533. int precision);
  534. /// Converts a float value to string. Converted string must be shorter than bufferSize.
  535. /// Computes a decimal representation with a fixed number of digits after the
  536. /// decimal point.
  537. Foundation_API std::string& floatToStr(std::string& str,
  538. float value,
  539. int precision = -1,
  540. int width = 0,
  541. char thSep = 0,
  542. char decSep = 0);
  543. /// Converts a float value, assigns it to the supplied string and returns the reference.
  544. /// This function calls floatToStr(char*, int, float, int, int) and formats the result according to
  545. /// precision (total number of digits after the decimal point, -1 means ignore precision argument)
  546. /// and width (total length of formatted string).
  547. Foundation_API std::string& floatToFixedStr(std::string& str,
  548. float value,
  549. int precision,
  550. int width = 0,
  551. char thSep = 0,
  552. char decSep = 0);
  553. /// Converts a float value, assigns it to the supplied string and returns the reference.
  554. /// This function calls floatToFixedStr(char*, int, float, int) and formats the result according to
  555. /// precision (total number of digits after the decimal point) and width (total length of formatted string).
  556. Foundation_API void doubleToStr(char* buffer,
  557. int bufferSize,
  558. double value,
  559. int lowDec = -std::numeric_limits<double>::digits10,
  560. int highDec = std::numeric_limits<double>::digits10);
  561. /// Converts a double value to string. Converted string must be shorter than bufferSize.
  562. /// Conversion is done by computing the shortest string of digits that correctly represents
  563. /// the input number. Depending on lowDec and highDec values, the function returns
  564. /// decimal or exponential representation.
  565. Foundation_API void doubleToFixedStr(char* buffer,
  566. int bufferSize,
  567. double value,
  568. int precision);
  569. /// Converts a double value to string. Converted string must be shorter than bufferSize.
  570. /// Computes a decimal representation with a fixed number of digits after the
  571. /// decimal point.
  572. Foundation_API std::string& doubleToStr(std::string& str,
  573. double value,
  574. int precision = -1,
  575. int width = 0,
  576. char thSep = 0,
  577. char decSep = 0);
  578. /// Converts a double value, assigns it to the supplied string and returns the reference.
  579. /// This function calls doubleToStr(char*, int, double, int, int) and formats the result according to
  580. /// precision (total number of digits after the decimal point, -1 means ignore precision argument)
  581. /// and width (total length of formatted string).
  582. Foundation_API std::string& doubleToFixedStr(std::string& str,
  583. double value,
  584. int precision = -1,
  585. int width = 0,
  586. char thSep = 0,
  587. char decSep = 0);
  588. /// Converts a double value, assigns it to the supplied string and returns the reference.
  589. /// This function calls doubleToFixedStr(char*, int, double, int) and formats the result according to
  590. /// precision (total number of digits after the decimal point) and width (total length of formatted string).
  591. Foundation_API float strToFloat(const char* str,
  592. const char* inf = POCO_FLT_INF, const char* nan = POCO_FLT_NAN);
  593. /// Converts the string of characters into single-precision floating point number.
  594. /// Function uses double_conversion::DoubleToStringConverter to do the conversion.
  595. Foundation_API bool strToFloat(const std::string&, float& result,
  596. char decSep = '.', char thSep = ',',
  597. const char* inf = POCO_FLT_INF, const char* nan = POCO_FLT_NAN);
  598. /// Converts the string of characters into single-precision floating point number.
  599. /// The conversion result is assigned to the result parameter.
  600. /// If decimal separator and/or thousand separator are different from defaults, they should be
  601. /// supplied to ensure proper conversion.
  602. ///
  603. /// Returns true if successful, false otherwise.
  604. Foundation_API double strToDouble(const char* str,
  605. const char* inf = POCO_FLT_INF, const char* nan = POCO_FLT_NAN);
  606. /// Converts the string of characters into double-precision floating point number.
  607. Foundation_API bool strToDouble(const std::string& str, double& result,
  608. char decSep = '.', char thSep = ',',
  609. const char* inf = POCO_FLT_INF, const char* nan = POCO_FLT_NAN);
  610. /// Converts the string of characters into double-precision floating point number.
  611. /// The conversion result is assigned to the result parameter.
  612. /// If decimal separator and/or thousand separator are different from defaults, they should be
  613. /// supplied to ensure proper conversion.
  614. ///
  615. /// Returns true if successful, false otherwise.
  616. } // namespace Poco
  617. #ifdef POCO_COMPILER_MSVC
  618. #pragma warning(pop)
  619. #endif // POCO_COMPILER_MSVC
  620. #endif // Foundation_NumericString_INCLUDED