Skip to content

Commit

Permalink
Fix #258
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Aug 26, 2024
1 parent 0a2011f commit 6e498e4
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 133 deletions.
38 changes: 20 additions & 18 deletions src/xtd.core/include/xtd/basic_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,35 @@ namespace xtd {
/// @remarks Is equal to `std::basic_string<char_t, traits_t, allocator_t>`.`
using base_type = std::basic_string<char_t, traits_t, allocator_t>;
/// @brief Represents the basic string traits type.
using traits_type = base_type::traits_type;
using traits_type = typename base_type::traits_type;
/// @brief Represents the basic string value type.
using value_type = base_type::value_type;
using value_type = typename base_type::value_type;
/// @brief Represents the basic string allocator type.
using allocator_type = base_type::allocator_type;
using allocator_type = typename base_type::allocator_type;
/// @brief Represents the basic string size type.
using size_type = base_type::size_type;
using size_type = typename base_type::size_type;
/// @brief Represents the basic string difference type.
using difference_type = base_type::difference_type;
using difference_type = typename base_type::difference_type;
/// @brief Represents the basic string referecne type.
using reference = base_type::reference;
using reference = typename base_type::reference;
/// @brief Represents the basic string const referecne type.
using const_reference = base_type::const_reference;
using const_reference = typename base_type::const_reference;
/// @brief Represents the basic string pointer type.
using pointer = base_type::pointer;
using pointer = typename base_type::pointer;
/// @brief Represents the basic string const pointer type.
using const_pointer = base_type::const_pointer;
using const_pointer = typename base_type::const_pointer;
/// @brief Represents the basic string iterator type.
/// @todo replace xtd::ienumerable::iterator
using iterator = xtd::collections::generic::ienumerable<char_t>::iterator;
using iterator = typename xtd::collections::generic::ienumerable<char_t>::iterator;
/// @brief Represents the basic string const iterator type.
/// @todo replace xtd::ienumerable::const_iterator
using const_iterator = xtd::collections::generic::ienumerable<char_t>::const_iterator;
using const_iterator = typename xtd::collections::generic::ienumerable<char_t>::const_iterator;
/// @brief Represents the basic string reverse iterator type.
using reverse_iterator = base_type::reverse_iterator;
using reverse_iterator = typename base_type::reverse_iterator;
/// @brief Represents the basic string const reverse iterator type.
using const_reverse_iterator = base_type::const_reverse_iterator;
using const_reverse_iterator = typename base_type::const_reverse_iterator;
/// @brief Represents the basic string enumerator type.
using enumerator_type = xtd::collections::generic::enumerator<value_type>;
using enumerator_type = typename xtd::collections::generic::enumerator<value_type>;
/// @}

/// @name Public Fields
Expand Down Expand Up @@ -1913,9 +1913,11 @@ namespace xtd {
/// @return The current string.
basic_string<xtd::char32> to_u32string() const noexcept {return __xtd_convert_to_string<xtd::char32>(chars_);}

#if defined(__xtd__cpp_lib_char8_t)
/// @brief Converts the value of this instance to a xtd::basic_string <xtd::char8>.
/// @return The current string.
basic_string<xtd::char8> to_u8string() const noexcept {return __xtd_convert_to_string<xtd::char8>(chars_);}
#endif

/// @brief Returns a copy of the current xtd::basic_string converted to uppercase.
/// @return A string in uppercase.
Expand Down Expand Up @@ -3014,14 +3016,14 @@ namespace xtd {
/// @remarks Equivalent to `return os << std::basic_string_view<char_t, traits_t>(str);`.
/// @todo uncomment following line and remove the next.
//friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << __xtd_convert_to_string<char>(str.chars_);}
friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << __xtd_convert_to_string<char>(str.chars());}
/// @brief Output stream operator. Behaves as a [FormattedOutputFunction](https://en.cppreference.com/w/cpp/named_req/FormattedOutputFunction). After constructing and checking the sentry object, [determines the output format padding](https://en.cppreference.com/w/cpp/named_req/FormattedOutputFunction#Padding).
/// @param os The character output stream.
/// @param str The string to be inserted.
/// @remarks Then inserts each character from the resulting sequence `seq` (the contents of `str` plus padding) to the output stream `os` as if by calling `os.rdbuf()->sputn(seq, n)`, where n is `std::max(os.width(), str.size())`.
/// @remarks Finally, calls `os.width(0)` to cancel the effects of std::setw, if any.
/// @remarks Equivalent to `return os << std::basic_string_view<char_t, traits_t>(str);`.
friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) {return stream << str.to_wstring().chars_;}
friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) {return stream << str.to_wstring().chars();}

