is_hex() is a bit misleading as from_hex() requires an even-length hex string, but is_hex() also allows odd-length hex strings, which means currently callers should be doing if (lokimq::is_hex(str) && str.size() % 2 == 0), but probably aren't.
Since the main point of lokimq/hex.h is for byte<->hex conversions it doesn't make much sense to allow is_hex() to return true for something that can't be validly decoded via from_hex(), thus this PR changes it to return false.
If someone really wants to test for an odd-length hex string, this also exposes is_hex_digit so that they could use:
is_hex()
is a bit misleading asfrom_hex()
requires an even-length hex string, butis_hex()
also allows odd-length hex strings, which means currently callers should be doingif (lokimq::is_hex(str) && str.size() % 2 == 0)
, but probably aren't.Since the main point of
lokimq/hex.h
is for byte<->hex conversions it doesn't make much sense to allowis_hex()
to return true for something that can't be validly decoded viafrom_hex()
, thus this PR changes it to return false.If someone really wants to test for an odd-length hex string, this also exposes
is_hex_digit
so that they could use: