1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Index Data nor the names of its contributors
13 * may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \brief Internal header for ICU utilities
35 #include <yaz/yconfig.h>
37 #include <unicode/utypes.h> /* Basic ICU data types */
38 #include <unicode/uchar.h> /* char names */
40 #include <unicode/ucol.h>
41 #include <unicode/ubrk.h>
42 #include <unicode/utrans.h>
46 /* declared structs and functions */
48 int icu_check_status (UErrorCode status);
57 struct icu_buf_utf16 * icu_buf_utf16_create(size_t capacity);
59 struct icu_buf_utf16 * icu_buf_utf16_clear(struct icu_buf_utf16 * buf16);
61 struct icu_buf_utf16 * icu_buf_utf16_resize(struct icu_buf_utf16 * buf16,
64 struct icu_buf_utf16 * icu_buf_utf16_copy(struct icu_buf_utf16 * dest16,
65 struct icu_buf_utf16 * src16);
67 void icu_buf_utf16_destroy(struct icu_buf_utf16 * buf16);
78 struct icu_buf_utf8 * icu_buf_utf8_create(size_t capacity);
80 struct icu_buf_utf8 * icu_buf_utf8_clear(struct icu_buf_utf8 * buf8);
82 struct icu_buf_utf8 * icu_buf_utf8_resize(struct icu_buf_utf8 * buf8,
85 void icu_buf_utf8_destroy(struct icu_buf_utf8 * buf8);
88 UErrorCode icu_utf16_from_utf8(struct icu_buf_utf16 * dest16,
89 struct icu_buf_utf8 * src8,
92 UErrorCode icu_utf16_from_utf8_cstr(struct icu_buf_utf16 * dest16,
93 const char * src8cstr,
97 UErrorCode icu_utf16_to_utf8(struct icu_buf_utf8 * dest8,
98 struct icu_buf_utf16 * src16,
106 struct icu_casemap * icu_casemap_create(char action, UErrorCode *status);
108 void icu_casemap_destroy(struct icu_casemap * casemap);
110 int icu_casemap_casemap(struct icu_casemap * casemap,
111 struct icu_buf_utf16 * dest16,
112 struct icu_buf_utf16 * src16,
116 int icu_utf16_casemap(struct icu_buf_utf16 * dest16,
117 struct icu_buf_utf16 * src16,
118 const char *locale, char action,
121 void icu_sortkey8_from_utf16(UCollator *coll,
122 struct icu_buf_utf8 * dest8,
123 struct icu_buf_utf16 * src16,
124 UErrorCode * status);
130 struct icu_buf_utf16 * buf16;
136 keep always invariant
141 0 <= token_id <= token_count
145 struct icu_tokenizer * icu_tokenizer_create(const char *locale, char action,
148 void icu_tokenizer_destroy(struct icu_tokenizer * tokenizer);
150 int icu_tokenizer_attach(struct icu_tokenizer * tokenizer,
151 struct icu_buf_utf16 * src16, UErrorCode *status);
153 int32_t icu_tokenizer_next_token(struct icu_tokenizer * tokenizer,
154 struct icu_buf_utf16 * tkn16,
157 int32_t icu_tokenizer_token_id(struct icu_tokenizer * tokenizer);
158 int32_t icu_tokenizer_token_start(struct icu_tokenizer * tokenizer);
159 int32_t icu_tokenizer_token_end(struct icu_tokenizer * tokenizer);
160 int32_t icu_tokenizer_token_length(struct icu_tokenizer * tokenizer);
161 int32_t icu_tokenizer_token_count(struct icu_tokenizer * tokenizer);
168 struct icu_buf_utf16 * rules16;
169 UParseError parse_error;
170 UTransliterator * trans;
173 struct icu_transform * icu_transform_create(const char *rules, char action,
177 void icu_transform_destroy(struct icu_transform * transform);
179 int icu_transform_trans(struct icu_transform * transform,
180 struct icu_buf_utf16 * dest16,
181 struct icu_buf_utf16 * src16,
184 enum icu_chain_step_type {
185 ICU_chain_step_type_none,
186 ICU_chain_step_type_display, /* convert to utf8 display format */
187 ICU_chain_step_type_casemap, /* apply utf16 charmap */
188 ICU_chain_step_type_transform, /* apply utf16 transform */
189 ICU_chain_step_type_tokenize /* apply utf16 tokenization */
194 struct icu_chain_step
196 /* type and action object */
197 enum icu_chain_step_type type;
199 struct icu_casemap * casemap;
200 struct icu_transform * transform;
201 struct icu_tokenizer * tokenizer;
203 /* temprary post-action utf16 buffer */
204 struct icu_buf_utf16 * buf16;
205 struct icu_chain_step * previous;
213 struct icu_chain_step * icu_chain_step_create(yaz_icu_chain_t chain,
214 enum icu_chain_step_type type,
215 const uint8_t * rule,
216 struct icu_buf_utf16 * buf16,
220 void icu_chain_step_destroy(struct icu_chain_step * step);
228 const char * src8cstr;
232 /* number of tokens returned so far */
235 /* utf8 output buffers */
236 struct icu_buf_utf8 * display8;
237 struct icu_buf_utf8 * norm8;
238 struct icu_buf_utf8 * sort8;
240 /* utf16 source buffer */
241 struct icu_buf_utf16 * src16;
243 /* linked list of chain steps */
244 struct icu_chain_step * steps;
247 struct icu_chain_step * icu_chain_insert_step(yaz_icu_chain_t chain,
248 enum icu_chain_step_type type,
249 const uint8_t * rule,
252 int icu_chain_step_next_token(yaz_icu_chain_t chain,
253 struct icu_chain_step * step,
256 int icu_chain_token_number(yaz_icu_chain_t chain);
258 const UCollator * icu_chain_get_coll(yaz_icu_chain_t chain);
260 #endif /* ICU_I18NL_H */
265 * c-file-style: "Stroustrup"
266 * indent-tabs-mode: nil
268 * vim: shiftwidth=4 tabstop=8 expandtab