/// @brief Input stream operator. Behaves as a [FormattedInputFunction](https://en.cppreference.com/w/cpp/named_req/FormattedInputFunction). After constructing and checking the sentry object, which may skip leading whitespace, first clears `str` with `str.erase()`, then reads characters from `is` and appends them to `str` as if by `str.append(1, c)`, until one of the following conditions becomes true:
/// * N characters are read, where N is `is.width()` if `is.width() > 0`, otherwise N is `str.max_size()`,
Expand Down Expand Up @@ -3065,13 +3067,13 @@ namespace xtd {
static const std::vector<char_t> default_split_separators;
static const std::vector<char_t> default_trim_chars;

base_type::iterator to_base_type_iterator(iterator value) const noexcept {
typename base_type::iterator to_base_type_iterator(iterator value) const noexcept {
if (value == begin()) return chars_.begin();
if (value == end()) return chars_.end();
return chars_.begin() + (value - begin());
}

iterator to_iterator(base_type::iterator value) const noexcept {
iterator to_iterator(typename base_type::iterator value) const noexcept {
if (value == chars_.begin()) return begin();
if (value == chars_.end()) return end();
return begin() + (value - chars_.begin());
Expand Down
4 changes: 2 additions & 2 deletions src/xtd.core/include/xtd/collections/generic/ienumerable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace xtd {

/// @{
/// @brief Represents the iterator of xtd::collections::generic::ienumerable value type.
using iterator = enumerable_iterators<type_t, ienumerable<type_t>>::iterator;
using iterator = typename enumerable_iterators<type_t, ienumerable<type_t>>::iterator;
/// @brief Represents the const iterator of xtd::collections::generic::ienumerable value type.
using const_iterator = enumerable_iterators<type_t, ienumerable<type_t>>::const_iterator;
using const_iterator = typename enumerable_iterators<type_t, ienumerable<type_t>>::const_iterator;
/// @}

/// @name Public Methods
Expand Down
8 changes: 4 additions & 4 deletions src/xtd.core/include/xtd/collections/generic/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ namespace xtd {
/// @brief Represents the const iterator of list value type.
using const_iterator = ilist<type_t>::const_iterator;
/// @brief Represents the reverse iterator of list value type.
using reverse_iterator = base_type::reverse_iterator;
using reverse_iterator = typename base_type::reverse_iterator;
/// @brief Represents the const reverse iterator of list value type.
using const_reverse_iterator = base_type::const_reverse_iterator;
using const_reverse_iterator = typename base_type::const_reverse_iterator;
/// @brief Represents the read only collection of of list.
using read_only_collection = xtd::collections::object_model::read_only_collection<value_type>;
/// @}
Expand Down Expand Up @@ -940,13 +940,13 @@ namespace xtd {
/// @}

private:
base_type::iterator to_base_type_iterator(iterator value) noexcept {
typename base_type::iterator to_base_type_iterator(iterator value) noexcept {
if (value == begin()) return data_->items.begin();
if (value == end()) return data_->items.end();
return data_->items.begin() + (value - begin());
}

iterator to_iterator(base_type::iterator value) noexcept {
iterator to_iterator(typename base_type::iterator value) noexcept {
if (value == data_->items.begin()) return begin();
if (value == data_->items.end()) return end();
return begin() + (value - data_->items.begin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace xtd {
template<typename list_type_t>
class empty_list : public generic::ilist<list_type_t> {
public:
using iterator = generic::ilist<list_type_t>::iterator;
using const_iterator = generic::ilist<list_type_t>::const_iterator;
using iterator = typename generic::ilist<list_type_t>::iterator;
using const_iterator = typename generic::ilist<list_type_t>::const_iterator;

inline static constexpr xtd::size npos = xtd::size_object::max_value;

Expand Down
26 changes: 13 additions & 13 deletions src/xtd.core/include/xtd/text/basic_string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,33 @@ namespace xtd {
/// @remarks Is equal to `std::basic_string<char_t, traits_t, allocator_t>`.`
using base_type = std::basic_string<char_t, traits_t, allocator_t>;
/// @brief Represents the basic string traits type.
using traits_type = base_type::traits_type;
using traits_type = typename base_type::traits_type;
/// @brief Represents the basic string value type.
using value_type = base_type::value_type;
using value_type = typename base_type::value_type;
/// @brief Represents the basic string allocator type.
using allocator_type = base_type::allocator_type;
using allocator_type = typename base_type::allocator_type;
/// @brief Represents the basic string size type.
using size_type = base_type::size_type;
using size_type = typename base_type::size_type;
/// @brief Represents the basic string difference type.
using difference_type = base_type::difference_type;
using difference_type = typename base_type::difference_type;
/// @brief Represents the basic string referecne type.
using reference = base_type::reference;
using reference = typename base_type::reference;
/// @brief Represents the basic string const referecne type.
using const_reference = base_type::const_reference;
using const_reference = typename base_type::const_reference;
/// @brief Represents the basic string pointer type.
using pointer = base_type::pointer;
using pointer = typename base_type::pointer;
/// @brief Represents the basic string const pointer type.
using const_pointer = base_type::const_pointer;
using const_pointer = typename base_type::const_pointer;
/// @brief Represents the basic string iterator type.
/// @todo replace xtd::ienumerable::iterator
using iterator = base_type::iterator;
using iterator = typename base_type::iterator;
/// @brief Represents the basic string const iterator type.
/// @todo replace xtd::ienumerable::const_iterator
using const_iterator = base_type::const_iterator;
using const_iterator = typename base_type::const_iterator;
/// @brief Represents the basic string reverse iterator type.
using reverse_iterator = base_type::reverse_iterator;
using reverse_iterator = typename base_type::reverse_iterator;
/// @brief Represents the basic string const reverse iterator type.
using const_reverse_iterator = base_type::const_reverse_iterator;
using const_reverse_iterator = typename base_type::const_reverse_iterator;
/// @}

/// @name Public Fields
Expand Down
2 changes: 2 additions & 0 deletions src/xtd.core/include/xtd/text/u8string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace xtd {
/// @brief Contains classes that represent ASCII and Unicode character encodings; abstract base classes for converting blocks of characters to and from blocks of bytes; and a helper class that manipulates and formats xtd::string objects without creating intermediate instances of xtd::string.
namespace text {
#if defined(__xtd__cpp_lib_char8_t)
/// @brief Represents text as a sequence of UTF-32 code units.
/// @par Namespace
/// xtd
Expand All @@ -19,5 +20,6 @@ namespace xtd {
/// @remarks If you want the same mutable string class, you can use xtd::text::u8string_builder class.
/// @remarks xtd::u32string implements xtd::basic_string and therefore offers the full (immutable) API of [std::u32string](https://en.cppreference.com/w/cpp/string).
using u8string_builder = xtd::text::basic_string_builder<xtd::char8>;
#endif
}
}
42 changes: 21 additions & 21 deletions src/xtd.core/src/xtd/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ std::any convert::to_any(wchar* value) noexcept {

bool convert::to_boolean(std::any value) {
try {
return any_cast<bool>(value);
return std::any_cast<bool>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -312,7 +312,7 @@ bool convert::to_boolean(wchar* value) {

xtd::byte convert::to_byte(std::any value) {
try {
return any_cast<xtd::byte>(value);
return std::any_cast<xtd::byte>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -491,7 +491,7 @@ xtd::byte convert::to_byte(wchar* value) {

char convert::to_char(std::any value) {
try {
return any_cast<char>(value);
return std::any_cast<char>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -853,10 +853,10 @@ char8 convert::to_char8(wchar* value) {

char16 convert::to_char16(std::any value) {
try {
return any_cast<char16>(value);
return std::any_cast<char16>(value);
} catch (...) {
try {
return *any_cast<char16*>(value);
return *std::any_cast<char16*>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1039,10 +1039,10 @@ char16 convert::to_char16(wchar* value) {

char32 convert::to_char32(std::any value) {
try {
return any_cast<char32>(value);
return std::any_cast<char32>(value);
} catch (...) {
try {
return *any_cast<char32*>(value);
return *std::any_cast<char32*>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1223,10 +1223,10 @@ char32 convert::to_char32(wchar* value) {

wchar convert::to_wchar(std::any value) {
try {
return any_cast<wchar>(value);
return std::any_cast<wchar>(value);
} catch (...) {
try {
return *any_cast<wchar*>(value);
return *std::any_cast<wchar*>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1409,7 +1409,7 @@ wchar convert::to_wchar(wchar* value) {

decimal convert::to_decimal(std::any value) {
try {
return any_cast<decimal>(value);
return std::any_cast<decimal>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1563,7 +1563,7 @@ decimal convert::to_decimal(wchar* value) {

double convert::to_double(std::any value) {
try {
return any_cast<double>(value);
return std::any_cast<double>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1717,7 +1717,7 @@ double convert::to_double(wchar* value) {

float convert::to_single(std::any value) {
try {
return any_cast<float>(value);
return std::any_cast<float>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -1871,7 +1871,7 @@ float convert::to_single(wchar* value) {

int16 convert::to_int16(std::any value) {
try {
return any_cast<int16>(value);
return std::any_cast<int16>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2046,7 +2046,7 @@ int16 convert::to_int16(wchar* value) {

int32 convert::to_int32(std::any value) {
try {
return any_cast<int32>(value);
return std::any_cast<int32>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2217,7 +2217,7 @@ int32 convert::to_int32(wchar* value) {

int64 convert::to_int64(std::any value) {
try {
return any_cast<int64>(value);
return std::any_cast<int64>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2383,7 +2383,7 @@ int64 convert::to_int64(wchar* value) {

slong convert::to_llong(std::any value) {
try {
return any_cast<slong>(value);
return std::any_cast<slong>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2549,7 +2549,7 @@ slong convert::to_llong(wchar* value) {

sbyte convert::to_sbyte(std::any value) {
try {
return any_cast<sbyte>(value);
return std::any_cast<sbyte>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2727,7 +2727,7 @@ sbyte convert::to_sbyte(wchar* value) {

uint16 convert::to_uint16(std::any value) {
try {
return any_cast<uint16>(value);
return std::any_cast<uint16>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -2903,7 +2903,7 @@ uint16 convert::to_uint16(wchar* value) {

uint32 convert::to_uint32(std::any value) {
try {
return any_cast<uint32>(value);
return std::any_cast<uint32>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -3077,7 +3077,7 @@ uint32 convert::to_uint32(wchar* value) {

uint64 convert::to_uint64(std::any value) {
try {
return any_cast<uint64>(value);
return std::any_cast<uint64>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down Expand Up @@ -3249,7 +3249,7 @@ uint64 convert::to_uint64(wchar* value) {

xtd::ulong convert::to_ullong(std::any value) {
try {
return any_cast<xtd::ulong>(value);
return std::any_cast<xtd::ulong>(value);
} catch (...) {
throw invalid_cast_exception {csf_};
}
Expand Down
2 changes: 1 addition & 1 deletion src/xtd.core/src/xtd/time_zone_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ xtd::date_time time_zone_info::convert_to_utc(const xtd::date_time& date_time, c

auto daylight_saving_time_offset = ticks {0};
if (source_time_zone.supports_daylight_saving_time() && source_time_zone.is_daylight_saving_time(date_time))
daylight_saving_time_offset = duration_cast<ticks>(std::chrono::hours(1));
daylight_saving_time_offset = std::chrono::duration_cast<ticks>(std::chrono::hours(1));

auto offset_local = -(source_time_zone.base_utc_offset() + daylight_saving_time_offset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ void command_link_button::texts(intptr control, const std::tuple<string, string>
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", __FILE__, __LINE__, __func__);
return;
}
static_cast<wxCommandLinkButton*>(reinterpret_cast<control_handler*>(control)->control())->SetMainLabelAndNote(convert_string::to_wstring(get<0>(texts)), convert_string::to_wstring(get<1>(texts)));
static_cast<wxCommandLinkButton*>(reinterpret_cast<control_handler*>(control)->control())->SetMainLabelAndNote(convert_string::to_wstring(std::get<0>(texts)), convert_string::to_wstring(std::get<1>(texts)));
}
Loading

0 comments on commit 6e498e4

Please sign in to comment.