in blogs/sept-2021/converter.cc [198:233]
FieldValue Converter::ConvertSpecialValue(
const std::map<Variant, Variant>& from) const {
// Special values are Firestore entities encoded as maps because they are not
// directly supported by `Variant`. The assumption is that the map contains
// a boolean field "special" set to true and a string field "type" indicating
// which kind of an entity it contains.
std::string type = TryGetString(from, "type");
if (type.empty()) {
return {};
}
if (type == "timestamp") {
Timestamp result(TryGetInteger(from, "seconds"),
TryGetInteger(from, "nanoseconds"));
return FieldValue::Timestamp(result);
} else if (type == "geo_point") {
GeoPoint result(TryGetDouble(from, "latitude"),
TryGetDouble(from, "longitude"));
return FieldValue::GeoPoint(result);
} else if (type == "document_reference") {
DocumentReference result =
firestore_->Document(TryGetString(from, "document_path"));
return FieldValue::Reference(result);
} else if (type == "delete") {
return FieldValue::Delete();
} else if (type == "server_timestamp") {
return FieldValue::ServerTimestamp();
}
return {};
}