1#ifndef NU_STRCOLL_H
2#define NU_STRCOLL_H
3
4/** @defgroup collation Collation functions
5 *
6 * All functions in this group are following full Unicode collation rules,
7 * i.e. nu_strstr(haystack, "Æ") will find "AE" in haystack and
8 * nu_strstr(haystack, "ß") will find "ss".
9 *
10 * Same applies for *every* function, nu_strchr(str, 0x00DF), as you would
11 * guess, will also find "ss" in str.
12 *
13 * Please expect this.
14 *
15 * Note on "n" functions variant: please see comment on this topic
16 * in strings.h
17 */
18
19#include <sys/types.h>
20
21#include <libnu/config.h>
22#include <libnu/casemap.h>
23#include <libnu/defines.h>
24#include <libnu/strings.h>
25
26#if defined (__cplusplus) || defined (c_plusplus)
27extern "C" {
28#endif
29
30#ifdef NU_WITH_TOFOLD
31# define NU_FOLDING_FUNCTION nu_tofold
32#else
33# define NU_FOLDING_FUNCTION nu_toupper
34#endif /* NU_WITH_TOFOLD */
35
36#ifdef NU_WITH_Z_COLLATION
37
38/** Locate codepoint in string
39 *
40 * @ingroup collation
41 * @param encoded encoded string
42 * @param c charater to locate
43 * @param read read (decode) function for encoded string
44 * @return pointer to codepoint in string or 0
45 */
46NU_EXPORT
47const char* nu_strchr(const char *encoded, uint32_t c, nu_read_iterator_t read);
48
49/** Locate codepoint in string ignoring case
50 *
51 * @ingroup collation
52 * @see nu_strchr
53 */
54NU_EXPORT
55const char* nu_strcasechr(const char *encoded, uint32_t c, nu_read_iterator_t read);
56
57/** Locate codepoint in string in reverse direction
58 *
59 * @ingroup collation
60 * @param encoded encoded string
61 * @param c charater to locate
62 * @param read read (decode) function for encoded string
63 * @return pointer to codepoint in string or 0
64 */
65NU_EXPORT
66const char* nu_strrchr(const char *encoded, uint32_t c, nu_read_iterator_t read);
67
68/** Locate codepoint in string in reverse direction, case-insensitive
69 *
70 * @ingroup collation
71 * @see nu_strrchr
72 */
73NU_EXPORT
74const char* nu_strrcasechr(const char *encoded, uint32_t c, nu_read_iterator_t read);
75
76/** Compare strings in case-sensitive manner.
77 *
78 * @ingroup collation
79 * @param s1 first encoded strings
80 * @param s2 second encoded strings
81 * @param s1_read read (decode) function for first string
82 * @param s2_read read (decode) function for second string
83 * @return -1, 0, 1
84 */
85NU_EXPORT
86int nu_strcoll(const char *s1, const char *s2,
87 nu_read_iterator_t s1_read, nu_read_iterator_t s2_read);
88
89/** Compare strings in case-insensitive manner.
90 *
91 * @ingroup collation
92 * @see nu_strcoll
93 */
94NU_EXPORT
95int nu_strcasecoll(const char *s1, const char *s2,
96 nu_read_iterator_t s1_read, nu_read_iterator_t s2_read);
97
98/** Find needle in haystack
99 *
100 * @ingroup collation
101 * @param haystack encoded haystack
102 * @param needle encoded needle
103 * @param haystack_read haystack read (decode) function
104 * @param needle_read needle read (decode) function
105 * @return pointer to found string or 0, will return
106 * haystack if needle is empty string
107 */
108NU_EXPORT
109const char* nu_strstr(const char *haystack, const char *needle,
110 nu_read_iterator_t haystack_read, nu_read_iterator_t needle_read);
111
112/** Find needle in haystack (case-insensitive)
113 *
114 * @ingroup collation
115 * @see nu_strstr
116 */
117NU_EXPORT
118const char* nu_strcasestr(const char *haystack, const char *needle,
119 nu_read_iterator_t haystack_read, nu_read_iterator_t needle_read);
120
121#endif /* NU_WITH_Z_COLLATION */
122
123#ifdef NU_WITH_N_COLLATION
124
125/**
126 * @ingroup collation
127 * @see nu_strchr
128 */
129NU_EXPORT
130const char* nu_strnchr(const char *encoded, size_t max_len, uint32_t c,
131 nu_read_iterator_t read);
132
133/**
134 * @ingroup collation
135 * @see nu_strcasechr
136 */
137NU_EXPORT
138const char* nu_strcasenchr(const char *encoded, size_t max_len, uint32_t c,
139 nu_read_iterator_t read);
140
141/**
142 * @ingroup collation
143 * @see nu_strrchr
144 */
145NU_EXPORT
146const char* nu_strrnchr(const char *encoded, size_t max_len, uint32_t c,
147 nu_read_iterator_t read);
148
149/**
150 * @ingroup collation
151 * @see nu_strrcasechr
152 */
153NU_EXPORT
154const char* nu_strrcasenchr(const char *encoded, size_t max_len, uint32_t c,
155 nu_read_iterator_t read);
156
157/**
158 * @ingroup collation
159 * @see nu_strcoll
160 */
161NU_EXPORT
162int nu_strncoll(const char *s1, size_t s1_max_len,
163 const char *s2, size_t s2_max_len,
164 nu_read_iterator_t s1_read, nu_read_iterator_t s2_read);
165
166/**
167 * @ingroup collation
168 * @see nu_strncoll
169 */
170NU_EXPORT
171int nu_strcasencoll(const char *s1, size_t s1_max_len,
172 const char *s2, size_t s2_max_len,
173 nu_read_iterator_t s1_read, nu_read_iterator_t s2_read);
174
175/**
176 * @ingroup collation
177 * @see nu_strstr
178 */
179NU_EXPORT
180const char* nu_strnstr(const char *haystack, size_t haystack_max_len,
181 const char *needle, size_t needle_max_len,
182 nu_read_iterator_t haystack_read, nu_read_iterator_t needle_read);
183
184/**
185 * @ingroup collation
186 * @see nu_strcasestr
187 */
188NU_EXPORT
189const char* nu_strcasenstr(const char *haystack, size_t haystack_max_len,
190 const char *needle, size_t needle_max_len,
191 nu_read_iterator_t haystack_read, nu_read_iterator_t needle_read);
192
193#endif /* NU_WITH_N_COLLATION */
194
195#if defined (__cplusplus) || defined (c_plusplus)
196}
197#endif
198
199#endif /* NU_STRCOLL_H */
200

source code of qtlocation/src/3rdparty/mapbox-gl-native/vendor/nunicode/include/libnu/strcoll.h