string_theory

Flexible modern C++ string library with type-safe formatting

MIT License

Stars
51

Bot releases are hidden (Show)

string_theory - String Theory 3.8 Latest Release

Published by zrax about 1 year ago

  • Fix UB in find and related operations, which could read past the end of the string in certain cases.
  • Fix <cstdint> include in st_string.h
  • Fix some compiler warnings with newer versions of MSVC and GCC
string_theory - String Theory 3.7

Published by zrax over 1 year ago

  • Fix a clang optimization that would produce incorrect results for ST::string::from_int in Release builds
  • Update GTest to 1.11 to fix issues with newer compilers
    • NOTE: GTest is now included as a git submodule rather than directly in the source tree.
string_theory - String Theory 3.6

Published by zrax over 2 years ago

  • Fix std::filesystem use on MacOS to correctly detect availability based on the target platform's SDK version.
  • Fix ST::string::to_buffer(char_buffer &) always returning Latin-1 data even when UTF-8 was requested.
  • Fix some warnings on GCC 11 and 12.
string_theory - String Theory 3.5

Published by zrax about 3 years ago

  • Add a data() method to ST::string for better STL compatibility/consistency.
  • Add overloads to find(), find_last() and contains() for when the (C-style) substring size is known.
  • Improve performance of some string APIs.
  • Fix ST::buffer<T>::compare and friends to work correctly with non-char buffers.
  • Fix C++ feature detection to not return false negatives when building with -Werror
  • Fix a build failure on GCC 11.
  • Disallow ST::string::view() on temporary (rvalue) objects.
  • Remove the redundant (and undocumented) ST::string::from_literal constructor method.
string_theory - String Theory 3.4

Published by zrax almost 4 years ago

  • Fix ST_WCHAR_LITERAL, ST_UTF16_LITERAL and ST_UTF32_LITERAL macros, which would previously create an incorrectly-sized buffer for non-empty strings.
  • Add ST::buffer<T>::clear() and ST::string::clear() methods
  • Deprecate ST::null and ST::null_t in favor of better alternatives:
    • Construction: Use {} or an explicit constructor (ST::string(), ST::char_buffer())
    • Comparison: Use .empty()
    • Assignment: Use .clear() or assign a default-constructed object.
string_theory - String Theory 3.3

Published by zrax over 4 years ago

  • Add support for }} as an escape sequence for literal } in format strings. This means that formatting a string with escaped literal {} characters can be balanced: ST::format("... {{some-uuid}} ...") => "... {some-uuid} ...".
    • Warning: This is a potentially backwards-incompatible change. If you already have format strings that contain a double }}, they will need to be escaped now (}}}}).
    • Note: There is no behavior change for a single } which is not already part of a format specifier. It will still be written as-is to the output, for backwards compatibility.
  • Remove support for std::experimental::string_view and std::experimental::filesystem in favor of the non-experimental versions.
  • Fix a unit test for compatibility with musl libc.
  • Clean up a few unnecessary includes and no-longer used internal support macros.
  • Fix a few minor issues identified by cppcheck.
  • GCC: Only link to stdc++fs when it is required for using std::filesystem.
string_theory - String Theory 3.2

Published by zrax over 4 years ago

  • Fix std::filesystem::path support in MSVC 2019 when using C++17 instead of C++20.
  • Add more basic conversions (to/from short, long, long long) and deprecate to/from explicit int64 types.
  • Remove some unused config macros.
string_theory - String Theory 3.1

Published by zrax over 4 years ago

Bug fix release:

  • Fix attribute detection so [[nodiscard]] is only used on compilers that support it without a warning.
  • Fix unit tests to not emit warnings on [[nodiscard]] functions.
  • Restore ST::string_stream::operator<<(char) and instead disable the signed char and unsigned char overloads, to help catch places where int8_t and uint8_t might be aliased to something unexpected. 8-bit integers can be streamed by first casting them to the appropriate int type (int or unsigned int).
