iceberg-cpp
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
iceberg::StringUtils Class Reference

Static Public Member Functions

static std::string ToLower (std::string_view str)
 Lower-case a UTF-8 string using Unicode simple (1:1) case mapping.
 
static std::string ToUpper (std::string_view str)
 Upper-case the ASCII letters (a-z) in a string; all other bytes, including multi-byte UTF-8 sequences, are left unchanged.
 
static bool EqualsIgnoreCase (std::string_view lhs, std::string_view rhs)
 Case-insensitive equality using Unicode simple (1:1) case mapping.
 
static bool StartsWithIgnoreCase (std::string_view str, std::string_view prefix)
 Case-insensitive prefix test using Unicode simple (1:1) case mapping.
 
static size_t CodePointCount (std::string_view str)
 Count the number of code points in a UTF-8 string.
 
template<typename T >
requires std::is_arithmetic_v<T> && FromChars<T> && (!std::same_as<T, bool>)
static Result< T > ParseNumber (std::string_view str)
 
static Result< std::vector< uint8_t > > HexStringToBytes (std::string_view hex)
 Decode a hex string (upper or lower case) into bytes. Returns an error if the string has odd length or contains invalid hex characters.
 
template<typename T >
requires std::is_floating_point_v<T> && (!FromChars<T>)
static Result< T > ParseNumber (std::string_view str)
 

Member Function Documentation

◆ EqualsIgnoreCase()

static bool iceberg::StringUtils::EqualsIgnoreCase ( std::string_view  lhs,
std::string_view  rhs 
)
inlinestatic

Case-insensitive equality using Unicode simple (1:1) case mapping.

Equal when the ToLower forms of both operands are equal, so folding follows ToLower's rules (e.g. "İ" (U+0130) folds to "i"). Defined for any byte sequence: ToLower passes invalid UTF-8 bytes through unchanged, so they compare verbatim.

◆ StartsWithIgnoreCase()

static bool iceberg::StringUtils::StartsWithIgnoreCase ( std::string_view  str,
std::string_view  prefix 
)
inlinestatic

Case-insensitive prefix test using Unicode simple (1:1) case mapping.

True when the ToLower form of str starts with the ToLower form of prefix, so folding follows ToLower's rules (e.g. "İ" (U+0130) folds to "i"). Defined for any byte sequence: ToLower passes invalid UTF-8 bytes through unchanged, so they compare verbatim.

◆ ToLower()

static std::string iceberg::StringUtils::ToLower ( std::string_view  str)
static

Lower-case a UTF-8 string using Unicode simple (1:1) case mapping.

Intended for case-insensitive name matching, similar to Iceberg Java's toLowerCase(Locale.ROOT). The mapping is locale-independent, matching the intent of Locale.ROOT. It uses simple (1:1) case mapping rather than Java's full case mapping, so results differ for a few code points; e.g. U+0130 (capital I with dot above) maps to U+0069 ("i") here, but to U+0069 U+0307 ("i" + combining dot above) in Java. For ASCII and the large majority of letters the two agree.

Pure-ASCII input takes a byte-wise fast path; utf8proc is only invoked when a non-ASCII byte (>= 0x80) is present. The function is total: it never fails, and input need not be valid UTF-8. A byte that does not begin a valid UTF-8 sequence is copied through unchanged and decoding resumes at the next byte, so the valid code points around it are still lower-cased. See https://github.com/apache/iceberg-cpp/issues/613.

◆ ToUpper()

static std::string iceberg::StringUtils::ToUpper ( std::string_view  str)
inlinestatic

Upper-case the ASCII letters (a-z) in a string; all other bytes, including multi-byte UTF-8 sequences, are left unchanged.

Deliberately ASCII-only and, unlike ToLower, not Unicode-aware. It is only used to normalize ASCII enum/codec strings (e.g. "gzip" -> "GZIP", "all" -> "ALL") for case-insensitive comparison. A Unicode upper-case is intentionally not provided: simple case mapping would be wrong for some letters (e.g. "ß" (U+00DF) would stay unchanged instead of becoming "SS"), and no caller needs it.


The documentation for this class was generated from the following file: