26#include "iceberg/iceberg_export.h"
27#include "iceberg/result.h"
42 size_t code_point_count = 0;
43 size_t safe_point = 0;
45 for (
size_t i = 0; i < source.size(); ++i) {
47 if ((source[i] & 0xC0) != 0x80) {
49 if (code_point_count >
static_cast<size_t>(L)) {
56 if (safe_point != 0) {
58 source.resize(safe_point);
76 static Result<std::string> TruncateUTF8Max(
const std::string& source,
size_t L);
83 requires std::is_same_v<T, int32_t> || std::is_same_v<T, int64_t>
85 return v - (((v % W) + W) % W);
92 static Decimal TruncateDecimal(
const Decimal& decimal, int32_t width);
102 static Result<Literal> TruncateLiteral(
const Literal& literal, int32_t width);
115 static Result<Literal> TruncateLiteralMax(
const Literal& value, int32_t width);
Represents 128-bit fixed-point decimal numbers. The max decimal precision that can be safely represen...
Definition decimal.h:46
Literal is a literal value that is associated with a primitive type.
Definition literal.h:39
Definition truncate_util.h:32
static T TruncateInteger(T v, int32_t W)
Truncate an integer v, either int32_t or int64_t, to v - (v % W).
Definition truncate_util.h:84
static std::string TruncateUTF8(std::string source, size_t L)
Truncate a UTF-8 string to a specified number of code points.
Definition truncate_util.h:41