13 #ifndef __STOUT_STRINGIFY_HPP__
14 #define __STOUT_STRINGIFY_HPP__
38 std::ostringstream out;
41 ABORT(
"Failed to stringify!");
50 inline std::string
stringify(
const std::string& str)
57 inline std::string
stringify(
const std::wstring& str)
60 static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,
wchar_t>
62 "UTF-16 to UTF-8 conversion failed",
63 L
"UTF-16 to UTF-8 conversion failed");
65 return converter.to_bytes(str);
69 inline std::wstring wide_stringify(
const std::string& str)
72 static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,
wchar_t>
74 "UTF-8 to UTF-16 conversion failed",
75 L
"UTF-8 to UTF-16 conversion failed");
77 return converter.from_bytes(str);
84 return b ?
"true" :
"false";
91 std::ostringstream out;
93 typename std::set<T>::const_iterator iterator = set.begin();
94 while (iterator != set.end()) {
96 if (++iterator != set.end()) {
105 template <
typename T>
108 std::ostringstream out;
110 typename std::list<T>::const_iterator iterator = list.begin();
111 while (iterator != list.end()) {
113 if (++iterator != list.end()) {
122 template <
typename T>
125 std::ostringstream out;
127 typename std::vector<T>::const_iterator iterator = vector.begin();
128 while (iterator != vector.end()) {
130 if (++iterator != vector.end()) {
139 template <
typename K,
typename V>
142 std::ostringstream out;
144 typename std::map<K, V>::const_iterator iterator = map.begin();
145 while (iterator != map.end()) {
149 if (++iterator != map.end()) {
158 template <
typename T>
161 std::ostringstream out;
164 while (iterator != set.end()) {
166 if (++iterator != set.end()) {
175 template <
typename K,
typename V>
178 std::ostringstream out;
181 while (iterator != map.end()) {
185 if (++iterator != map.end()) {
193 #endif // __STOUT_STRINGIFY_HPP__
#define ABORT(...)
Definition: abort.hpp:40
Definition: hashset.hpp:53
Try< bool > set(const std::string &_link, unsigned int flags)
Definition: internal.hpp:125
Definition: hashmap.hpp:38
Iterable< V > map(F &&f, const Iterable< U, Us...> &input)
Definition: lambda.hpp:45
Try< std::vector< Entry > > list(const std::string &hierarchy, const std::string &cgroup)
std::string stringify(int flags)