mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add cwchar.hpp
rename decimal_to_int -> ascii_to_int
This commit is contained in:
parent
50fd5f33bf
commit
28f7c510a5
34 changed files with 576 additions and 92 deletions
22
sprout/cwchar/wcschr.hpp
Normal file
22
sprout/cwchar/wcschr.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSCHR_HPP
|
||||
#define SPROUT_CWCHAR_WCSCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wcschr(wchar_t const* s, int c) {
|
||||
return *s == static_cast<wchar_t>(c) ? s
|
||||
: !*s ? nullptr
|
||||
: sprout::wcschr(s + 1, c)
|
||||
;
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t* wcschr(wchar_t* s, int c) {
|
||||
return const_cast<wchar_t*>(sprout::wcschr(const_cast<wchar_t const*>(s), c));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSCHR_HPP
|
19
sprout/cwchar/wcscmp.hpp
Normal file
19
sprout/cwchar/wcscmp.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSCMP_HPP
|
||||
#define SPROUT_CWCHAR_WCSCMP_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR int wcscmp(wchar_t const* s1, wchar_t const* s2) {
|
||||
return !*s1 && !*s2 ? 0
|
||||
: !*s1 ? -1
|
||||
: !*s2 ? 1
|
||||
: *s1 == *s2 ? sprout::wcscmp(s1 + 1, s2 + 1)
|
||||
: static_cast<unsigned wchar_t>(*s1) - static_cast<unsigned wchar_t>(*s2)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSCMP_HPP
|
15
sprout/cwchar/wcscoll.hpp
Normal file
15
sprout/cwchar/wcscoll.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSCOLL_HPP
|
||||
#define SPROUT_CWCHAR_WCSCOLL_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstring/strcmp.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR int wcscoll(wchar_t const* s1, wchar_t const* s2) {
|
||||
return sprout::wcscmp(s1, s2);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSCOLL_HPP
|
24
sprout/cwchar/wcscspn.hpp
Normal file
24
sprout/cwchar/wcscspn.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSCSPN_HPP
|
||||
#define SPROUT_CWCHAR_WCSCSPN_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstring/strchr.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR std::size_t wcscspn_impl(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
|
||||
return !*s1 || sprout::wcschr(s2, *s1) ? n
|
||||
: sprout::detail::wcscspn_impl(s1 + 1, s2, n + 1)
|
||||
;
|
||||
}
|
||||
} // amespace detail
|
||||
|
||||
inline SPROUT_CONSTEXPR std::size_t wcscspn(wchar_t const* s1, wchar_t const* s2) {
|
||||
return sprout::detail::wcscspn_impl(s1, s2, 0);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSCSPN_HPP
|
23
sprout/cwchar/wcslen.hpp
Normal file
23
sprout/cwchar/wcslen.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSLEN_HPP
|
||||
#define SPROUT_CWCHAR_WCSLEN_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR std::size_t wcslen_impl(wchar_t const* s, std::size_t n) {
|
||||
return !*s ? n :
|
||||
sprout::detail::wcslen_impl(s + 1, n + 1)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
inline SPROUT_CONSTEXPR std::size_t wcslen(wchar_t const* s) {
|
||||
return sprout::detail::wcslen_impl(s, 0);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSLEN_HPP
|
20
sprout/cwchar/wcsncmp.hpp
Normal file
20
sprout/cwchar/wcsncmp.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSNCMP_HPP
|
||||
#define SPROUT_CWCHAR_WCSNCMP_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR int wcsncmp(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
|
||||
return !n || (!*s1 && !*s2) ? 0
|
||||
: !*s1 ? -1
|
||||
: !*s2 ? 1
|
||||
: *s1 == *s2 ? sprout::wcsncmp(s1 + 1, s2 + 1, n - 1)
|
||||
: static_cast<unsigned wchar_t>(*s1) - static_cast<unsigned wchar_t>(*s2)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSNCMP_HPP
|
23
sprout/cwchar/wcspbrk.hpp
Normal file
23
sprout/cwchar/wcspbrk.hpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSPBRK_HPP
|
||||
#define SPROUT_CWCHAR_WCSPBRK_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstring/strchr.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wcspbrk(wchar_t const* s1, wchar_t const* s2) {
|
||||
return !*s1 ? nullptr
|
||||
: sprout::wcschr(s2, *s1) ? s1
|
||||
: sprout::wcspbrk(s1 + 1, s2)
|
||||
;
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t* wcspbrk(wchar_t* s1, wchar_t const* s2) {
|
||||
return const_cast<wchar_t*>(sprout::wcspbrk(const_cast<wchar_t const*>(s1), s2));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSPBRK_HPP
|
22
sprout/cwchar/wcsrchr.hpp
Normal file
22
sprout/cwchar/wcsrchr.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSRCHR_HPP
|
||||
#define SPROUT_CWCHAR_WCSRCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wcsrchr(wchar_t const* s, int c) {
|
||||
return *s == static_cast<wchar_t>(c) && (!*s || !sprout::wcsrchr(s + 1, c))? s
|
||||
: !*s ? nullptr
|
||||
: sprout::wcsrchr(s + 1, c)
|
||||
;
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t* wcsrchr(wchar_t* s, int c) {
|
||||
return const_cast<wchar_t*>(sprout::wcsrchr(const_cast<wchar_t const*>(s), c));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSRCHR_HPP
|
24
sprout/cwchar/wcsspn.hpp
Normal file
24
sprout/cwchar/wcsspn.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSSPN_HPP
|
||||
#define SPROUT_CWCHAR_XXX_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/cstring/strchr.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR std::size_t wcsspn_impl(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
|
||||
return !*s1 || !sprout::wcschr(s2, *s1) ? n
|
||||
: sprout::detail::wcsspn_impl(s1 + 1, s2, n + 1)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
inline SPROUT_CONSTEXPR std::size_t wcsspn(wchar_t const* s1, wchar_t const* s2) {
|
||||
return sprout::detail::wcsspn_impl(s1, s2, 0);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_XXX_HPP
|
22
sprout/cwchar/wcsstr.hpp
Normal file
22
sprout/cwchar/wcsstr.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef SPROUT_CWCHAR_WCSSTR_HPP
|
||||
#define SPROUT_CWCHAR_WCSSTR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wcsstr(wchar_t const* s1, wchar_t const* s2) {
|
||||
return !*s2 ? s1
|
||||
: !*s1 ? nullptr
|
||||
: *s1 == *s2 && sprout::wcsstr(s1 + 1, s2 + 1) ? s1
|
||||
: sprout::wcsstr(s1 + 1, s2)
|
||||
;
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t* wcsstr(wchar_t* s1, wchar_t const* s2) {
|
||||
return const_cast<wchar_t*>(sprout::wcsstr(const_cast<wchar_t const*>(s1), s2));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WCSSTR_HPP
|
30
sprout/cwchar/wmemchr.hpp
Normal file
30
sprout/cwchar/wmemchr.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
#define SPROUT_CWCHAR_WMEMCHR_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wmemchr_impl(wchar_t const* s, wchar_t c, std::size_t n) {
|
||||
return !n ? 0
|
||||
: *s == c ? s
|
||||
: sprout::detail::wmemchr_impl(s + 1, c, n - 1)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t const* wmemchr(wchar_t const* s, wchar_t c, size_t n) {
|
||||
return sprout::detail::wmemchr_impl(s, c, n);
|
||||
}
|
||||
|
||||
inline SPROUT_CONSTEXPR wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n) {
|
||||
return const_cast<wchar_t*>(
|
||||
sprout::detail::wmemchr_impl(s, c, n)
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WMEMCHR_HPP
|
28
sprout/cwchar/wmemcmp.hpp
Normal file
28
sprout/cwchar/wmemcmp.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef SPROUT_CWCHAR_WMEMCMP_HPP
|
||||
#define SPROUT_CWCHAR_WMEMCMP_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_CONSTEXPR int wmemcmp_impl(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
|
||||
return !n ? 0
|
||||
: *s1 == *s2 ? sprout::detail::wmemcmp_impl(s1 + 1, s2 + 1, n - 1)
|
||||
: *s1 - *s2
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
inline SPROUT_CONSTEXPR int wmemcmp(wchar_t const* s1, wchar_t const* s2, std::size_t n) {
|
||||
return sprout::detail::wmemcmp_impl(
|
||||
s1,
|
||||
s2,
|
||||
n
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CWCHAR_WMEMCMP_HPP
|
Loading…
Add table
Add a link
Reference in a new issue