struct VisitIsSequence { // Any type of vector is a sequence. template <typename T> booloperator()(const std::optional<std::vector<T>>* attribute) { returntrue;
} // Any other type is not. template <typename T> booloperator()(const std::optional<T>* attribute) { returnfalse;
}
};
// Converts the attribute to string in a JSON-compatible way. struct VisitToString { template <typename T, typename std::enable_if_t<
std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t> ||
std::is_same_v<T, bool> || std::is_same_v<T, std::string>, bool> = true>
std::string ValueToString(const T& value) { if constexpr (std::is_same_v<T, bool>) { return BoolToString(value);
} return absl::StrCat(value);
}
// Convert 64-bit integers to doubles before converting to string because JSON // represents all numbers as floating points with ~15 digits of precision. template <typename T, typename std::enable_if_t<std::is_same_v<T, int64_t> ||
std::is_same_v<T, uint64_t> ||
std::is_same_v<T, double>, bool> = true>
std::string ValueToString(const T& value) { char buf[32]; constint len = std::snprintf(&buf[0], std::size(buf), "%.16g", static_cast<double>(value));
RTC_DCHECK_LE(len, std::ssize(buf)); return std::string(&buf[0], len);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.