Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a52de9e
enh(Foundation): rewrite intToStr with inline fast path and std::to_c…
matejk Apr 6, 2026
7a69896
fix(Foundation): fix isSafeIntCast return type, bare sign parsing, an…
matejk Apr 6, 2026
013f55c
enh(Foundation): optimize strToInt with std::from_chars fast path
matejk Apr 6, 2026
c8b59e2
enh(Foundation): add intToStr per-case and throughput benchmarks
matejk Apr 6, 2026
db8e4dc
enh(Foundation): use string overload in NumberParser to avoid strlen
matejk Apr 6, 2026
7a58925
enh(Foundation): replace constant-value benchmarks with random small …
matejk Apr 6, 2026
ac846b0
enh(Foundation): replace intToStr with two-digits-at-a-time algorithm
matejk Apr 7, 2026
21a1f0e
enh(Foundation): post-review fixes for intToStr and utility functions
matejk Apr 7, 2026
0baca55
enh(Foundation): replace double-conversion with std::to_chars/from_ch…
matejk Apr 7, 2026
e89e669
enh(Foundation): post-review fixes for float conversion and C++17 cle…
matejk Apr 7, 2026
940e66f
enh(Foundation): optimize FixedStr, add const, rewrite benchmarks
matejk Apr 7, 2026
04465ba
Potential fix for pull request finding 'CodeQL / Unused local variable'
matejk Apr 7, 2026
bf7a1b0
fix(Foundation): fix CI failures across all platforms
matejk Apr 7, 2026
d4ff631
fix(Foundation): fix CI failures across all platforms
matejk Apr 8, 2026
2295595
enh(Foundation): fix isSafeIntCast/safeIntCast template parameters
matejk Apr 13, 2026
96ee082
enh(Foundation): remove POCO_NUMERIC_STRING_PRIVATE include guard
matejk Apr 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Foundation/include/Poco/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,29 @@
#define POCO_HAVE_ATOMIC_SHARED_PTR false
#endif

// Float std::to_chars/from_chars support detection.
// - GCC 11+ (libstdc++): full support since GCC 11
// - MSVC 19.24+: full support since VS 2019 16.4
// - Apple Clang: requires macOS 26.0+ deployment target (availability annotations)
// - Non-Apple libc++ (Android NDK, FreeBSD, Emscripten): requires libc++ 20+
// (LLVM 20); libc++ 17-19 have float from_chars overloads explicitly deleted.
// On macOS, even non-Apple LLVM (Homebrew) uses system libc++ headers with
// Apple availability annotations, so __APPLE__ must also be excluded here.
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#endif
#if defined(__cpp_lib_to_chars) && __cpp_lib_to_chars >= 202306L
#define POCO_HAS_FLOAT_CHARCONV 1
#elif defined(_MSC_VER) && _MSC_VER >= 1924
#define POCO_HAS_FLOAT_CHARCONV 1
#elif defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 11
#define POCO_HAS_FLOAT_CHARCONV 1
#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000
#define POCO_HAS_FLOAT_CHARCONV 1
#elif defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 200000 && !defined(__APPLE__)
#define POCO_HAS_FLOAT_CHARCONV 1
#endif

// Option to silence deprecation warnings.
#ifndef POCO_SILENCE_DEPRECATED
#define POCO_DEPRECATED(reason) [[deprecated(reason)]]
Expand Down
64 changes: 32 additions & 32 deletions Foundation/include/Poco/NumberFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,23 +690,23 @@ inline bool NumberFormatter::isEnabled(Options options, Options opt)
inline std::string NumberFormatter::format(int value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(int value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(int value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}

Expand All @@ -726,63 +726,63 @@ inline std::string NumberFormatter::formatHex(int value, int width, Options opti
inline std::string NumberFormatter::format(unsigned value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(unsigned value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(unsigned int value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned value, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}


inline std::string NumberFormatter::format(long value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}

Expand All @@ -802,39 +802,39 @@ inline std::string NumberFormatter::formatHex(long value, int width, Options opt
inline std::string NumberFormatter::format(unsigned long value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(unsigned long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(unsigned long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned long value, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned long value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}

Expand All @@ -845,23 +845,23 @@ inline std::string NumberFormatter::formatHex(unsigned long value, int width, Op
inline std::string NumberFormatter::format(long long value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(long long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(long long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}

Expand All @@ -881,39 +881,39 @@ inline std::string NumberFormatter::formatHex(long long value, int width, Option
inline std::string NumberFormatter::format(unsigned long long value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(unsigned long long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(unsigned long long value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned long long value, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(unsigned long long value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}

Expand All @@ -924,23 +924,23 @@ inline std::string NumberFormatter::formatHex(unsigned long long value, int widt
inline std::string NumberFormatter::format(Int64 value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(Int64 value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(Int64 value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}

Expand All @@ -960,39 +960,39 @@ inline std::string NumberFormatter::formatHex(long long value, int width, Option
inline std::string NumberFormatter::format(UInt64 value)
{
std::string result;
intToStr(value, 10, result);
if (!intToStr(value, 10, result)) result.clear();
return result;
}


inline std::string NumberFormatter::format(UInt64 value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, ' ');
if (!intToStr(value, 10, result, false, width, ' ')) result.clear();
return result;
}


inline std::string NumberFormatter::format0(UInt64 value, int width)
{
std::string result;
intToStr(value, 10, result, false, width, '0');
if (!intToStr(value, 10, result, false, width, '0')) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(UInt64 value, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), -1, ' ', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}


inline std::string NumberFormatter::formatHex(UInt64 value, int width, Options options)
{
std::string result;
intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE));
if (!intToStr(value, 0x10, result, isEnabled(options, Options::HEX_PREFIX), width, '0', 0, isEnabled(options, Options::HEX_LOWERCASE))) result.clear();
return result;
}

Expand Down
Loading
Loading