to_string
Functions that will render a text representation of bools, integrals, floating point, strings, string views and pointers.
It will convert to any of the ETL string types.
____________________________________________________________________________________________________
Default format specification
template <typename T>
const etl::istring& to_string(const T value,
etl::istring& str,
const bool append = false)
template <typename T>
const etl::iwstring& to_string(const T value,
etl::iwstring& str,
const bool append = false)
template <typename T>
const etl::iu16string& to_string(const T value,
etl::iu16string& str,
const bool append = false)
template <typename T>
const etl::iu32string& to_string(const T value,
etl::iu32string& str,
const bool append = false)
value The value to convert to a string.
str The string in with to place the rendered text.
append If true then appends the text to the current string's content. Default false.
____________________________________________________________________________________________________
Supplied format specification
template <typename T>
const etl::istring& to_string(const T value,
etl::istring& str,
const etl::format_spec& format,
const bool append = false)
template <typename T>
const etl::iwstring& to_string(const T value,
etl::iwstring& str,
const etl::wformat_spec& format,
const bool append = false)
template <typename T>
const etl::iu16string& to_string(const T value,
etl::iu16string& str,
const etl::ui16format_spec& format,
const bool append = false)
template <typename T>
const etl::iu32string& to_string(const T value,
etl::iu32string& str,
const etl::u32format_spec& format,
const bool append = false)
value The value to convert to a string.
str The string in with to place the rendered text.
format The format specification.
append If true then appends the text to the current string's content. Default false.
____________________________________________________________________________________________________
Examples
etl::format_spec format;
// Format as a hex character, minimum fill width of 8, fill with zeros.
format.hex().width(8).fill('0');
etl::string<8> text;
// 'text' is set to "00123456"
etl::to_string(1193046, text, format);
____________________________________________________________________________________________________
etl::format_spec format;
// Format minimum fill width of 8, fill with space and three decimal digits.
format.width(8).fill(' ').precision(3);
etl::string<8> text;
// 'text' is set to " 3.142"
etl::to_string(3.1415, text, format);
____________________________________________________________________________________________________
etl::string<19> text = "The result is ";
etl::to_string(3.1415, text, etl::format_spec().precision(3), true);
// 'text' is set to "The result is 3.142"