Don't assert for unexpected FX slot IDs
[openal-soft.git] / common / alstring.h
blob3182889d2ea6faef290d890d2be85223bb1171bf
1 #ifndef AL_STRING_H
2 #define AL_STRING_H
4 #include <algorithm>
5 #include <cstddef>
6 #include <limits>
7 #include <string>
8 #include <string_view>
11 namespace al {
13 template<typename T, typename Traits>
14 [[nodiscard]] constexpr
15 auto sizei(const std::basic_string_view<T,Traits> str) noexcept -> int
16 { return static_cast<int>(std::min<std::size_t>(str.size(), std::numeric_limits<int>::max())); }
18 [[nodiscard]]
19 constexpr bool contains(const std::string_view str0, const std::string_view str1) noexcept
20 { return str0.find(str1) != std::string_view::npos; }
22 [[nodiscard]]
23 constexpr bool starts_with(const std::string_view str0, const std::string_view str1) noexcept
24 { return str0.substr(0, std::min(str0.size(), str1.size())) == str1; }
26 [[nodiscard]]
27 constexpr bool ends_with(const std::string_view str0, const std::string_view str1) noexcept
28 { return str0.substr(str0.size() - std::min(str0.size(), str1.size())) == str1; }
30 [[nodiscard]]
31 int case_compare(const std::string_view str0, const std::string_view str1) noexcept;
33 [[nodiscard]]
34 int case_compare(const std::wstring_view str0, const std::wstring_view str1) noexcept;
36 [[nodiscard]]
37 int strcasecmp(const char *str0, const char *str1) noexcept;
38 [[nodiscard]]
39 int strncasecmp(const char *str0, const char *str1, std::size_t len) noexcept;
41 } // namespace al
43 #endif /* AL_STRING_H */