MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / SubstringImpl

Function SubstringImpl

common/values/string_value.cc:600–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598namespace {
599
600absl::StatusOr<size_t> SubstringImpl(absl::string_view string, uint64_t start) {
601 size_t size_code_points = 0;
602 size_t size_code_units = 0;
603 while (!string.empty()) {
604 char32_t code_point;
605 size_t code_units;
606 std::tie(code_point, code_units) = cel::internal::Utf8Decode(string);
607 if (size_code_points == start) {
608 return size_code_units;
609 }
610 string.remove_prefix(code_units);
611 ++size_code_points;
612 size_code_units += code_units;
613 }
614 if (size_code_points == start) {
615 return size_code_units;
616 }
617 return absl::InvalidArgumentError(
618 "<string>.substring(<start>): <start> is greater than <string>.size()");
619}
620
621absl::StatusOr<absl::Cord> SubstringImpl(const absl::Cord& cord,
622 uint64_t start) {

Callers

nothing calls this directly

Calls 2

Utf8DecodeFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected