31#ifndef ETL_TO_STRING_HELPER_INCLUDED
32#define ETL_TO_STRING_HELPER_INCLUDED
36#include "../platform.h"
37#include "../absolute.h"
38#include "../negative.h"
39#include "../basic_format_spec.h"
40#include "../type_traits.h"
41#include "../container.h"
42#include "../absolute.h"
43#include "../algorithm.h"
44#include "../iterator.h"
49#if ETL_USING_STL && ETL_USING_CPP11
55 namespace private_to_string
57#if ETL_NOT_USING_64BIT_TYPES
58 typedef int32_t workspace_t;
59 typedef uint32_t uworkspace_t;
61 typedef int64_t workspace_t;
62 typedef uint64_t uworkspace_t;
68 template <
typename TIString>
73 if (length <
format.get_width())
93 template <
typename TIString>
99 typedef typename TIString::value_type type;
100 typedef typename TIString::iterator
iterator;
102 static const type t[] = {
't',
'r',
'u',
'e' };
103 static const type
f[] = {
'f',
'a',
'l',
's',
'e' };
112 if (
format.is_boolalpha())
116 str.insert(str.end(), ETL_OR_STD11::begin(t), ETL_OR_STD11::end(t));
120 str.insert(str.end(), ETL_OR_STD11::begin(
f), ETL_OR_STD11::end(
f));
127 str.push_back(type(
'1'));
131 str.push_back(type(
'0'));
141 template <
typename T,
typename TIString>
148 typedef typename TIString::value_type type;
149 typedef typename TIString::iterator
iterator;
163 str.push_back(type(
'-'));
166 str.push_back(type(
'0'));
175 value = value /
T(
format.get_base());
181 str.push_back(type(
'-'));
184 if (
format.is_show_base())
186 switch (
format.get_base())
190 str.push_back(
format.is_upper_case() ? type(
'B') : type(
'b'));
191 str.push_back(type(
'0'));
197 str.push_back(type(
'0'));
203 str.push_back(
format.is_upper_case() ? type(
'X') : type(
'x'));
204 str.push_back(type(
'0'));
216 etl::reverse(start, str.end());
225 template <
typename TIString>
230 typedef typename TIString::value_type type;
232 static const type
n[] = {
'n',
'a',
'n' };
233 static const type
i[] = {
'i',
'n',
'f' };
237 str.insert(str.end(), ETL_OR_STD11::begin(
n), ETL_OR_STD11::end(
n));
241 str.insert(str.end(), ETL_OR_STD11::begin(
i), ETL_OR_STD11::end(
i));
248 template <
typename TIString>
256 typedef typename TIString::value_type type;
262 str.push_back(type(
'.'));
267#if ETL_USING_64BIT_TYPES
271 template <
typename TIString>
279 typedef typename TIString::value_type type;
285 str.push_back(type(
'.'));
294 template <
typename T,
typename TIString>
300 typedef typename TIString::iterator
iterator;
301 typedef typename TIString::value_type type;
319#if ETL_NOT_USING_64BIT_TYPES
362 template <
typename T,
typename TIString>
367 const bool append =
false)
369 typedef typename TIString::iterator
iterator;
370 typedef typename TIString::value_type type;
441 template <
typename TIString>
455 template <
typename TIString>
466 typename TIString::iterator start = str.end();
468 str.insert(str.end(), value.begin(), value.end());
476 template <
typename TSringView,
typename TIString>
487 typename TIString::iterator start = str.end();
489 str.insert(str.end(), value.begin(), value.end());
499 template <
typename TIString>
503 const bool append =
false)
513 template <
typename TIString>
517 const bool append =
false)
524#if ETL_USING_64BIT_TYPES
528 template <
typename T,
typename TIString>
544 template <
typename T,
typename TIString>
558 template <
typename T,
typename TIString>
574 template <
typename T,
typename TIString>
588 template <
typename T,
typename TIString>
595 etl::private_to_string::add_integral(type(value), str,
format, append,
false);
603 template <
typename T,
typename TIString>
608 etl::private_to_string::add_integral_denominated(type(value), denominator_exponent, str, format, append,
false);
617 template <
typename T,
typename TIString>
add_pointer
Definition type_traits_generator.h:898
is_same
Definition type_traits_generator.h:1041
bitset_ext
Definition absolute.h:38
Definition type_traits.h:1376
iterator
Definition iterator.h:399
pair holds two objects of arbitrary type
Definition utility.h:164
void add_alignment(TIString &str, typename TIString::iterator position, const etl::basic_format_spec< TIString > &format)
Helper function for left/right alignment.
Definition to_string_helper.h:69
void add_floating_point(const T value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for floating point.
Definition to_string_helper.h:295
void add_string(const TIString &value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for strings.
Definition to_string_helper.h:456
void add_integral_denominated(const T value, const uint32_t denominator_exponent, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append=false)
Helper function for denominated integers.
Definition to_string_helper.h:363
void add_nan_inf(const bool not_a_number, const bool infinity, TIString &str)
Helper function for floating point nan and inf.
Definition to_string_helper.h:226
void add_integral_and_fractional(const uint32_t integral, const uint32_t fractional, TIString &str, const etl::basic_format_spec< TIString > &integral_format, const etl::basic_format_spec< TIString > &fractional_format, const bool negative)
Helper function for floating point integral and fractional.
Definition to_string_helper.h:249
const TIString & to_string(const bool value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append=false)
For booleans.
Definition to_string_helper.h:500
void add_integral(T value, TIString &str, const etl::basic_format_spec< TIString > &format, bool append, const bool negative)
Helper function for integrals.
Definition to_string_helper.h:142
void add_string_view(const TSringView &value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for string views.
Definition to_string_helper.h:477
void add_pointer(const volatile void *value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for pointers.
Definition to_string_helper.h:442
void add_boolean(const bool value, TIString &str, const etl::basic_format_spec< TIString > &format, const bool append)
Helper function for booleans.
Definition to_string_helper.h:94