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

Function putField

fdbrpc/TokenSign.cpp:246–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244
245template <class FieldType, class Writer>
246void putField(Optional<FieldType> const& field, Writer& wr, const char* fieldName) {
247 if (!field.present())
248 return;
249 wr.Key(fieldName);
250 auto const& value = field.get();
251 static_assert(std::is_same_v<StringRef, FieldType> || std::is_same_v<FieldType, uint64_t> ||
252 std::is_same_v<FieldType, VectorRef<StringRef>>);
253 if constexpr (std::is_same_v<StringRef, FieldType>) {
254 wr.String(reinterpret_cast<const char*>(value.begin()), value.size());
255 } else if constexpr (std::is_same_v<FieldType, uint64_t>) {
256 wr.Uint64(value);
257 } else {
258 wr.StartArray();
259 for (auto elem : value) {
260 wr.String(reinterpret_cast<const char*>(elem.begin()), elem.size());
261 }
262 wr.EndArray();
263 }
264}
265
266StringRef makeTokenPart(Arena& arena, TokenRef tokenSpec) {
267 using Buffer = rapidjson::StringBuffer;

Callers 1

makeTokenPartFunction · 0.70

Calls 9

getMethod · 0.65
presentMethod · 0.45
KeyMethod · 0.45
StringMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
Uint64Method · 0.45
StartArrayMethod · 0.45
EndArrayMethod · 0.45

Tested by

no test coverage detected