xtd 0.2.0
string.hpp
Go to the documentation of this file.
1
4#pragma once
5#define __XTD_CORE_INTERNAL__
7#undef __XTD_CORE_INTERNAL__
8#include "basic_string.hpp"
9
11namespace xtd {
21 using string = xtd::basic_string<char>;
22
34
42 xtd::string to_string(unsigned val);
50 xtd::string to_string(unsigned long val);
54 xtd::string to_string(long long val);
58 xtd::string to_string(unsigned long long val);
62 string to_string(float val);
70 xtd::string to_string(long double val);
74 template<class type_t>
75 xtd::string to_string(type_t val) {
76 return string::format("{}", val);
77 }
78
82 template<class type_t>
83 xtd::string to_ustring(type_t val) {
84 return to_string(val);
85 }
86}
87
88/*
91#if defined(__xtd__cpp_lib_format)
92template <>
93struct std::formatter<xtd::string> : std::formatter<std::string> {
94 template<class object_t, class format_context_t>
95 auto format(const object_t& obj, format_context_t& ctx) const {return std::format_to(ctx.out(), "{}", std::string {obj.to_string()});}
96};
97#endif
99*/
100
103template<>
104inline std::string xtd::to_string(const xtd::string& value, const std::string& fmt, const std::locale& loc) {return value.to_string();}
105
106template<class key_t, class value_t>
107xtd::string xtd::collections::generic::key_value_pair<key_t, value_t>::to_string() const noexcept {return xtd::string::format("({0}, {1})", first, second);}
108
109template<class type_t>
110xtd::string __opaque_xtd_linq_enumerable_collection__<type_t>::to_string() const {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
111
112template<class type_t, class param_t>
113xtd::string __opaque_xtd_linq_lazy_enumerable__<type_t, param_t>::to_string() const {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
114
115template<class type_t>
116xtd::string xtd::reference_wrapper_object<type_t>::to_string() const noexcept {return xtd::string::format("{} [value={}]", xtd::object::to_string(), !ref_.has_value() ? "(null)" : string::format("{}", get()));}
117
118template<class type_t>
119xtd::string xtd::shared_ptr_object<type_t>::to_string() const noexcept {return xtd::string::format("{} [pointer={}]", xtd::object::to_string(), ptr_ == xtd::null ? "null" : string::format("0x{:X16}, use_count={}", get(), use_count()));}
120
121template<class type_t, class deleter_t>
122xtd::string xtd::unique_ptr_object<type_t, deleter_t>::to_string() const noexcept {return xtd::string::format("{} [pointer={}]", xtd::object::to_string(), ptr_ == xtd::null ? "null" : string::format("0x{:X16}", get()));}
124
125#include "literals/string.hpp"
Contains string definitions.
Contains xtd::basic_string class.
virtual xtd::string to_string() const noexcept
Returns a xtd::string that represents the current object.
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
xtd::string ustring
Represents text as a sequence of UTF-8 code units.
Definition string.hpp:33
null_ptr null
Represents a null pointer value.
Contains xtd::string suffixes.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375
xtd::string to_ustring(type_t val)
Converts a type_t to xtd::string.
Definition string.hpp:83
xtd::string to_string() const noexcept override
Returns a String representation of the key_value_pair<key_t, value_t>, using the String representatio...