Skip to content

[char_category] add ranges api for to_c_lower and to_c_upper #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3c713e0
move print_freestanding to impl.h
trcrsired Apr 6, 2025
941baa8
impl
trcrsired Apr 6, 2025
6a5c651
[print] move print_freestanding to a seperate directory to revamp it
trcrsired Apr 6, 2025
86f1205
special
trcrsired May 13, 2025
4be7ad3
Merge remote-tracking branch 'parent/next' into next
trcrsired May 13, 2025
df76284
Merge branch 'cppfastio:next' into next
trcrsired May 16, 2025
6fa8b50
add license and license-zhCN.txt for anti-tivoization
trcrsired May 21, 2025
517363c
Merge remote-tracking branch 'parent/next' into next
trcrsired May 28, 2025
4a9db4f
[core] Fix warnings for codecvt for clang for charxx_t
trcrsired May 30, 2025
2039ab7
Add trim to string
trcrsired May 31, 2025
e4fa227
add __cpp_static_call_operator to char_category_traits.h
trcrsired May 31, 2025
025f9fb
[edit] add string_view for trim, trim.cc string.h
trcrsired May 31, 2025
582c3ae
Merge remote-tracking branch 'refs/remotes/origin/next' into next
trcrsired May 31, 2025
975cfb0
Merge remote-tracking branch 'parent/next' into next
trcrsired May 31, 2025
533be36
[string] trim_subview_prefix should have
trcrsired Jun 1, 2025
d17d954
Merge remote-tracking branch 'parent/next' into next
trcrsired Jun 1, 2025
715ed24
[char_category] add to_c_lower upper ranges support
trcrsired Jun 1, 2025
849e3db
[char_category_traits.h] fix to_c_halfwidth
trcrsired Jun 1, 2025
118c83f
fix issues with shadow
trcrsired Jun 1, 2025
4c481f3
[nt] fix shadow in alpc_nt.h
trcrsired Jun 1, 2025
bdb0795
Merge branch 'cppfastio:next' into next
trcrsired Jun 1, 2025
5c4339c
[char_category] fix api before C++23
trcrsired Jun 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 0 additions & 306 deletions include/fast_io_core_impl/char_category/char_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -1578,268 +1578,6 @@ inline constexpr char32_t to_c_lower_ascii_impl(char32_t ch) noexcept

} // namespace details

template <::std::integral char_type>
inline constexpr char_type to_c_lower(char_type ch) noexcept
{
using unsigned_char_type = ::std::make_unsigned_t<char_type>;
if constexpr (!::fast_io::details::is_ebcdic<char_type>)
{
return static_cast<char_type>(
static_cast<unsigned_char_type>(details::to_c_lower_ascii_impl(static_cast<unsigned_char_type>(ch))));
}
else if constexpr (::std::same_as<char, char_type>)
{
switch (ch)
{
case 'A':
return 'a';
case 'B':
return 'b';
case 'C':
return 'c';
case 'D':
return 'd';
case 'E':
return 'e';
case 'F':
return 'f';
case 'G':
return 'g';
case 'H':
return 'h';
case 'I':
return 'i';
case 'J':
return 'j';
case 'K':
return 'k';
case 'L':
return 'l';
case 'M':
return 'm';
case 'N':
return 'n';
case 'O':
return 'o';
case 'P':
return 'p';
case 'Q':
return 'q';
case 'R':
return 'r';
case 'S':
return 's';
case 'T':
return 't';
case 'U':
return 'u';
case 'V':
return 'v';
case 'W':
return 'w';
case 'X':
return 'x';
case 'Y':
return 'y';
case 'Z':
return 'z';
default:
return ch;
}
}
else if constexpr (::std::same_as<wchar_t, char_type>)
{
switch (ch)
{
case L'A':
return L'a';
case L'B':
return L'b';
case L'C':
return L'c';
case L'D':
return L'd';
case L'E':
return L'e';
case L'F':
return L'f';
case L'G':
return L'g';
case L'H':
return L'h';
case L'I':
return L'i';
case L'J':
return L'j';
case L'K':
return L'k';
case L'L':
return L'l';
case L'M':
return L'm';
case L'N':
return L'n';
case L'O':
return L'o';
case L'P':
return L'p';
case L'Q':
return L'q';
case L'R':
return L'r';
case L'S':
return L's';
case L'T':
return L't';
case L'U':
return L'u';
case L'V':
return L'v';
case L'W':
return L'w';
case L'X':
return L'x';
case L'Y':
return L'y';
case L'Z':
return L'z';
default:
return ch;
}
}
}

