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

Function FormatList

extensions/formatting.cc:137–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137absl::StatusOr<absl::string_view> FormatList(
138 const Value& value,
139 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
140 google::protobuf::MessageFactory* absl_nonnull message_factory,
141 google::protobuf::Arena* absl_nonnull arena,
142 std::string& scratch ABSL_ATTRIBUTE_LIFETIME_BOUND) {
143 CEL_ASSIGN_OR_RETURN(auto it, value.GetList().NewIterator());
144 scratch.clear();
145 scratch.push_back('[');
146 std::string value_scratch;
147
148 while (it->HasNext()) {
149 CEL_ASSIGN_OR_RETURN(auto next,
150 it->Next(descriptor_pool, message_factory, arena));
151 absl::string_view next_str;
152 value_scratch.clear();
153 CEL_ASSIGN_OR_RETURN(
154 next_str, FormatString(next, descriptor_pool, message_factory, arena,
155 value_scratch));
156 absl::StrAppend(&scratch, next_str);
157 absl::StrAppend(&scratch, ", ");
158 }
159 if (scratch.size() > 1) {
160 scratch.resize(scratch.size() - 2);
161 }
162 scratch.push_back(']');
163 return scratch;
164}
165
166absl::StatusOr<absl::string_view> FormatMap(
167 const Value& value,

Callers 1

FormatStringFunction · 0.85

Calls 5

FormatStringFunction · 0.85
clearMethod · 0.80
CEL_ASSIGN_OR_RETURNFunction · 0.50
HasNextMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected