Remove some comments, update README, update ssp.hpp

This commit is contained in:
ado 2023-08-08 14:38:49 +02:00
parent 672b89b213
commit 8b72deb1ed
4 changed files with 13 additions and 12 deletions

View File

@ -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) [![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) [![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) [![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) 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)

View File

@ -16,7 +16,6 @@
#include <cstdlib> #include <cstdlib>
#endif #endif
// TODO try from_chars for integer conversions
namespace ss { namespace ss {
//////////////// ////////////////

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
// TODO add single header tests
#include "common.hpp" #include "common.hpp"
#include "converter.hpp" #include "converter.hpp"
#include "exception.hpp" #include "exception.hpp"

21
ssp.hpp
View File

@ -1465,7 +1465,6 @@ public:
#else #else
#endif #endif
// TODO try from_chars for integer conversions
namespace ss { namespace ss {
//////////////// ////////////////
@ -1491,16 +1490,23 @@ std::enable_if_t<std::is_floating_point_v<T>, std::optional<T>> to_num(
template <typename T> template <typename T>
std::enable_if_t<std::is_floating_point_v<T>, std::optional<T>> to_num( std::enable_if_t<std::is_floating_point_v<T>, std::optional<T>> to_num(
const char* const begin, const char* const end) { const char* const begin, const char* const end) {
static_assert(!std::is_same_v<T, long double>,
"Conversion to long double is disabled");
constexpr static auto buff_max = 64; constexpr static auto buff_max = 64;
char buff[buff_max]; char short_buff[buff_max];
size_t string_range = std::distance(begin, end); size_t string_range = std::distance(begin, end);
std::string long_buff;
char* buff;
if (string_range > buff_max) { if (string_range > buff_max) {
return std::nullopt; long_buff = std::string{begin, end};
} buff = long_buff.data();
} else {
std::copy_n(begin, string_range, buff); buff = short_buff;
buff[string_range] = '\0'; buff[string_range] = '\0';
std::copy_n(begin, string_range, buff);
}
T ret; T ret;
char* parse_end = nullptr; char* parse_end = nullptr;
@ -1509,8 +1515,6 @@ std::enable_if_t<std::is_floating_point_v<T>, std::optional<T>> to_num(
ret = std::strtof(buff, &parse_end); ret = std::strtof(buff, &parse_end);
} else if constexpr (std::is_same_v<T, double>) { } else if constexpr (std::is_same_v<T, double>) {
ret = std::strtod(buff, &parse_end); ret = std::strtod(buff, &parse_end);
} else if constexpr (std::is_same_v<T, long double>) {
ret = std::strtold(buff, &parse_end);
} }
if (parse_end != buff + string_range) { if (parse_end != buff + string_range) {
@ -2132,7 +2136,6 @@ private:
} /* ss */ } /* ss */
// TODO add single header tests
namespace ss { namespace ss {