3ee6028ced9bab405e5cd3f2da32e886b6894ed9
[m17n/m17n-lib.git] / src / m17n-core.h
1 /* m17n-core.h -- header file for the CORE API of the m17n library.
2    Copyright (C) 2003, 2004, 2005, 2006
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    02111-1307, USA.  */
22
23 #ifndef _M17N_CORE_H_
24 #define _M17N_CORE_H_
25
26 #ifdef __cplusplus
27 #define M17N_BEGIN_HEADER extern "C" {
28 #define M17N_END_HEADER }
29 #else
30 #define M17N_BEGIN_HEADER       /* do nothing */
31 #define M17N_END_HEADER         /* do nothing */
32 #endif
33
34 M17N_BEGIN_HEADER
35
36 /*
37  * Header file for m17n library.
38  */
39
40 /* (C1) Introduction */
41
42 /***en @defgroup m17nIntro Introduction  */
43 /***ja @defgroup m17nIntro ¤Ï¤¸¤á¤Ë  */
44 /*=*/
45
46 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
47
48 #define M17NLIB_MAJOR_VERSION 1
49 #define M17NLIB_MINOR_VERSION 3
50 #define M17NLIB_PATCH_LEVEL 5
51 #define M17NLIB_VERSION_NAME "1.3.5"
52
53 extern void m17n_init_core (void);
54 #define M17N_INIT() m17n_init_core ()
55 extern void m17n_fini_core (void);
56 #define M17N_FINI() m17n_fini_core ()
57
58 #endif
59
60 /*=*/
61
62 /*** @ingroup m17nIntro */
63 /***en
64     @brief Enumeration for the status of the m17n library.
65
66     The enum #M17NStatus is used as a return value of the function
67     m17n_status ().  */
68
69 /***ja
70     @brief  m17n ¥é¥¤¥Ö¥é¥ê¤Î¾õÂÖ¤ò¼¨¤¹Îóµó·¿.
71
72     Îóµó·¿ #M17NStatus ¤Ï´Ø¿ô m17n_status () ¤ÎÌá¤êÃͤȤ·¤ÆÍѤ¤¤é¤ì¤ë¡£ */
73
74 enum M17NStatus
75   {
76     /***en No modules is initialized, and all modules are finalized.  */
77     M17N_NOT_INITIALIZED, 
78     /***en Only the modules in CORE API are initialized.  */
79     M17N_CORE_INITIALIZED,
80     /***en Only the modules in CORE and SHELL APIs are initialized.  */
81     M17N_SHELL_INITIALIZED, 
82     /***en All modules are initialized.  */
83     M17N_GUI_INITIALIZED
84   };
85
86 /*=*/
87
88 extern enum M17NStatus m17n_status (void);
89
90 /***en @defgroup m17nCore CORE API  */
91 /***ja @defgroup m17nCore ¥³¥¢ API */
92 /*=*/
93 /*** @ingroup m17nCore */
94 /***en @defgroup m17nObject Managed Object */
95 /***ja @defgroup m17nObject ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È */
96 /*=*/
97
98 /*** @ingroup m17nObject  */
99 /***en
100     @brief The first member of a managed object.
101
102     When an application program defines a new structure for managed
103     objects, its first member must be of the type @c struct
104     #M17NObjectHead.  Its contents are used by the m17n library, and
105     application programs should never touch them.  */
106 /***ja
107     @brief ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤ÎºÇ½é¤Î¥á¥ó¥Ð.
108
109     ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤¬¿·¤·¤¤¹½Â¤ÂΤò´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤È¤·¤ÆÄêµÁ¤¹¤ëºÝ¤Ë¤Ï¡¢ºÇ½é¤Î¥á¥ó¥Ð¤Ï 
110     @c #M17NObjectHead ¹½Â¤Âη¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
111     @c #M17NObjectHead ¤ÎÆâÍƤϠm17n 
112     ¥é¥¤¥Ö¥é¥ê¤¬»ÈÍѤ¹¤ë¤Î¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤Ï¿¨¤ì¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£    */
113
114 typedef struct
115 {
116   void *filler[2];
117 } M17NObjectHead;
118
119 /*=*/
120
121 /* Return a newly allocated managed object.  */
122 extern void *m17n_object (int size, void (*freer) (void *));
123
124 /* Increment the reference count of managed object OBJECT.  */
125 extern int m17n_object_ref (void *object);
126
127 /* Decrement the reference count of managed object OBJECT.  */
128 extern int m17n_object_unref (void *object);
129
130 /*** @ingroup m17nCore */
131 /***en
132     @brief Generic function type.
133
134     #M17NFunc is a generic function type for setting a function
135     pointer as a value of #MSymbol property or #MPlist.  */
136
137 /***ja
138     @brief ÈÆ´Ø¿ô·¿.
139
140     #M17NFunc ¤ÏÈÆ´Ø¿ô·¿¤Ç¤¢¤ê¡¢´Ø¿ô¥Ý¥¤¥ó¥¿¤ò #MSymbol ¥×¥í¥Ñ¥Æ¥£¤ä
141     #MPlist ¤ÎÃͤȤ·¤ÆÀßÄꤹ¤ëºÝÍѤ¤¤ë¡£  */
142
143
144 /***
145     @seealso
146     msymbol_put_func (), msymbol_get_func (),
147     mplist_put_func (), mplist_get_func ().  */
148
149 typedef void (*M17NFunc) (void);
150
151 /*=*/
152
153 /*** @ingroup m17nCore */
154 /***en
155     @brief Wrapper for a generic function type.
156
157     The macro M17N_FUNC () casts a function to the type #M17NFunc.  */
158
159 /***ja
160     @brief ÈÆ´Ø¿ô·¿¤Ø¤Î¥é¥Ã¥Ñ.
161
162     ¥Þ¥¯¥í M17N_FUNC () ¤Ï´Ø¿ô¤ò #M17NFunc ·¿¤Ø¥­¥ã¥¹¥È¤¹¤ë¡£  */
163
164
165 #define M17N_FUNC(func) ((M17NFunc) (func))
166
167 /*=*/
168
169 /* (C2) Symbol handling */
170
171 /*** @ingroup m17nCore */
172 /***en @defgroup m17nSymbol Symbol  */
173 /***ja @defgroup m17nSymbol ¥·¥ó¥Ü¥ë */
174 /*=*/
175
176 /***
177     @ingroup m17nSymbol */
178 /***en
179     @brief Type of symbols.
180
181     The type #MSymbol is for a @e symbol object.  Its internal
182     structure is concealed from application programs.  */
183
184 /***ja
185     @brief ¥·¥ó¥Ü¥ë¤Î·¿Àë¸À.
186
187     #MSymbol ¤Ï @e ¥·¥ó¥Ü¥ë (symbol) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
188     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
189
190 typedef struct MSymbolStruct *MSymbol;
191
192 /*=*/
193
194 /* Predefined symbols. */ 
195 extern MSymbol Mnil;
196 extern MSymbol Mt;
197 extern MSymbol Mstring;
198 extern MSymbol Msymbol;
199 extern MSymbol Mtext;
200
201 /* Return a symbol of name NAME.  */
202 extern MSymbol msymbol (const char *name);
203
204 /* Return a managing key of name NAME.  */
205 extern MSymbol msymbol_as_managing_key (const char *name);
206
207 /* Check if SYMBOL is a managing key.  */
208 extern int msymbol_is_managing_key (MSymbol symbol);
209
210 /* Return a symbol of name NAME if it already exists.  */
211 extern MSymbol msymbol_exist (const char *name);
212
213 /* Return the name of SYMBOL.  */
214 extern char *msymbol_name (MSymbol symbol);
215
216 /* Give SYMBOL KEY property with value VALUE.  */
217 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
218
219 /*** Return KEY property value of SYMBOL.  */
220 extern void *msymbol_get (MSymbol symbol, MSymbol key);
221
222 extern int msymbol_put_func (MSymbol symbol, MSymbol key, M17NFunc func);
223
224 extern M17NFunc msymbol_get_func (MSymbol symbol, MSymbol key);
225
226 /* 
227  *  (2-1) Property List
228  */
229 /*=*/
230 /*** @ingroup m17nCore */
231 /***en @defgroup m17nPlist Property List */
232 /***ja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È */
233 /*=*/
234
235 /***
236     @ingroup m17nPlist */ 
237 /***en
238     @brief Type of property list objects.
239
240     The type #MPlist is for a @e property @e list object.  Its internal
241     structure is concealed from application programs.  */
242
243 /***ja
244     @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿Àë¸À.
245
246     #MPlist ¤Ï @e ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È (Property list) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
247     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
248
249 typedef struct MPlist MPlist;
250
251 /*=*/
252
253 extern MSymbol Mplist, Minteger;
254
255 extern MPlist *mplist ();
256
257 extern MPlist *mplist_copy (MPlist *plist);
258
259 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
260
261 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
262
263 extern void *mplist_pop (MPlist *plist);
264
265 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
266
267 extern void *mplist_get (MPlist *plist, MSymbol key);
268
269 extern MPlist *mplist_put_func (MPlist *plist, MSymbol key, M17NFunc func);
270
271 extern M17NFunc mplist_get_func (MPlist *plist, MSymbol key);
272
273 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
274
275 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
276
277 extern MPlist *mplist_next (MPlist *plist);
278
279 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
280
281 extern int mplist_length (MPlist *plist);
282
283 extern MSymbol mplist_key (MPlist *plist);
284
285 extern void *mplist_value (MPlist *plist);
286
287 /* (S1) Characters */
288
289 /*=*/
290 /*** @ingroup m17nCore */
291 /***en @defgroup m17nCharacter Character */
292 /***ja @defgroup m17nCharacter Ê¸»ú */
293 /*=*/
294
295 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
296 #define MCHAR_MAX 0x3FFFFF
297 /*#define MCHAR_MAX 0x7FFFFFFF*/
298 #endif
299
300 extern MSymbol Mscript;
301 extern MSymbol Mname;
302 extern MSymbol Mcategory;
303 extern MSymbol Mcombining_class;
304 extern MSymbol Mbidi_category;
305 extern MSymbol Msimple_case_folding;
306 extern MSymbol Mcomplicated_case_folding;
307
308 extern MSymbol mchar_define_property (const char *name, MSymbol type);
309
310 extern void *mchar_get_prop (int c, MSymbol key);
311
312 extern int mchar_put_prop (int c, MSymbol key, void *val);
313
314 /* (C3) Handling chartable */
315
316 /*** @ingroup m17nCore */
317 /***en @defgroup m17nChartable Chartable */
318 /***ja @defgroup m17nChartable Ê¸»ú¥Æ¡¼¥Ö¥ë */
319 /*=*/
320 extern MSymbol Mchar_table;
321
322 /***
323     @ingroup m17nChartable */
324 /***en
325     @brief Type of chartables.
326
327     The type #MCharTable is for a @e chartable objects.  Its
328     internal structure is concealed from application programs.  */
329
330 /***ja
331     @brief Ê¸»ú¥Æ¡¼¥Ö¥ë¤Î·¿Àë¸À.
332
333     #MCharTable ¤Ï @e Ê¸»ú¥Æ¡¼¥Ö¥ë (chartable) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
334     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
335
336 typedef struct MCharTable MCharTable;
337 /*=*/
338
339 extern MCharTable *mchartable (MSymbol key, void *default_value);
340
341 extern void *mchartable_lookup (MCharTable *table, int c);
342
343 extern int mchartable_set (MCharTable *table, int c, void *val);
344
345 extern int mchartable_set_range (MCharTable *table, int from, int to,
346                                  void *val);
347
348 extern int mchartable_map (MCharTable *table, void *ignore,
349                            void (*func) (int, int, void *, void *), 
350                            void *func_arg);
351
352 extern void mchartable_range (MCharTable *table, int *from, int *to);
353
354 extern MCharTable *mchar_get_prop_table (MSymbol key, MSymbol *type);
355
356 /*
357  *  (5) Handling M-text.
358  *      "M" of M-text stands for:
359  *      o Multilingual
360  *      o Metamorphic
361  *      o More than string
362  */
363
364 /*** @ingroup m17nCore */
365 /***en @defgroup m17nMtext M-text */
366 /***ja @defgroup m17nMtext M-text */
367 /*=*/
368
369 /*
370  * (5-1) M-text basics
371  */
372 /*=*/
373 /*** @ingroup m17nMtext */
374 /***en
375     @brief Type of @e M-texts.
376
377     The type #MText is for an @e M-text object.  Its internal
378     structure is concealed from application programs.  */
379
380 /***ja
381     @brief @e MText ¤Î·¿Àë¸À.
382
383     #Mtext ¤Ï @e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
384     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£ 
385
386     @latexonly \IPAlabel{MText} @endlatexonly
387     @latexonly \IPAlabel{MText->MPlist} @endlatexonly  */
388
389 typedef struct MText MText;
390
391 /*=*/
392
393 /*** @ingroup m17nMtext */
394 /***en
395     @brief Enumeration for specifying the format of an M-text.
396
397     The enum #MTextFormat is used as an argument of the
398     mtext_from_data () function to specify the format of data from
399     which an M-text is created.  */
400
401 /***ja
402     @brief M-text ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ëÎóµó·¿.
403
404     Îóµó·¿ #MTextFormat ¤Ï´Ø¿ô
405     mtext_from_data () ¤Î°ú¿ô¤È¤·¤ÆÍѤ¤¤é¤ì¡¢
406     M-text ¤òÀ¸À®¤¹¤ë¸µ¤È¤Ê¤ë¥Ç¡¼¥¿¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ë¡£  */
407
408 enum MTextFormat
409   {
410     MTEXT_FORMAT_US_ASCII,
411     MTEXT_FORMAT_UTF_8,
412     MTEXT_FORMAT_UTF_16LE,
413     MTEXT_FORMAT_UTF_16BE,
414     MTEXT_FORMAT_UTF_32LE,
415     MTEXT_FORMAT_UTF_32BE,
416     MTEXT_FORMAT_MAX
417   };
418 /*=*/
419
420 extern MText *mtext ();
421
422 extern void *mtext_data (MText *mt, enum MTextFormat *fmt, int *nunits,
423                          int *pos_idx, int *unit_idx);
424
425 /*=*/
426
427 /***en @name Variables: Default Endian of UTF-16 and UTF-32 */
428 /***ja @name ÊÑ¿ô: UTF-16 ¤È UTF-32 ¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥¨¥ó¥Ç¥£¥¢¥ó */
429 /*** @{ */
430 /*=*/
431
432 /*** @ingroup m17nMtext */
433 /***en
434     @brief Variable of value MTEXT_FORMAT_UTF_16LE or MTEXT_FORMAT_UTF_16BE.
435
436     The global variable #MTEXT_FORMAT_UTF_16 is initialized to
437     #MTEXT_FORMAT_UTF_16LE on a "Little Endian" system (storing words
438     with the least significant byte first), and to
439     #MTEXT_FORMAT_UTF_16BE on a "Big Endian" system (storing words
440     with the most significant byte first).  */
441
442 /***ja
443     @brief Ãͤ¬ MTEXT_FORMAT_UTF_16LE ¤« MTEXT_FORMAT_UTF_16BE ¤Ç¤¢¤ëÊÑ¿ô
444
445     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_16 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
446     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
447     #MTEXT_FORMAT_UTF_16LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
448     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
449     #MTEXT_FORMAT_UTF_16BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
450
451 /***
452     @seealso
453     mtext_from_data ()  */
454
455 extern const enum MTextFormat MTEXT_FORMAT_UTF_16;
456 /*=*/
457
458 /*** @ingroup m17nMtext */
459 /***en
460     @brief Variable of value MTEXT_FORMAT_UTF_32LE or MTEXT_FORMAT_UTF_32BE.
461
462     The global variable #MTEXT_FORMAT_UTF_32 is initialized to
463     #MTEXT_FORMAT_UTF_32LE on a "Little Endian" system (storing words
464     with the least significant byte first), and to
465     #MTEXT_FORMAT_UTF_32BE on a "Big Endian" system (storing
466     words with the most significant byte first).  */
467
468 /***ja
469     @brief Ãͤ¬ MTEXT_FORMAT_UTF_32LE ¤« MTEXT_FORMAT_UTF_32BE ¤Ç¤¢¤ëÊÑ¿ô
470
471     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_32 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
472     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
473     #MTEXT_FORMAT_UTF_32LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
474     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
475     #MTEXT_FORMAT_UTF_32BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
476
477 /***
478     @seealso
479     mtext_from_data ()  */
480
481 extern const int MTEXT_FORMAT_UTF_32;
482
483 /*=*/
484 /*** @} */
485 /*=*/
486
487 extern MText *mtext_from_data (const void *data, int nitems,
488                                enum MTextFormat format);
489
490 /*=*/
491 /*** @} */
492
493 extern MSymbol Mlanguage;
494
495 /*
496  *  (5-2) Functions to manipulate M-texts.  They correspond to string
497  *   manipulating functions in libc.
498  *   In the following functions, mtext_XXX() corresponds to strXXX().
499  */
500
501 extern int mtext_len (MText *mt);
502
503 extern int mtext_ref_char (MText *mt, int pos);
504
505 extern int mtext_set_char (MText *mt, int pos, int c);
506
507 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
508
509 extern int mtext_compare (MText *mt1, int from1, int to1,
510                           MText *mt2, int from2, int to2);
511
512 extern int mtext_case_compare (MText *mt1, int from1, int to1,
513                                MText *mt2, int from2, int to2);
514
515 extern int mtext_character (MText *mt, int from, int to, int c);
516
517 extern int mtext_del (MText *mt, int from, int to);
518
519 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
520
521 extern int mtext_insert (MText *mt1, int pos, MText *mt2, int from, int to);
522
523 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
524
525 extern int mtext_replace (MText *mt1, int from1, int to1,
526                           MText *mt2, int from2, int to2);
527
528 extern MText *mtext_cat_char (MText *mt, int c);
529
530 extern MText *mtext_duplicate (MText *mt, int from, int to);
531
532 extern MText *mtext_dup (MText *mt);
533
534 extern MText *mtext_cat (MText *mt1, MText *mt2);
535
536 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
537
538 extern MText *mtext_cpy (MText *mt1, MText *mt2);
539
540 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
541
542 extern int mtext_chr (MText *mt, int c);
543
544 extern int mtext_rchr (MText *mt, int c);
545
546 extern int mtext_cmp (MText *mt1, MText *mt2);
547
548 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
549
550 extern int mtext_spn (MText *mt1, MText *mt2);
551
552 extern int mtext_cspn (MText *mt1, MText *mt2);
553
554 extern int mtext_pbrk (MText *mt1, MText *mt2);
555
556 extern int mtext_text (MText *mt1, int pos, MText *mt2);
557
558 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
559
560 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
561
562 extern int mtext_casecmp (MText *mt1, MText *mt2);
563
564 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
565
566 extern int mtext_lowercase (MText *mt);
567
568 extern int mtext_titlecase (MText *mt);
569
570 extern int mtext_uppercase (MText *mt);
571
572 /***en
573     @brief Enumeration for specifying a set of line breaking option.
574
575     The enum #MTextLineBreakOption is to control the line breaking
576     algorithm of the function mtext_line_break () by specifying
577     logical-or of the members in the arg @e option.  */
578
579 enum MTextLineBreakOption
580   {
581     /***en Specify the legacy support for space character as base for
582        combining marks.  See the section 8.3 of UAX#14. */
583     MTEXT_LBO_SP_CM = 1,
584     /***en Specify to use space characters for line breaking Korean
585         text.  */
586     MTEXT_LBO_KOREAN_SP = 2,
587     /***en Specify to treat characters of ambiguous line-breaking
588         class as of ideographic line-breaking class.  */
589     MTEXT_LBO_AI_AS_ID = 4,
590     MTEXT_LBO_MAX
591   };
592
593 extern int mtext_line_break (MText *mt, int pos, int option, int *after);
594
595 /*** @ingroup m17nPlist */
596 extern MPlist *mplist_deserialize (MText *mt);
597
598 /*
599  * (5-3) Text properties
600  */
601 /*=*/
602 /*** @ingroup m17nCore */
603 /***en @defgroup m17nTextProperty Text Property */
604 /***ja @defgroup m17nTextProperty ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
605 /*=*/
606 /*** @ingroup m17nTextProperty */
607 /***en
608     @brief Flag bits to control text property.
609
610     The mtext_property () function accepts logical OR of these flag
611     bits as an argument.  They control the behaviour of the created
612     text property as described in the documentation of each flag
613     bit.  */
614
615 /***ja
616     @brief ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤òÀ©¸æ¤¹¤ë¥Õ¥é¥°¥Ó¥Ã¥È.
617
618     ´Ø¿ô mtext_property () ¤Ï°Ê²¼¤Î¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÏÀÍý
619     OR ¤ò°ú¿ô¤È¤·¤Æ¤È¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
620     ¥Õ¥é¥°¥Ó¥Ã¥È¤ÏÀ¸À®¤µ¤ì¤¿¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î¿¶Éñ¤¤¤òÀ©¸æ¤¹¤ë¡£
621     ¾ÜºÙ¤Ï³Æ¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÀâÌÀ¤ò»²¾È¡£*/
622
623 enum MTextPropertyControl
624   {
625     /***en If this flag bit is on, an M-text inserted at the start
626         position or at the middle of the text property inherits the
627         text property.  */
628     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î»Ï¤Þ¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
629         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
630         */
631     MTEXTPROP_FRONT_STICKY = 0x01,
632
633     /***en If this flag bit is on, an M-text inserted at the end
634         position or at the middle of the text property inherits the
635         text property.  */
636     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î½ª¤ï¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
637         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
638         */
639     MTEXTPROP_REAR_STICKY = 0x02,
640
641     /***en If this flag bit is on, the text property is removed if a
642         text in its region is modified.  */
643     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£  */
644     MTEXTPROP_VOLATILE_WEAK = 0x04,
645
646     /***en If this flag bit is on, the text property is removed if a
647         text or the other text property in its region is modified.  */
648     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¢¤ë¤¤¤ÏÊ̤Υƥ­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¤³¤Î¥Æ¥­
649         ¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£*/
650     MTEXTPROP_VOLATILE_STRONG = 0x08,
651
652     /***en If this flag bit is on, the text property is not
653         automatically merged with the others.  */
654     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¾¤Î¥×¥í¥Ñ¥Æ¥£¤È¼«Æ°Åª¤Ë¤Ï¥Þ¡¼¥¸¤µ¤ì¤Ê¤¤¡£ */
655     MTEXTPROP_NO_MERGE = 0x10,
656
657     MTEXTPROP_CONTROL_MAX = 0x1F
658   };
659
660 /*=*/
661 extern MSymbol Mtext_prop_serializer;
662 extern MSymbol Mtext_prop_deserializer;
663
664
665 /*** @ingroup m17nTextProperty */
666 /***en
667     @brief Type of serializer functions.
668
669     This is the type of serializer functions.  If the key of a symbol
670     property is #Mtext_prop_serializer, the value must be of this
671     type.
672
673     @seealso
674     mtext_serialize (), #Mtext_prop_serializer
675 */
676 /***ja
677     @brief ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
678
679     ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
680     #Mtext_prop_serializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
681
682     @seealso
683     mtext_serialize (), #Mtext_prop_serializer
684 */
685
686 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
687
688 /*** @ingroup m17nTextProperty */
689 /***en
690     @brief Type of deserializer functions.
691
692     This is the type of deserializer functions.  If the key of a
693     symbol property is #Mtext_prop_deserializer, the value must be of
694     this type.
695
696     @seealso
697     mtext_deserialize (), #Mtext_prop_deserializer
698 */
699 /***ja
700     @brief ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
701
702     ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
703     #Msymbol_prop_deserializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
704
705     @seealso
706     Mtext_prop_deserialize (), Mtext_prop_deserializer
707 */
708 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
709
710 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
711
712 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
713                                   void **values, int num);
714
715 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
716
717 extern int mtext_put_prop (MText *mt, int from, int to,
718                            MSymbol key, void *val);
719
720 extern int mtext_put_prop_values (MText *mt, int from, int to,
721                                   MSymbol key, void **values, int num);
722
723 extern int mtext_push_prop (MText *mt, int from, int to,
724                             MSymbol key, void *val);
725
726 extern int mtext_pop_prop (MText *mt, int from, int to,
727                            MSymbol key);
728
729 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
730                              int *from, int *to, int deeper);
731
732 /*=*/
733 /***
734     @ingroup m17nTextProperty */
735 /***en
736     @brief Type of text properties.
737
738     The type #MTextProperty is for a @e text @e property objects.  Its
739     internal structure is concealed from application programs.  */
740 /***ja
741     @brief @c ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î·¿Àë¸À.
742
743     #MTextProperty ¤Ï @e ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
744     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
745
746 typedef struct MTextProperty MTextProperty;
747
748 /*=*/
749
750 extern MTextProperty *mtext_property (MSymbol key, void *val,
751                                       int control_bits);
752
753 extern MText *mtext_property_mtext (MTextProperty *prop);
754
755 extern MSymbol mtext_property_key (MTextProperty *prop);
756
757 extern void *mtext_property_value (MTextProperty *prop);
758
759 extern int mtext_property_start (MTextProperty *prop);
760
761 extern int mtext_property_end (MTextProperty *prop);
762
763 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
764
765 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
766                                  MTextProperty **props, int num);
767
768 extern int mtext_attach_property (MText *mt, int from, int to,
769                                   MTextProperty *prop);
770
771 extern int mtext_detach_property (MTextProperty *prop);
772
773 extern int mtext_push_property (MText *mt, int from, int to,
774                                 MTextProperty *prop);
775
776 extern MText *mtext_serialize (MText *mt, int from, int to,
777                                MPlist *property_list);
778
779 extern MText *mtext_deserialize (MText *mt);
780
781 M17N_END_HEADER
782
783 #endif /* _M17N_CORE_H_ */
784
785 /*
786   Local Variables:
787   coding: euc-japan
788   End:
789 */