/* * Copyright 2024 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
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) { return rtc::ToString(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], arraysize(buf), "%.16g", static_cast<double>(value));
RTC_DCHECK_LE(len, arraysize(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.