diff --git a/README.md b/README.md index 230cd61..7a4c2de 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ [![windows-msys2-clang](https://github.com/red0124/ssp/workflows/win-msys2-clang-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml) [![win-msvc-ci](https://github.com/red0124/ssp/workflows/win-msvc-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml) [![single-header-ci](https://github.com/red0124/ssp/workflows/single-header-ci/badge.svg)](https://github.com/red0124/ssp/actions/workflows/single-header.yml) -[![coverage](https://coveralls.io/repos/github/red0124/ssp/badge.svg?branch=feature/coverage_ci)](https://coveralls.io/github/red0124/ssp?branch=feature/coverage_ci) +[![coverage](https://coveralls.io/repos/github/red0124/ssp/badge.svg?branch=master/coverage_ci)](https://coveralls.io/github/red0124/ssp?branch=master/coverage_ci) A header only "csv" parser which is fast and versatile with modern C++ api. Requires compiler with C++17 support. [Can also be used to convert strings to specific types.](#the-converter) diff --git a/include/ss/extract.hpp b/include/ss/extract.hpp index 4862f3f..a26828d 100644 --- a/include/ss/extract.hpp +++ b/include/ss/extract.hpp @@ -16,7 +16,6 @@ #include #endif -// TODO try from_chars for integer conversions namespace ss { //////////////// diff --git a/include/ss/parser.hpp b/include/ss/parser.hpp index 54126bb..db80dd3 100644 --- a/include/ss/parser.hpp +++ b/include/ss/parser.hpp @@ -1,6 +1,5 @@ #pragma once -// TODO add single header tests #include "common.hpp" #include "converter.hpp" #include "exception.hpp" diff --git a/ssp.hpp b/ssp.hpp index d50d3c3..cb0bc2e 100644 --- a/ssp.hpp +++ b/ssp.hpp @@ -1465,7 +1465,6 @@ public: #else #endif -// TODO try from_chars for integer conversions namespace ss { //////////////// @@ -1491,17 +1490,24 @@ std::enable_if_t, std::optional> to_num( template std::enable_if_t, std::optional> to_num( const char* const begin, const char* const end) { + static_assert(!std::is_same_v, + "Conversion to long double is disabled"); + constexpr static auto buff_max = 64; - char buff[buff_max]; + char short_buff[buff_max]; size_t string_range = std::distance(begin, end); + std::string long_buff; + char* buff; if (string_range > buff_max) { - return std::nullopt; + long_buff = std::string{begin, end}; + buff = long_buff.data(); + } else { + buff = short_buff; + buff[string_range] = '\0'; + std::copy_n(begin, string_range, buff); } - std::copy_n(begin, string_range, buff); - buff[string_range] = '\0'; - T ret; char* parse_end = nullptr; @@ -1509,8 +1515,6 @@ std::enable_if_t, std::optional> to_num( ret = std::strtof(buff, &parse_end); } else if constexpr (std::is_same_v) { ret = std::strtod(buff, &parse_end); - } else if constexpr (std::is_same_v) { - ret = std::strtold(buff, &parse_end); } if (parse_end != buff + string_range) { @@ -2132,7 +2136,6 @@ private: } /* ss */ -// TODO add single header tests namespace ss {