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
12namespace xtd {
23
27 string to_string(int val);
31 string to_string(unsigned val);
35 string to_string(long val);
39 string to_string(unsigned long val);
43 string to_string(long long val);
47 string to_string(unsigned long long val);
51 string to_string(float val);
55 string to_string(double val);
59 string to_string(long double val);
63 template<class type_t>
64 string to_string(type_t val) {
65 return string::format("{}", val);
66 }
67
72 template<class type_t>
73 [[deprecated("Replaced by xtd::to_string - Will be removed in version 0.4.0.")]] string to_ustring(type_t val) {
74 return to_string(val);
75 }
76}
77
78/*
81#if defined(__xtd__cpp_lib_format)
82template <>
83struct std::formatter<xtd::string> : std::formatter<std::string> {
84 template<class object_t, class format_context_t>
85 auto format(const object_t& obj, format_context_t& ctx) const {return std::format_to(ctx.out(), "{}", std::string {obj.to_string()});}
86};
87#endif
89*/
90
92template<>
93inline std::string xtd::to_string(const xtd::string& value, const std::string& fmt, const std::locale& loc) {return value.to_string();}
94
96template<class key_t, class value_t>
98
99template<class type_t>
100xtd::string __opaque_xtd_linq_enumerable_collection__<type_t>::to_string() const {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
101
102template<class type_t, class param_t>
103xtd::string __opaque_xtd_linq_lazy_enumerable__<type_t, param_t>::to_string() const {return xtd::string::format("[{}]", xtd::string::join(", ", *this));}
104
105
106template<class type_t>
107xtd::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()));}
Contains string definitions.
Contains xtd::basic_string class.
Represents text as a sequence of character units.
Definition basic_string.hpp:71
basic_string< char > to_string() const noexcept override
Converts the value of this instance to a xtd::basic_string <char>.
Definition basic_string.hpp:1911
static basic_string join(const basic_string separator, const collection_t &values) noexcept
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:2288
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.
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:20
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.
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition to_string.hpp:41
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
xtd::string to_string() const noexcept override
Returns a String representation of the key_value_pair<key_t, value_t>, using the String representatio...