slang/util/String.h file

Various string utilities.

Namespaces

namespace slang
Root namespace.

Functions

auto toStringView(std::span<char> text) -> std::string_view
Converts a span of characters into a std::string_view.
void uintToStr(SmallVectorBase<char>& buffer, uint32_t value)
Converts the provided value into a string, storing it into buffer.
void uintToStr(SmallVectorBase<char>& buffer, uint64_t value)
Converts the provided value into a string, storing it into buffer.
auto strToInt(std::string_view str, size_t* pos = nullptr, int base = 10) -> std::optional<int32_t>
Parses the provided str in the specified base into a signed integer.
auto strToUInt(std::string_view str, size_t* pos = nullptr, int base = 10) -> std::optional<uint32_t>
Parses the provided str in the specified base into an unsigned integer.
auto strToDouble(std::string_view str, size_t* pos = nullptr) -> std::optional<double>
Parses the provided str into a floating point value.
void strToUpper(std::string& str)
Converts the provided string to all uppercase characters (assuming ASCII contents).
void strToLower(std::string& str)
Converts the provided string to all lowercase characters (assuming ASCII contents).
auto charToUpper(char c) -> char
Converts a character to uppercase (assuming ASCII).
auto charToLower(char c) -> char
Converts a character to lowercase (assuming ASCII).
auto editDistance(std::string_view left, std::string_view right, bool allowReplacements = true, int maxDistance = 0) -> int
Determines the number of edits to the left string that are required to change it into the right string.
auto getU8Str(const std::filesystem::path& path) -> const std::string&
Gets a string representation of the given path, in UTF-8 encoding.