xtd 0.2.0
Loading...
Searching...
No Matches
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"
10
12namespace xtd {
22 using string = xtd::basic_string<char>;
23
34 using ustring [[deprecated("Replaced by xtd::string - Will be removed in version 0.4.0.")]] = xtd::string;
35
43 xtd::string to_string(unsigned val);
51 xtd::string to_string(unsigned long val);
55 xtd::string to_string(long long val);
59 xtd::string to_string(unsigned long long val);
63 string to_string(float val);
71 xtd::string to_string(long double val);
75 template<typename type_t>
76 inline xtd::string to_string(type_t val) {
77 return string::format("{}", val);
78 }
79
84 template<typename type_t>
85 [[deprecated("Replaced by xtd::to_string - Will be removed in version 0.4.0.")]]
86 inline xtd::string to_ustring(type_t val) {
87 return to_string(val);
88 }
89}
90
91/*
94#if defined(__xtd__cpp_lib_format)
95template <>
96struct std::formatter<xtd::string> : std::formatter<std::string> {
97 template<typename object_t, typename format_context_t>
98 auto format(const object_t& obj, format_context_t& ctx) const {return std::format_to(ctx.out(), "{}", std::string {obj.to_string()});}
99};
100#endif
102*/
103
105template<typename type_t>
106[[nodiscard]] inline auto __to_string_istringable_to_string(const xtd::istringable<type_t>* obj) -> std::string {
107 return obj->to_string();
108}
109
110template<typename key_t, typename value_t>
111[[nodiscard]] inline auto xtd::collections::generic::key_value_pair<key_t, value_t>::to_string() const noexcept -> xtd::string {return xtd::string::format("({}, {})", first, second);}
112
113template<typename type_t>
114[[nodiscard]] inline auto __opaque_xtd_linq_enumerable_collection__<type_t>::to_string() const -> xtd::string {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
115
116template<typename type_t, typename param_t>
117[[nodiscard]] inline auto __opaque_xtd_linq_lazy_enumerable__<type_t, param_t>::to_string() const -> xtd::string {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
118
119template<typename type_t>
120[[nodiscard]] inline auto xtd::reference_wrapper_object<type_t>::to_string() const noexcept -> xtd::string {return xtd::string::format("{} [value={}]", xtd::object::to_string(), !ref_.has_value() ? "(null)" : string::format("{}", get()));}
121
122template<typename type_t>
123[[nodiscard]] inline auto xtd::shared_ptr_object<type_t>::to_string() const noexcept -> xtd::string {return xtd::string::format("{} [pointer={}]", xtd::object::to_string(), ptr_ == xtd::null ? "null" : string::format("0x{:X16}, use_count={}", get(), use_count()));}
124
125template<typename type_t, typename deleter_t>
126[[nodiscard]] inline auto xtd::unique_ptr_object<type_t, deleter_t>::to_string() const noexcept -> xtd::string {return xtd::string::format("{} [pointer={}]", xtd::object::to_string(), ptr_ == xtd::null ? "null" : string::format("0x{:X16}", get()));}
128
129#include "literals/string.hpp"
Contains xtd::basic_string class.
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Definition basic_string.hpp:1255
Provides a way to represent the current object as a string.
Definition istringable.hpp:26
virtual xtd::string to_string() const
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.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
null_ptr null
Represents a null pointer value.
Contains xtd::collections::generic::key_value_pair <key_t, value_t> struct.
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:86