template <typename string_type_>
struct string_view_for The C++ layer is built on the types below plus a 256-bit byteset.
sz::string_slice<char_type>— a non-owning, length-bounded view overcharorchar const. Two aliases exist: the read-onlysz::string_view_t = string_slice<char const>and the mutablesz::string_span_t = string_slice<char>.sz::string<allocator = std::allocator<char>>— an owning, Small-String-Optimizedcharcontainer; the aliassz::string_tuses the defaultstd::allocator. A stateful allocator travels with the string under the usualstd::allocator_traitspropagation rules, and an empty one costs no bytes.sz::strings_view_t— a non-owning column of strings, wrapping asz_strings_view_tin any of its layouts.sz::strings<allocator = sz::heap_alloc<char>>— an owned, move-only column, asz_strings_span_ttape and the allocator of its blocks; the aliassz::strings_tuses the default.sz::byteset_t— the C++ wrapper aroundsz_byteset_t, constructible from an initializer list, a(pointer, count)pair, or astd::array, and composable withoperator|.sz::status_t— a scoped enum mirroringsz_status_twithsuccess_k,bad_alloc_k,invalid_utf8_k,contains_duplicates_k, and the rest, returned by the fallible free functions and the string’s allocating verbs.
sz::string_view_t is implicitly constructible from a char const *, a (pointer, length) pair, std::string, and std::string_view, and converts back to both; sz::string_t::make builds an owning string from a view or a lazy sz::concatenate(...) expression, and copy() duplicates one, both returning an sz::expected.
Both keep the std::string/std::string_view members no kernel backs — data, size, length, empty, at, front, back, iterators, substr, compare, the relational operators, and operator<=>, which order bytes through std::char_traits.
Both also stream through operator<<, and <stringzilla/hash.hpp> specializes std::hash<sz::string_t> / std::hash<sz::string_view_t>, so they work as unordered-container keys.
Every operation a kernel of the library backs is a free function taking any string, from StringZilla and STL strings to string literals, and its member spelling is deleted, with a comment naming the function.
These members are gone, each replaced by the free function of the same name with the string first, like sz::find(text, "x") for text.find("x"):
find,rfind,contains,count,find_first_of,find_first_not_of,find_last_of,find_last_not_of,contains_only, theis_alphafamily,partition,rpartition,lstrip,rstrip,strip,find_all,rfind_all,splitandrsplitin<stringzilla/find.hpp>, wheresplit(byteset)issz::split_charactersandsplitlines()issz::split_characters(text, sz::newlines_set());starts_with,ends_with, and the matchingremove_prefixandremove_suffixin<stringzilla/compare.hpp>;hash,hash_multiseed,bytesumandfill_randomin<stringzilla/hash.hpp>, withsz::hash_tand thestd::hashspecializations;utf8_count,utf8_seek,utf8_runesand the otherutf8_*ranges in<stringzilla/utf8_runes.hpp>and its siblings;utf8_find_denormalized,is_normalized,utf8_normalize,utf8_uncased_*andutf8_uncased_foldin<stringzilla/utf8_norm.hpp>and<stringzilla/utf8_uncased.hpp>;replace_allin<stringzilla/find.hpp>, andlookupin<stringzilla/strings_verbs.hpp>, both taking the string to change in place;- the column members
find,hashes,utf8_count,to_rows,gather,escape,unescape,lookup,normalizeandjoinin<stringzilla/strings_verbs.hpp>, wherestrings::splitissz::split_intoandstrings::split_linesissz::split_lines.
A verb over the default mask returns its plain result, and the overload taking an explicit capability mask and stream returns an sz::expected.
The lazy ranges keep only views, so they take lvalues and borrowed views, and refuse an owning temporary like std::string("a b") at compile time.
User-defined literals live in sz::literals:
using namespace sz::literals;
sz::string_view_t v = "needle"_sv; // a view, no allocation
sz::byteset_t s = " \t\n\r"_bs; // a byte-set from a literalConvenience byte-sets are available as free functions: sz::whitespaces_set(), sz::newlines_set(), sz::digits_set(), sz::hexdigits_set(), sz::octdigits_set(), and sz::ascii_letters_set().