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

Method ToString

common/source.cc:90–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90std::string SourceContentView::ToString(SourcePosition begin,
91 SourcePosition end) const {
92 ABSL_DCHECK_GE(begin, 0);
93 ABSL_DCHECK_LE(end, size());
94 ABSL_DCHECK_LE(begin, end);
95 return absl::visit(
96 absl::Overload(
97 [begin = static_cast<size_t>(begin),
98 end = static_cast<size_t>(end)](absl::Span<const char> view) {
99 view = view.subspan(begin, end - begin);
100 return std::string(view.data(), view.size());
101 },
102 [begin = static_cast<size_t>(begin),
103 end = static_cast<size_t>(end)](absl::Span<const uint8_t> view) {
104 view = view.subspan(begin, end - begin);
105 std::string result;
106 result.reserve(view.size() * 2);
107 for (const auto& code_point : view) {
108 internal::Utf8Encode(result, code_point);
109 }
110 result.shrink_to_fit();
111 return result;
112 },
113 [begin = static_cast<size_t>(begin),
114 end = static_cast<size_t>(end)](absl::Span<const char16_t> view) {
115 view = view.subspan(begin, end - begin);
116 std::string result;
117 result.reserve(view.size() * 3);
118 for (const auto& code_point : view) {
119 internal::Utf8Encode(result, code_point);
120 }
121 result.shrink_to_fit();
122 return result;
123 },
124 [begin = static_cast<size_t>(begin),
125 end = static_cast<size_t>(end)](absl::Span<const char32_t> view) {
126 view = view.subspan(begin, end - begin);
127 std::string result;
128 result.reserve(view.size() * 4);
129 for (const auto& code_point : view) {
130 internal::Utf8Encode(result, code_point);
131 }
132 result.shrink_to_fit();
133 return result;
134 }),
135 view_);
136}
137
138void SourceContentView::AppendToString(std::string& dest) const {
139 absl::visit(absl::Overload(

Callers 15

getTextMethod · 0.45
toStringMethod · 0.45
operator()Method · 0.45
ExportAsProtoValueFunction · 0.45
operator[]Method · 0.45
GetConstantStringMethod · 0.45
CheckForMarkedAttributesFunction · 0.45
SelectStepMethod · 0.45
DirectSelectStepMethod · 0.45

Calls 3

sizeFunction · 0.70
Utf8EncodeFunction · 0.50
sizeMethod · 0.45

Tested by 14

TESTFunction · 0.36
AddFatalFailureFunction · 0.36
Hello1Function · 0.36
Hello2Function · 0.36
TESTFunction · 0.36
MatchAndExplainMethod · 0.36
TEST_PFunction · 0.36
TEST_PFunction · 0.36
TEST_PFunction · 0.36
TEST_PFunction · 0.36
TESTFunction · 0.36