MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / to_string

Function to_string

src/audio/base/Utils.h:96–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95template <typename T>
96auto to_string(const T& num, const std::string def = "0") -> std::string {
97 // This is used to replace `std::to_string` as a locale independent
98 // number conversion using `std::to_chars`.
99 // An additional string parameter could be eventually provided with a
100 // default value to return in case the conversion fails.
101
102 // Max buffer length:
103 // number of base-10 digits that can be represented by the type T without change +
104 // number of base-10 digits that are necessary to uniquely represent all distinct
105 // values of the type T (meaningful only for real numbers) +
106 // room for other characters such as "+-e,."
107 const size_t max = std::numeric_limits<T>::digits10 + std::numeric_limits<T>::max_digits10 + 10U;
108
109 std::array<char, max> buffer;
110
111 const auto p_init = buffer.data();
112
113 const auto result = std::to_chars(p_init, p_init + max, num);
114
115 return (result.ec == std::errc()) ? std::string(p_init, result.ptr - p_init) : def;
116}
117
118
119} // namespace util

Callers 15

label_update_threadFunction · 0.85
connect_filtersMethod · 0.85
on_destroy_node_proxyFunction · 0.85
on_node_infoFunction · 0.85
on_metadata_propertyFunction · 0.85
on_registry_globalFunction · 0.85
PwPipelineManagerMethod · 0.85
link_nodesMethod · 0.85
statusMethod · 0.85
updateFirEqualizerMethod · 0.85
updateCompanderMethod · 0.85

Calls 1

dataMethod · 0.45

Tested by

no test coverage detected