Releases: eliaskosunen/scnlib
Releases Β· eliaskosunen/scnlib
4.0.1
- Fix documentation generation
Full Changelog: v4.0.0...v4.0.1
4.0.0
Breaking changes
scanner::parsenow returnsIterator, notscan_expected<Iterator>- Errors are reported by throwing a
scan_format_string_error, or by callingParseContext::on_error.
- Errors are reported by throwing a
- Optimize the way
scancallsvscanto remove extra copies/moves
// Dummy-implementation of `scan`
// Before (v3):
auto args = make_scan_args<scan_context, Args...>();
auto result = vscan(std::forward<Source>(source), format, args);
return make_scan_result(std::move(result), std::move(args.args()));
// Now (v4):
auto result = make_scan_result<Source, Args...>();
fill_scan_result(result, vscan(std::forward<Source>(source), format,
make_scan_args(result->values())));
return result;- Changes to
scan_error- Success state removed: use
expected<void, scan_error>instead. scan_error::value_out_of_rangesplit intovalue_positive_overflow,value_negative_overflow,
value_positive_underflow, andvalue_negative_overflow.end_of_rangerenamed toend_of_input.invalid_literal,invalid_fill,length_too_short, andinvalid_source_stateadded.
- Success state removed: use
basic_scan_contextis now templated on the range type
Features
<chrono>scanning- Scanning of pointers (
void*andconst void*) - Ability to disable dependency on FastFloat with
SCN_DISABLE_FAST_FLOAT- FastFloat used to be the only required external dependency
- If disabled,
std::from_charsfor floating-point values is required
Changes
- Deprecate
visit_scan_arg, addbasic_scan_arg::visit - Remove thousands separator checking when scanning localized numbers
scan_error::invalid_source_stateis now returned if syncing with the underlying source fails afterscan
(like for example,std::ungetcfails)
Full Changelog: v3.0.2...v4.0.0
3.0.2
- Fix formatting options of user-defined types sometimes being ignored
- Fix unnecessary blocking in
scn::input - Fix usage of
std::regex_constants::multilineon libstdc++ v11 (#130, thanks @jiayuehua (Jia Yue Hua)) - Fix build failures on Emscripten
- Update documentation to have a version-dropdown
- Fix typo in documentation about manual indexing (#122, thanks @lynxlynxlynx (Jaka Kranjc))
- Fix typos in README (#120, thanks @zencatalyst (Kasra Hashemi))
Full Changelog: v3.0.1...v3.0.2
3.0.1
- Bump
SOVERSIONto 3 (reported in #117, thanks @xvitaly (Vitaly)) - Call
find_packagein CMake iff a target is not already defined (reported in #118, thanks @ajtribick) - Remove
find_dependency(Threads)fromscn-config.cmake
Full Changelog: v3.0.0...v3.0.1
3.0.0
Breaking changes
- The default behavior for scanning integers is now
d(decimal) instead ofi(detect base from prefix).
// v3
auto result = scn::scan<int>("077", "{}");
// result->value() == 77
result = scn::scan<int>("078", "{}");
// result->value() == 78
// v2
auto result = scn::scan<int>("077", "{}");
// result->value() == 63
result = scn::scan<int>("078", "{}");
// result->value() == 7
// result->range() == "8"
// (Because of the '0' prefix, an octal number is expected,
// and '8' is not a valid octal digit, so reading is stopped)- A large part of the bundled
<ranges>-implementation is removed.
Only the parts strictly needed for the library are included.- The library no longer uses a stdlib provided
<ranges>, even if available. - This cut down compile times massively for library consumers
- You now may need to specialize
scn::ranges::enable_borrowed_rangefor your own range types,
even if you've already specializedstd::ranges::enable_borrowed_range.
Specializations ofstd::basic_string_vieware already borrowed out of the box.
- The library no longer uses a stdlib provided
// std::span is a borrowed_range,
// but scnlib doesn't know about it
auto result = scn::scan<...>(std::span{...}, ...);
// decltype(result->range()) is scn::ranges::dangling
namespace scn::ranges {
template <typename T, size_t E>
inline constexpr bool enable_borrowed_range<std::span<T, E>> = true;
}
auto result = scn::scan<...>(std::span{...}, ...);
// decltype(result->range()) is a scn::ranges::subrange<const T*>scn::spanis removedscan_arg_storeandborrowed_subrange_with_sentinelare removed from the public interfacescan_arg_storeis changed to be non-copyable and non-movable, for correctness reasons
(it holds references to itself, copying and moving would be needlessly expensive)- The interface of
make_scan_resultis changed to take atupleinstead of the now unmovablescan_arg_store.
// v3
auto args = make_scan_args<scan_context, Args...>();
auto result = vscan(source, format, args);
return make_scan_result(std::move(result), std::move(args.args()));
// v2
auto args = make_scan_args<scan_context, Args...>();
auto result = vscan(source, format, args);
return make_scan_result(std::move(result), std::move(args));- The meaning of the "width" field in format specifiers is changed to mean the minimum field width
(like instd::format), instead of the maximum (sort of like inscanf)
// v3
auto result = std::scan<int>("123", "{:2}");
// result->value() == 123
// result->range() == ""
// v2
auto result = std::scan<int>("123", "{:2}");
// result->value() == 12
// result->range() == "3"Features
- The "precision" field is added as a format specifier,
which specifies the maximum fields width to scan (like instd::format)
// Scan up to 2 width units
auto result = scn::scan<int>("123", "{:.2}");
// result->value() == 12
// result->range() == "3"- Support for field fill and alignment is added.
This interacts well with the new width and precision fields
// Read an integer, aligned to the right ('>'), with asterisks ('*')
auto result = std::scan<int>("***42", "{:*>}");
// result->value() == 42
// result->range() == ""
// Read an integer, aligned to the left ('<'), with whitespace (default),
// with a maximum total width of 3
auto result = std::scan<int>("42 ", "{:<.3}");
// result->value() == 42
// result->range() == " "- In general, there seems to be a ~10% to 20% improvement in run-time performance.
Changes
- The dependency on
simdutfis removed. The library now has no external dependencies to compiled libraries
(FastFloat, an internal dependency, is a header-only library) - The number of source files is dramatically decreased: there are now just the public headers,
a private implementation header, and a private implementation source file. This cuts down the time needed to
compile the library, and any user code including it to a half (yes, really!)
Fixes
- Fix skipping of multiple characters of whitespace in the format string (reported in #116, thanks @Jonathan-Greve (Jonathan BjΓΈrn Greve))
Full Changelog: v2.0.3...v3.0.0
2.0.3
Fixes:
- Fix documentation: default format type specifier for integers is
i, notd:
when not explicitly specified by a format specifier, the base of an integer is determined based on its prefix:
0x...is hexadecimal,0...or0o...is octal,0b...is binary, and everything else is decimal. - Fix a compilation error which would occur when scanning more than 11 arguments with
scn::scan. - Small CMake adjustments to better support use as a subproject (#113, thanks @frankmiller (Frank Miller))
- Fix misplaced include of
GNUInstallDirsin CMake (#111, thanks @WangWeiLin-MV) - Allow for externally installed versions for GTest and Google Benchmark (#112, thanks @xvitaly (Vitaly))
- Adjust the definition of
SCN_COMPILERto fix usage with a recent Clang using modules (#109, thanks @Delta-dev-99 (Armando Martin)) - Allow for more versions of dependencies (simdutf, fast_float)
- Fix C++23 build failure caused by missing inclusion of
<utility>forstd::unreachable
Full Changelog: v2.0.2...v2.0.3
2.0.2
Minor fixes:
- Fix segfault when runtime-parsing
{:[^as a format string. - Fix compilation of
scan_buffer.cppon some MSVC versions. - Remove stray
test/folder
Full Changelog: v2.0.1...v2.0.2
2.0.1
Minor bugfixes
- Fix detection of support for
std::regex_constants::multiline(#98, thanks @jiayuehua (Jia Yue Hua)) - Fix builds of
float_readeron Android SDK < v28 (#99, thanks @jiayuehua (Jia Yue Hua)) - Fix typo in README example (#100, thanks @ednolan (Eddie Nolan))
Full Changelog: v2.0.0...v2.0.1
2.0.0
Major overhaul, both internally and in terms of the library interface. The library is rewritten in its entirety. See the documentation at https://scnlib.dev/, namely the Migration guide for more details.
The changes below are relative to v1. See CHANGELOG.md for changes relative to v2.0.0-beta.
Major changes include:
- C++17 is required.
- Several names are changed to include the
scan_prefix. scn::scanreturns the scanned values by value. Output parameters are no longer used.scn::scannow accepts allforward_ranges (v1:bidirectional_range+ default- and move constructible).scn::scanreturns a view (subrange) into its input, and never takes ownership.- Scope is more focused: list operations,
ignore,getline, andfilehave been removed. - Support for regular expressions.
- Better Unicode support.
- Performance improvements.
- Completely reworked internals.
Full Changelog: v2.0.0-beta...v2.0.0
1.1.3
Expected to be the last release in the v1-branch.
Development efforts are now fully directed towards v2.
Features
- Allow disabling support for individual types with
SCN_DISABLE_TYPE_*(#70, thanks @cjvaughter (CJ Vaughter))- Also, allow for disabling the fallbacks to
std::from_charsandstd::strtodwhen scanning floats - This provides possible binary size reductions, and allows better use in e.g. embedded platforms
- Also, allow for disabling the fallbacks to
- Allow disabling runtime localization with
SCN_DISABLE_LOCALE(#71, thanks @cjvaughter (CJ Vaughter)) - Parse leading
+signs in floats (reported in #77)
Fixes
- Fix
scn::wrap(std::string_view&&)being ambiguous on gcc (reported in #83) - Fix compiler error in
scn::basic_string_view<CharT>::substr(reported in #86) - Fix memory safety issues found with ASan and UBsan in
small_vector,detail::utf16::validate_next, anddetail::get_buffer. - Add
COMPONENTto CMake install targets (#80, thanks @pawelwod) - Fix calculation of
SCN_MSVCfrom_MSC_FULL_VER(#62, thanks @matbech (Mathias Berchtold)) - Fix MSVC
C4146warning ininteger_scanner(#64, thanks @matbech (Mathias Berchtold)) - Use
if constexprandstd::unreachableif available (#61, #78, thanks @matbech (Mathias Berchtold)) - Improve error messages given from the float parser