xtd 1.0.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"
11
13namespace xtd {
23 using string = xtd::basic_string<char>;
24
35 using ustring [[deprecated("Replaced by xtd::string - Will be removed in version 1.2.0.")]] = xtd::string;
36
40 [[nodiscard]] auto to_string(int val) -> xtd::string;
44 [[nodiscard]] auto to_string(unsigned val) -> xtd::string;
48 [[nodiscard]] auto to_string(long val) -> xtd::string;
52 [[nodiscard]] auto to_string(unsigned long val) -> xtd::string;
56 [[nodiscard]] auto to_string(long long val) -> xtd::string;
60 [[nodiscard]] auto to_string(unsigned long long val) -> xtd::string;
64 [[nodiscard]] auto to_string(float val) -> xtd::string;
68 [[nodiscard]] auto to_string(double val) -> xtd::string;
72 [[nodiscard]] auto to_string(long double val) -> xtd::string;
76 template<typename type_t>
77 [[nodiscard]] inline auto to_string(type_t val) -> xtd::string {
78 return string::format("{}", val);
79 }
80
85 template<typename type_t>
86 [[deprecated("Replaced by xtd::to_string - Will be removed in version 1.2.0.")]]
87 [[nodiscard]] inline auto to_ustring(type_t val) -> xtd::string {
88 return to_string(val);
89 }
90
92 namespace collections {
93 namespace generic {
94 template<typename type_t>
95 auto enumerable_generator<type_t>::to_string() const -> xtd::string {
96 auto result = xtd::string {"["};
97 for (auto item : self_)
98 result += xtd::string::format("{}{}", result != "[" ? ", " : "", item);
99 return result + "]";
100 }
101 }
102 }
104}
105
107template<typename type_t>
108[[nodiscard]] inline auto __to_string_istringable_to_string(const xtd::istringable<type_t>* obj) -> std::string {
109 return obj->to_string();
110}
111
112template<typename key_t, typename value_t>
113[[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);}
114
115template<typename type_t>
116[[nodiscard]] inline auto __opaque_xtd_linq_enumerable_collection__<type_t>::to_string() const -> xtd::string {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
117
118template<typename type_t, typename param_t>
119[[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));}
120
121[[nodiscard]] inline auto xtd::index::to_string() const noexcept -> xtd::string {return is_from_end() ? xtd::string::format("~{}", ~__v__) : xtd::string::format("{}", __v__);}
122
123template<typename type_t>
124[[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()));}
125
126template<typename type_t>
127[[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()));}
128
129template<typename type_t, typename deleter_t>
130[[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()));}
132
133#include "literals/string.hpp"
134#define __XTD_CORE_INTERNAL__
136#undef __XTD_CORE_INTERNAL__
Contains xtd::basic_string class.
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Definition basic_string.hpp:1259
Provides a way to represent the current object as a string.
Definition istringable.hpp:26
virtual auto to_string() const -> xtd::string
Returns a xtd::string that represents the current object.
Contains xtd::collections::generic::enumerable_generator <> class.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
auto format(const xtd::string &fmt, args_t &&... args) -> xtd::string
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:21
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
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.
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
auto to_string() const noexcept -> xtd::string override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:355
auto to_ustring(type_t val) -> xtd::string
Converts a type_t to xtd::string.
Definition string.hpp:87