Flexible modern C++ string library with type-safe formatting
MIT License
Bot releases are hidden (Show)
find
and related operations, which could read past the end of the string in certain cases.<cstdint>
include in st_string.h
Published by zrax over 1 year ago
ST::string::from_int
in Release buildsPublished by zrax over 2 years ago
std::filesystem
use on MacOS to correctly detect availability based on the target platform's SDK version.ST::string::to_buffer(char_buffer &)
always returning Latin-1 data even when UTF-8 was requested.Published by zrax about 3 years ago
data()
method to ST::string
for better STL compatibility/consistency.find()
, find_last()
and contains()
for when the (C-style) substring size is known.ST::buffer<T>::compare
and friends to work correctly with non-char
buffers.-Werror
ST::string::view()
on temporary (rvalue) objects.ST::string::from_literal
constructor method.Published by zrax almost 4 years ago
ST_WCHAR_LITERAL
, ST_UTF16_LITERAL
and ST_UTF32_LITERAL
macros, which would previously create an incorrectly-sized buffer for non-empty strings.ST::buffer<T>::clear()
and ST::string::clear()
methodsST::null
and ST::null_t
in favor of better alternatives:
{}
or an explicit constructor (ST::string()
, ST::char_buffer()
).empty()
.clear()
or assign a default-constructed object.Published by zrax over 4 years ago
}}
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} ..."
.
}}
, they will need to be escaped now (}}}}
).}
which is not already part of a format specifier. It will still be written as-is to the output, for backwards compatibility.std::experimental::string_view
and std::experimental::filesystem
in favor of the non-experimental versions.stdc++fs
when it is required for using std::filesystem
.Published by zrax over 4 years ago
std::filesystem::path
support in MSVC 2019 when using C++17 instead of C++20.Published by zrax over 4 years ago
Bug fix release:
[[nodiscard]]
is only used on compilers that support it without a warning.[[nodiscard]]
functions.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
).Published by zrax almost 5 years ago
Major Changes
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.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
ST::literals
namespace to avoid namespace collisions. When porting, you can use using namespace ST::literals;
to re-enable their use._stfmt
user-defined literal which can be used for literal format strings. For example:"The {} is {}"_stfmt("answer", 42);
format_type
overload directly now. See Defining Custom Formatters for details.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.ST::buffer<T>
objects with compare()
and operator<()
.ST::format
and ST::string_stream
(Thanks @Hoikas)Removed Features
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.std::string_view
.Published by zrax almost 5 years ago
-DST_CXX_STANDARD=NN
. The default is latest
, which matches the previous behavior to detect and use the latest standard supported by the compiler.std::filesystem
support to be enabled/disabled independently of std::string
support.
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
.Published by zrax almost 5 years ago
char8_t
and std::u8string
detection when the compiler supports it but the selected C++ standard does not.ST::string
.c_str()
methods to ST::buffer<T>
._stbuf
user literal operator and ST_(CHAR|WCHAR|UTF16|UTF32)_LITERAL
macros.ST::format
and friends when formatting floating point values.ST::format
and friends format arguments to reduce copying.Published by zrax over 5 years ago
/std:c++latest
on MSVC 2017 and 2019 (#10)std::experimental::
versions of std::filesystem
and std::string_view
in parallel with the non-experimental versions where possible.ST::string::set_validated()
and ST::string::from_validated()
as a faster alternative to construction with ST::assume_valid
.char8_t
and std::u8string
typesPublished by zrax over 6 years ago
ST::buffer<T>::operator==()
and ST::buffer<T>::allocate(size, fill)
for types of T
larger than char
.ST::string_stream::operator<<()
for float and double not actually writing the value to the stream.<cstring>
include from public headers.Published by zrax over 6 years ago
ST::buffer<T>::operator==()
for types of T
larger than char
.ST::string_stream::operator<<()
for float and double not actually writing the value to the stream.Published by zrax almost 7 years ago
"{&1}"
in formatting functions.std::string_view
and friends.is_empty
to empty
and char_at
to at
for better compatibility with STL.ST_NO_2_0_DEPRECATION
is defined.back
, front
, [c|r]begin
, [c|r]end
and necessary typedefs.ST::writef
for STL-style (std::ostream
-derived) streams.operator<<
and operator>>
overloads for using ST::string
with STL-style streams.create_writable_buffer
is still available, but will show a deprecation warning unless ST_NO_2_0_DEPRECATION
is defined.Published by zrax almost 7 years ago
std::u16string
and std::u32string
from C++11ST::string::c_str()
for the most common use case (no alternate string)ST::hash_i
to correctly hash case-insensitivelystd::hash
specialization for ST::string
for easier use in STL containersPublished by zrax over 7 years ago
operator+
and operator+=
overloads to ST::string
to append/prepend individual characters.find
and find_last
overloads that take a starting and ending position, respectively.Published by zrax over 7 years ago
ST::string
move constructor destroying the original data too early (#5)Published by zrax over 7 years ago
ST::printf
to be called with 0 formattable arguments (e.g. ST::printf("Hello\n");
)ST::hex_encode
to output lower-case hex, as per the documentation.NOTE: Minimum CMake version is now 2.8.12.
Published by zrax almost 8 years ago
ST::base64_encode
and ST::hex_encode
iff size == 0