Skip to content

Releases: eliaskosunen/scnlib

1.1

12 Mar 21:59
Compare
Choose a tag to compare
1.1
  • Add support for scanning 8-bit integers ((un)signed char, (u)int8_t),
    and characters (char, wchar_t) as integers
int8_t i1, i2;
char c1, c2;
auto ret = scn::scan("1 2 3 4", "{} {:c} {} {:i}", i1, i2, i3, i4);
// ret == true
// i1 == 1
// i2 == '2'
// c1 == '3'
// c2 == 4
  • Fix usage of external fast_float in CMake (#53, thanks @xvitaly (Vitaly Zaitsev))
  • Fix tests on big endian architectures (#54)
  • Fix alignment issues with small_vector on 32-bit architectures

Full Changelog: v1.0...v1.1

1.0

28 Feb 21:09
Compare
Choose a tag to compare
1.0

First stable release!

The library is now deemed production-ready, and backwards-compatibility will be maintained until the next major release comes out, in accordance to semantic versioning. 1.x-versions will be getting security updates after that, until further notice.

If you're migrating from v1.0-rc1, no major changes have been made, only bugfixes.

If you're migrating from v0.4, see the migration guide v0.4 -> v1.0.

If you're new here, see the documentation and the repository.

The feature highlights below are the same compared to those of v1.0-rc1

Feature highlights

New float parsing

Now, by default, scnlib uses https://github.com/fastfloat/fast_float for parsing floating-point values, falling back on std::from_chars and std::strtod only if necessary.

This provides even more performance than before: using scn::scan is now 2x to 8x faster than using std::stringstream, when parsing floats.

New format strings

Many things have changed (see the migration guide above), and the same format strings may now do different things.

// alignment
int i{};
auto result = scn::scan("***1***", "{:*^}", i);
// i == 1
// result.empty() == true

// localization
double d{};
result = scn::scan_localized(std::locale{"fi_FI.UTF-8"}, "3,14", "{:L}", d);
// d == 3.14
// result.empty() == true

// width
std::string str1;
result = scn::scan("abcde", "{:3}", str1);
// str1 == "abc"
// result.range() == "de"

// string set
std::string str2;
result = scn::scan("123abc", "{:[0-9]}", str2);
// str2 == "123"
// result.range() == "abc"

Unicode support

// Parse Unicode code points
scn::code_point cp{};
auto result = scn::scan("äa", "{}", cp);
// cp == 0xe4
// result.range() == "a"

// Parse Unicode strings
std::string s1, s2;
// s1: read until whitespace
// s2: read until non-letter character, according to locale
result = scn::scan_localized(std::locale{"fi_FI.UTF-8"}, "äa1 äa1", "{} {:L[:alpha:]}", s1, s2);
// s1 == "äa1"
// s2 == "äa"
// result.range() == "1"

And more

See CHANGELOG.md and the documentation for more details

Full Changelog (from v1.0-rc1): v1.0-rc1...v1.0

1.0-rc1

21 Feb 20:34
Compare
Choose a tag to compare
1.0-rc1 Pre-release
Pre-release

Getting closer to 1.0!

Feature highlights

New float parsing

Now, by default, scnlib uses https://github.com/fastfloat/fast_float for parsing floating-point values, falling back on std::from_chars and std::strtod only if necessary.

This provides even more performance than before.

New format strings

Many things have changed (see the migration guide below), and the same format strings may now do different things.

// alignment
int i{};
auto result = scn::scan("***1***", "{:*^}", i);
// i == 1
// result.empty() == true

// localization
double d{};
result = scn::scan_localized(std::locale{"fi_FI.UTF-8"}, "3,14", "{:L}", d);
// d == 3.14
// result.empty() == true

// width
std::string str1;
result = scn::scan("abcde", "{:3}", str1);
// str1 == "abc"
// result.range() == "de"

// string set
std::string str2;
result = scn::scan("123abc", "{:[0-9]}", str2);
// str2 == "123"
// result.range() == "abc"

Unicode support

// Parse Unicode code points
scn::code_point cp{};
auto result = scn::scan("äa", "{}", cp);
// cp == 0xe4
// result.range() == "a"

// Parse Unicode strings
std::string s1, s2;
// s1: read until whitespace
// s2: read until non-letter character, according to locale
result = scn::scan_localized(std::locale{"fi_FI.UTF-8"}, "äa äa", "{} {:L[:alpha:]}", s1, s2);
// s1 == s2 == "äa"
// result.empty() == true

And more

See CHANGELOG.md and the documentation, namely the migration guide for more details

Full Changelog: v0.4...v1.0-rc1

0.4

13 Nov 22:25
Compare
Choose a tag to compare
0.4 Pre-release
Pre-release

Planned to be the last 0.x release before 1.0-rc1.

Changes and removals

  • Rework source range handling:
    • Non-views are now accepted as source ranges --
      this includes types like std::string and std::vector<char>
    • Non-reconstructible ranges are now also accepted --
      scanning functions no longer return a reconstructed source range.
      The member function .range() can be used to scan the range again,
      and .reconstruct() reconstructs the range, if possible.
      Other helper member functions are also available.
    • Source ranges are now either taken by const lvalue reference or rvalue reference,
      so they are no longer modified by scanning functions.
      To access the leftover range, use the return value of the scanning function.
  • Rewrite file handling, with hopefully way less bugs this time around
    • Remove file_view and caching ranges
    • Move memory mapped files to the public API
  • Remove default_tag, replace with scan_default function template
  • Remove support for scanf syntax, including scn::scanf and scn::basic_scanf_parse_context.
  • Improve Ranges integration:
    • Move custom Ranges implementation to the public API (out from scn::detail::ranges): scn::custom_ranges
    • Integrate standard library Ranges, if available: scn::std_ranges aliased to std::ranges
    • Use stdlib Ranges, if available, fall back to custom implementation: namespace alias scn::ranges, control behavior with SCN_USE_STD_RANGES

Additions

  • Add more thorough documentation, tests, benchmarks and examples
  • Add scan_list_until

Fixes and minor stuff

0.3

19 Feb 15:08
Compare
Choose a tag to compare
0.3 Pre-release
Pre-release

Largely a bugfix release

Changes

  • Remove support for partial successes
    • If the reading of any of the arguments given to scan fail, the whole function fails
    • read-field removed from result
  • Overhaul list scanning
    • Add scan_list

Fixes

  • Fix issues with std::string_view and MSVC debug iterators (#11, #14, #18, #20)
  • Fix some issues with scanning customized types (#15)
  • Add missing support for custom-allocator std::strings (#16)
  • Fix erroneous git command in README (#13)
  • Fix README example
  • Fix erroneous usage of library feature test macros

Thanks to @nanoric and @SuperWig for bug reports!

Removals

  • Remove support for non-std::char_traits std::strings
  • Remove support for clang 3.6

0.2

18 Oct 16:34
Compare
Choose a tag to compare
0.2 Pre-release
Pre-release

There are so many changes, that writing a complete changelog isn't really possible.
The most substantial change is the removal of streams, which have been replaced with C++20-like ranges.
There are also some pretty sweet performance improvements; see benchmarks in README for more details.

See the documentation for more details, a tutorial, and an API reference.

0.1.2

25 Jun 21:17
Compare
Choose a tag to compare
0.1.2 Pre-release
Pre-release
  • Add SCN_RANGES CMake option
  • Add scn::temp helper function
  • Fix -Wpadded warnings on clang
  • Fix -Wfloat-equal and -Wconversion warnings on gcc
  • Fix C4146 error on UWP MSVC
  • Add CONTRIBUTING.md

0.1.1

25 Jun 19:15
Compare
Choose a tag to compare
0.1.1 Pre-release
Pre-release

Quick bugfix release

  • Add more examples
  • Fix #8: Fix segfault when using scn::cstdin() or scn::wcstdin(),
    caused by the copy and move constructor of small_vector setting data pointer to nullptr
    if copying/moving from an empty small_vector.
    (Thanks @SuperWig for reporting!)
  • Fix compilation error when using scn::ranges::get_value.
  • Fix a badge in README (thanks @p1v0t)

0.1

24 Jun 01:52
Compare
Choose a tag to compare
0.1 Pre-release
Pre-release

First release!