string_theory - String Theory 3.0

Published by zrax almost 5 years ago

Major Changes

  • String Theory 3.0 is now a header-only library. You still need CMake for configuring st_config.h and building the tests, but after installing it, only the include directory is necessary.
    • Note: For CMake projects, no change is necessary to use 3.0. The provided library is converted to an INTERFACE library which includes the required include directory and removes any linked libs.
  • String Theory 3.0 now requires C++11 at minimum. If you still need support for pre-C++11 compilers, you will need to stay on 2.x.
  • Many parts of String Theory which previously called ST_ASSERT for interface violations have been updated to throw exceptions instead. ST_ASSERT is now reserved only for unrecoverable failures in the library are not due to misuse of the API.
  • Breaking: The default format of individual characters in ST::format and friends is changed to their equivalent integral types, in order to avoid type aliasing issues in some environments. In order to remain compatible with both 2.x and 3.0, callers should use the "{c}" format specifier to explicitly request character formatting.

Changes, Additions, Fixes

  • Moved user-defined literals to the ST::literals namespace to avoid namespace collisions. When porting, you can use using namespace ST::literals; to re-enable their use.
  • Added an _stfmt user-defined literal which can be used for literal format strings. For example:
    "The {} is {}"_stfmt("answer", 42);
  • De-obfuscated the mechanism for declaring custom formatters. The old macros will still work, but new code should declare a format_type overload directly now. See Defining Custom Formatters for details.
  • Conversion between all supported encodings (UTF-8, UTF-16, UTF-32, Latin-1 and wchar_t) is now available outside of the ST::string class, including between encodings which previously did not have any direct conversion available. See the wiki for details.
  • Support basic (case-sensitive) comparison on ST::buffer<T> objects with compare() and operator<().
  • Fix UTF-8 conversions to not skip invalid sequence bytes when converting with substitutes. This behavior matches other UTF-8 implementations, including Python and Qt5.
  • Add more support for STL string classes in ST::format and ST::string_stream (Thanks @Hoikas)
  • Several performance improvements.
  • Several unit testing improvements in both coverage and functionality.

Removed Features

  • APIs marked deprecated in 2.0 are now removed.
  • ST::set_assert_handler and ST::set_default_assert_handler were removed since ST_ASSERT is no longer used for interface violations.
  • ST::utf_validation_t::assert_validity is removed since it no longer makes any sense.
  • Removed implicit conversions to std::string_view.
string_theory - String Theory 2.4

Published by zrax almost 5 years ago

  • Allow the user to explicitly specify a C++ standard to build against with -DST_CXX_STANDARD=NN. The default is latest, which matches the previous behavior to detect and use the latest standard supported by the compiler.
  • Allow std::filesystem support to be enabled/disabled independently of std::string support.
    • This removes the ST_NO_STL_STRINGS CMake flag and adds ST_ENABLE_STL_STRINGS and ST_ENABLE_STL_FILESYSTEM in its place. The default for both settings is ON.
  • Fix some build issues with older compilers.
  • Fix support for latest MSVC2019 updates.
  • Optimize string/buffer moves, and provide better exception safety in buffer copies.
string_theory - String Theory 2.3

Published by zrax almost 5 years ago

  • Fix char8_t and std::u8string detection when the compiler supports it but the selected C++ standard does not.
  • Fix a potential infinite loop when substituting bad UTF-8 sequences in ST::string.
  • Add c_str() methods to ST::buffer<T>.
  • Add _stbuf user literal operator and ST_(CHAR|WCHAR|UTF16|UTF32)_LITERAL macros.
  • Improve performance of ST::format and friends when formatting floating point values.
  • Apply forwarding of ST::format and friends format arguments to reduce copying.
string_theory - String Theory 2.2

Published by zrax over 5 years ago

  • Use /std:c++latest on MSVC 2017 and 2019 (#10)
  • Fix incorrect bitmask when decoding UTF-16 surrogate pairs.
  • Multiple performance improvements for string comparisons
  • Support the use of std::experimental:: versions of std::filesystem and std::string_view in parallel with the non-experimental versions where possible.
  • Add ST::string::set_validated() and ST::string::from_validated() as a faster alternative to construction with ST::assume_valid.
  • Add support for C++20 char8_t and std::u8string types
string_theory - String Theory 2.1

Published by zrax over 6 years ago

  • Fix major bug in ST::buffer<T>::operator==() and ST::buffer<T>::allocate(size, fill) for types of T larger than char.
  • Fix ST::string_stream::operator<<() for float and double not actually writing the value to the stream.
  • Fix potential undefined behavior formatting -(MAX_*) integers.
  • Add more unit tests for the fixed cases and others.
  • Slight performance improvement for simple integer formatters.
  • Guarantee case insensitive conversions and comparisons occur in the "C" locale.
  • Remove <cstring> include from public headers.
string_theory - String Theory 1.8

Published by zrax over 6 years ago

  • Fix major bug in ST::buffer<T>::operator==() for types of T larger than char.
  • Fix ST::string_stream::operator<<() for float and double not actually writing the value to the stream.
  • Add more unit tests.
string_theory - String Theory 2.0

Published by zrax almost 7 years ago

  • Add support for reordering and reusing format parameters as "{&1}" in formatting functions.
  • Add support for std::string_view and friends.
  • Rename is_empty to empty and char_at to at for better compatibility with STL.
    Note that the old names are still available, but will show a deprecation warning unless ST_NO_2_0_DEPRECATION is defined.
  • Add STL-style iterator methods, including back, front, [c|r]begin, [c|r]end and necessary typedefs.
  • Add ST::writef for STL-style (std::ostream-derived) streams.
  • Add operator<< and operator>> overloads for using ST::string with STL-style streams.
  • Simplified the necessary overhead for creating new formatting functions.
  • Change buffer classes to be writable (but not resizable) for easier construction and manipulation as buffers.
    Note that create_writable_buffer is still available, but will show a deprecation warning unless ST_NO_2_0_DEPRECATION is defined.
  • Optimized several parts of string_theory for better performance, especially around string construction, character access, and encoding conversions.
  • Fix UTF-16 invalid surrogate pair replacements producing non-canonical results.
  • Moved documentation to the Github wiki and cleaned it up for easier maintenance and use.
string_theory - String Theory 1.7

Published by zrax almost 7 years ago

  • Add more support for char16_t and char32_t string literals and conversions.
  • Add support for std::u16string and std::u32string from C++11
  • Optimize ST::string::c_str() for the most common use case (no alternate string)
  • Fix ST::hash_i to correctly hash case-insensitively
  • Add explicit std::hash specialization for ST::string for easier use in STL containers
  • Fix compile issues on GCC 4.4 (CentOS/RHEL 6)
  • Fix tests on MSVC 2017
string_theory - String Theory 1.6

Published by zrax over 7 years ago

  • Add operator+ and operator+= overloads to ST::string to append/prepend individual characters.
  • Add find and find_last overloads that take a starting and ending position, respectively.
  • Add support for gcov/lcov coverage analysis in the test suite.
string_theory - String Theory 1.5

Published by zrax over 7 years ago

  • Fix for exceptions thrown in the ST::string move constructor destroying the original data too early (#5)
string_theory - String Theory 1.4

Published by zrax over 7 years ago

  • Allow ST::printf to be called with 0 formattable arguments (e.g. ST::printf("Hello\n");)
  • Fix ST::hex_encode to output lower-case hex, as per the documentation.
  • Fix hard-coded paths in generated CMake files so installs are relocatable.

NOTE: Minimum CMake version is now 2.8.12.

string_theory - string_theory 1.3

Published by zrax almost 8 years ago

  • Fix several warnings in CMake and newer MSVC++ versions
  • Allow a NULL data pointer in ST::base64_encode and ST::hex_encode iff size == 0