MCPcopy Create free account
hub / github.com/apple/foundationdb / appendField

Function appendField

fdbrpc/TokenSign.cpp:209–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208template <class FieldType, size_t NameLen>
209void appendField(fmt::memory_buffer& b, char const (&name)[NameLen], Optional<FieldType> const& field) {
210 if (!field.present())
211 return;
212 auto const& f = field.get();
213 auto bi = std::back_inserter(b);
214 if constexpr (std::is_same_v<FieldType, VectorRef<StringRef>>) {
215 fmt::format_to(bi, " {}=[", name);
216 for (auto i = 0; i < f.size(); i++) {
217 if (i)
218 fmt::format_to(bi, ",");
219 fmt::format_to(bi, f[i].toStringView());
220 }
221 fmt::format_to(bi, "]");
222 } else if constexpr (std::is_same_v<FieldType, StringRef>) {
223 fmt::format_to(bi, " {}={}", name, f.toStringView());
224 } else {
225 fmt::format_to(bi, " {}={}", name, f);
226 }
227}
228
229StringRef TokenRef::toStringRef(Arena& arena) {
230 auto buf = fmt::memory_buffer();

Callers 1

toStringRefMethod · 0.85

Calls 5

toStringViewMethod · 0.80
getMethod · 0.65
format_toFunction · 0.50
presentMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected