Embedded Template Library 1.0
Loading...
Searching...
No Matches
to_u32string.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2019 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_TO_U32STRING_INCLUDED
32#define ETL_TO_U32STRING_INCLUDED
33
35
36#include "platform.h"
37#include "type_traits.h"
38#include "u32string.h"
39#include "u32format_spec.h"
41
42namespace etl
43{
44 //***************************************************************************
47 //***************************************************************************
48 template <typename T>
49 typename etl::enable_if<!etl::is_same<T, etl::iu32string>::value && !etl::is_same<T, etl::u32string_view>::value, const etl::iu32string&>::type
50 to_string(const T value, etl::iu32string& str, bool append = false)
51 {
52 etl::u32format_spec format;
53
54 return private_to_string::to_string(value, str, format, append);
55 }
56
57 //***************************************************************************
60 //***************************************************************************
61 template <typename T>
63 to_string(const T value, etl::iu32string& str, const etl::u32format_spec& format, bool append = false)
64 {
65 return private_to_string::to_string(value, str, format, append);
66 }
67
68 //***************************************************************************
71 //***************************************************************************
72 template <typename T>
74 to_string(const T value, uint32_t denominator_exponent, etl::iu32string& str, bool append = false)
75 {
76 etl::u32format_spec format;
77
78 return private_to_string::to_string(value, denominator_exponent, str, format, append);
79 }
80
81 //***************************************************************************
84 //***************************************************************************
85 template <typename T>
87 to_string(const T value, uint32_t denominator_exponent, etl::iu32string& str, const etl::u32format_spec& format, bool append = false)
88 {
89 return private_to_string::to_string(value, denominator_exponent, str, format, append);
90 }
91
92 //***************************************************************************
95 //***************************************************************************
96 template <typename T>
97 typename etl::enable_if<etl::is_same<T, etl::iu32string>::value, const etl::iu32string&>::type
98 to_string(const T& value, etl::iu32string& str, bool append = false)
99 {
100 etl::u32format_spec format;
101
102 private_to_string::add_string(value, str, format, append);
103
104 return str;
105 }
106
107 //***************************************************************************
110 //***************************************************************************
111 template <typename T>
112 typename etl::enable_if<etl::is_same<T, etl::iu32string>::value, const etl::iu32string&>::type
113 to_string(const etl::iu32string& value, T& str, const etl::u32format_spec& format, bool append = false)
114 {
115 private_to_string::add_string(value, str, format, append);
116
117 return str;
118 }
119
120 //***************************************************************************
123 //***************************************************************************
124 template <typename T>
125 typename etl::enable_if<etl::is_same<T, etl::u32string_view>::value, const etl::iu32string&>::type
126 to_string(T value, etl::iu32string& str, bool append = false)
127 {
128 etl::u32format_spec format;
129
130 private_to_string::add_string_view(value, str, format, append);
131
132 return str;
133 }
134
135 //***************************************************************************
138 //***************************************************************************
139 template <typename T>
140 typename etl::enable_if<etl::is_same<T, etl::u32string_view>::value, const etl::iu32string&>::type
141 to_string(T value, etl::iu32string& str, const etl::u32format_spec& format, bool append = false)
142 {
143 private_to_string::add_string_view(value, str, format, append);
144
145 return str;
146 }
147}
148
149#endif
enable_if
Definition type_traits_generator.h:1254
is_same
Definition type_traits_generator.h:1104
bitset_ext
Definition absolute.h:39
etl::enable_if<!etl::is_same< T, etl::istring >::value &&!etl::is_same< T, etl::string_view >::value, constetl::istring & >::type to_string(const T value, etl::istring &str, bool append=false)
Definition to_string.h:50
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:457
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:501
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:478