Skip to content

1.0

Compare
Choose a tag to compare
@eliaskosunen eliaskosunen released this 28 Feb 21:09
· 463 commits to master since this release

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