File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ module;
2+
3+ #include <CppUtils/System/OS.hpp>
4+
5+ #if defined(OS_MACOS)
6+ # include <cstdlib>
7+ #endif
8+
19export module CppUtils.Language.JSON.Parsing;
210
311import std;
@@ -75,11 +83,23 @@ export namespace CppUtils::Language::JSON
7583 [[nodiscard]] inline auto parseNumber() -> std::expected<double, Error>
7684 {
7785 auto value = 0.0;
86+ #if defined(OS_MACOS)
87+ // macOS ne supporte pas encore std::from_chars
88+ const auto chunk = std::string{m_json.substr(m_position)};
89+ auto* end = static_cast<char*>(nullptr);
90+ value = std::strtod(chunk.c_str(), std::addressof(end));
91+
92+ if (end == chunk.c_str())
93+ return std::unexpected{Error{"Invalid number format", m_position}};
94+
95+ m_position += static_cast<std::size_t>(end - chunk.c_str());
96+ #else
7897 auto result = std::from_chars(std::data(m_json) + m_position, std::data(m_json) + std::size(m_json), value);
7998 if (result.ec != std::errc())
8099 return std::unexpected{Error{"Invalid number format", m_position}};
81100
82101 m_position += static_cast<std::size_t>(result.ptr - (std::data(m_json) + m_position));
102+ #endif
83103 return value;
84104 }
85105
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export namespace CppUtils::Network::DNS
2424 [[nodiscard]] inline auto getHostName() -> std::string
2525 {
2626#if defined(OS_WINDOWS)
27- Socket:: WindowsSocketApi::ensureIsinitialized();
27+ WindowsSocketApi::ensureIsinitialized();
2828#endif
2929 auto hostname = std::string(MaxHostNameLength, '\0');
3030 if (::gethostname(std::data(hostname), std::size(hostname)) != 0)
@@ -38,7 +38,7 @@ export namespace CppUtils::Network::DNS
3838 [[nodiscard]] inline auto resolve(std::string_view hostname) -> std::vector<std::string>
3939 {
4040#if defined(OS_WINDOWS)
41- Socket:: WindowsSocketApi::ensureIsinitialized();
41+ WindowsSocketApi::ensureIsinitialized();
4242#endif
4343 auto hints = addrinfo{};
4444 hints.ai_family = AF_UNSPEC; // IPv4 or IPv6
You can’t perform that action at this time.
0 commit comments