19 #ifndef NUSPELL_UTILS_HXX 20 #define NUSPELL_UTILS_HXX 22 #include "nuspell_export.h" 25 #include <string_view> 28 #include <unicode/locid.h> 31 #define likely(expr) __builtin_expect(!!(expr), 1) 32 #define unlikely(expr) __builtin_expect(!!(expr), 0) 34 #define likely(expr) (expr) 35 #define unlikely(expr) (expr) 43 NUSPELL_DEPRECATED_EXPORT
auto split_on_any_of(std::string_view s,
45 std::vector<std::string>& out)
46 -> std::vector<std::string>&;
48 NUSPELL_EXPORT
auto utf32_to_utf8(std::u32string_view in, std::string& out)
50 NUSPELL_EXPORT
auto utf32_to_utf8(std::u32string_view in) -> std::string;
52 auto valid_utf8_to_32(std::string_view in, std::u32string& out) -> void;
53 auto valid_utf8_to_32(std::string_view in) -> std::u32string;
55 auto utf8_to_16(std::string_view in) -> std::u16string;
56 auto utf8_to_16(std::string_view in, std::u16string& out) -> bool;
58 auto validate_utf8(std::string_view s) -> bool;
60 NUSPELL_EXPORT
auto is_all_ascii(std::string_view s) -> bool;
62 NUSPELL_EXPORT
auto latin1_to_ucs2(std::string_view s) -> std::u16string;
63 auto latin1_to_ucs2(std::string_view s, std::u16string& out) -> void;
65 NUSPELL_EXPORT
auto is_all_bmp(std::u16string_view s) -> bool;
67 auto to_upper_ascii(std::string& s) -> void;
69 [[nodiscard]] NUSPELL_EXPORT
auto to_upper(std::string_view in,
70 const icu::Locale& loc)
72 [[nodiscard]] NUSPELL_EXPORT
auto to_title(std::string_view in,
73 const icu::Locale& loc)
75 [[nodiscard]] NUSPELL_EXPORT
auto to_lower(std::string_view in,
76 const icu::Locale& loc)
79 auto to_upper(std::string_view in,
const icu::Locale& loc, std::string& out)
81 auto to_title(std::string_view in,
const icu::Locale& loc, std::string& out)
83 auto to_lower(std::u32string_view in,
const icu::Locale& loc,
84 std::u32string& out) -> void;
85 auto to_lower(std::string_view in,
const icu::Locale& loc, std::string& out)
87 auto to_lower_char_at(std::string& s,
size_t i,
const icu::Locale& loc) -> void;
88 auto to_title_char_at(std::string& s,
size_t i,
const icu::Locale& loc) -> void;
97 enum class Casing : char {
105 NUSPELL_EXPORT
auto classify_casing(std::string_view s) -> Casing;
107 auto has_uppercase_at_compound_word_boundary(std::string_view word,
size_t i)
111 UConverter* cnv =
nullptr;
132 std::swap(cnv, other.cnv);
135 auto to_utf8(std::string_view in, std::string& out) -> bool;
136 auto valid() ->
bool {
return cnv !=
nullptr; }
139 auto replace_ascii_char(std::string& s,
char from,
char to) -> void;
140 auto erase_chars(std::string& s, std::string_view erase_chars) -> void;
141 NUSPELL_EXPORT
auto is_number(std::string_view s) -> bool;
142 auto count_appereances_of(std::string_view haystack, std::string_view needles)
145 auto inline begins_with(std::string_view haystack, std::string_view needle)
148 return haystack.compare(0, needle.size(), needle) == 0;
151 auto inline ends_with(std::string_view haystack, std::string_view needle)
154 return haystack.size() >= needle.size() &&
155 haystack.compare(haystack.size() - needle.size(), needle.size(),
167 return x.data() + x.size();
171 #endif // NUSPELL_UTILS_HXX Library main namespace.
Definition: aff_data.cxx:33
Definition: utils.hxx:110