template <::std::integral char_type>
inline constexpr char_type to_c_upper(char_type ch) noexcept
{
using unsigned_char_type = ::std::make_unsigned_t<char_type>;
if constexpr (!::fast_io::details::is_ebcdic<char_type>)
{
return static_cast<char_type>(
static_cast<unsigned_char_type>(details::to_c_upper_ascii_impl(static_cast<unsigned_char_type>(ch))));
}
else if constexpr (::std::same_as<char, char_type>)
{
switch (ch)
{
case 'a':
return 'A';
case 'b':
return 'B';
case 'c':
return 'C';
case 'd':
return 'D';
case 'e':
return 'E';
case 'f':
return 'F';
case 'g':
return 'G';
case 'h':
return 'H';
case 'i':
return 'I';
case 'j':
return 'J';
case 'k':
return 'K';
case 'l':
return 'L';
case 'm':
return 'M';
case 'n':
return 'N';
case 'o':
return 'O';
case 'p':
return 'P';
case 'q':
return 'Q';
case 'r':
return 'R';
case 's':
return 'S';
case 't':
return 'T';
case 'u':
return 'U';
case 'v':
return 'V';
case 'w':
return 'W';
case 'x':
return 'X';
case 'y':
return 'Y';
case 'z':
return 'Z';
default:
return ch;
}
}
else if constexpr (::std::same_as<wchar_t, char_type>)
{
switch (ch)
{
case L'a':
return L'A';
case L'b':
return L'B';
case L'c':
return L'C';
case L'd':
return L'D';
case L'e':
return L'E';
case L'f':
return L'F';
case L'g':
return L'G';
case L'h':
return L'H';
case L'i':
return L'I';
case L'j':
return L'J';
case L'k':
return L'K';
case L'l':
return L'L';
case L'm':
return L'M';
case L'n':
return L'N';
case L'o':
return L'O';
case L'p':
return L'P';
case L'q':
return L'Q';
case L'r':
return L'R';
case L's':
return L'S';
case L't':
return L'T';
case L'u':
return L'U';
case L'v':
return L'V';
case L'w':
return L'W';
case L'x':
return L'X';
case L'y':
return L'Y';
case L'z':
return L'Z';
default:
return ch;
}
}
}

/*
All Ascii based charset, only 6 character is supported
space (0x20, ' ')
Expand Down Expand Up @@ -2183,50 +1921,6 @@ inline constexpr bool is_c_fullwidth(char_type ch) noexcept
To do: to_c_fullwidth
*/

template <::std::integral char_type>
inline constexpr char_type to_c_halfwidth(char_type ch) noexcept
{
using unsigned_char_type = ::std::make_unsigned_t<char_type>;
if constexpr (sizeof(char_type) < sizeof(char32_t))
{
return ch;
}
else if constexpr (!::std::same_as<char_type, char32_t> && sizeof(char_type) == sizeof(char32_t))
{
return static_cast<char_type>(to_c_halfwidth(static_cast<char32_t>(ch)));
}
else if constexpr (::std::signed_integral<char_type>)
{
return static_cast<char_type>(to_c_halfwidth(static_cast<unsigned_char_type>(ch)));
}
else if constexpr (::std::same_as<char_type, wchar_t> && ::fast_io::details::wide_is_none_utf_endian)
{
constexpr unsigned_char_type fullwidth_exclaimation_mark_val{0xFF01};
constexpr unsigned_char_type num{94};
constexpr unsigned_char_type halfwidth_exclaimation_mark_val{u8'!'};
unsigned_char_type cht{ch};
cht = ::fast_io::byte_swap(cht);
unsigned_char_type const umav{static_cast<unsigned_char_type>(cht - fullwidth_exclaimation_mark_val)};
if (umav < num)
{
return static_cast<unsigned_char_type>(umav + halfwidth_exclaimation_mark_val);
}
return cht;
}
else
{
constexpr unsigned_char_type fullwidth_exclaimation_mark_val{0xFF01};
constexpr unsigned_char_type num{94};
constexpr unsigned_char_type halfwidth_exclaimation_mark_val{u8'!'};
unsigned_char_type const umav{static_cast<unsigned_char_type>(ch - fullwidth_exclaimation_mark_val)};
if (umav < num)
{
return static_cast<unsigned_char_type>(umav + halfwidth_exclaimation_mark_val);
}
return ch;
}
}

template <::std::integral T>
inline constexpr bool is_dos_path_invalid_character(T ch) noexcept
{
Expand Down
Loading