merge FLT
[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 extern MSymbol Mcharset;
201
202 /* Return a symbol of name NAME.  */
203 extern MSymbol msymbol (const char *name);
204
205 /* Return a managing key of name NAME.  */
206 extern MSymbol msymbol_as_managing_key (const char *name);
207
208 /* Check if SYMBOL is a managing key.  */
209 extern int msymbol_is_managing_key (MSymbol symbol);
210
211 /* Return a symbol of name NAME if it already exists.  */
212 extern MSymbol msymbol_exist (const char *name);
213
214 /* Return the name of SYMBOL.  */
215 extern char *msymbol_name (MSymbol symbol);
216
217 /* Give SYMBOL KEY property with value VALUE.  */
218 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
219
220 /*** Return KEY property value of SYMBOL.  */
221 extern void *msymbol_get (MSymbol symbol, MSymbol key);
222
223 extern int msymbol_put_func (MSymbol symbol, MSymbol key, M17NFunc func);
224
225 extern M17NFunc msymbol_get_func (MSymbol symbol, MSymbol key);
226
227 /* 
228  *  (2-1) Property List
229  */
230 /*=*/
231 /*** @ingroup m17nCore */
232 /***en @defgroup m17nPlist Property List */
233 /***ja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È */
234 /*=*/
235
236 /***
237     @ingroup m17nPlist */ 
238 /***en
239     @brief Type of property list objects.
240
241     The type #MPlist is for a @e property @e list object.  Its internal
242     structure is concealed from application programs.  */
243
244 /***ja
245     @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿Àë¸À.
246
247     #MPlist ¤Ï @e ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È (Property list) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
248     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
249
250 typedef struct MPlist MPlist;
251
252 /*=*/
253
254 extern MSymbol Mplist, Minteger;
255
256 extern MPlist *mplist ();
257
258 extern MPlist *mplist_copy (MPlist *plist);
259
260 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
261
262 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
263
264 extern void *mplist_pop (MPlist *plist);
265
266 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
267
268 extern void *mplist_get (MPlist *plist, MSymbol key);
269
270 extern MPlist *mplist_put_func (MPlist *plist, MSymbol key, M17NFunc func);
271
272 extern M17NFunc mplist_get_func (MPlist *plist, MSymbol key);
273
274 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
275
276 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
277
278 extern MPlist *mplist_next (MPlist *plist);
279
280 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
281
282 extern int mplist_length (MPlist *plist);
283
284 extern MSymbol mplist_key (MPlist *plist);
285
286 extern void *mplist_value (MPlist *plist);
287
288 /* (S1) Characters */
289
290 /*=*/
291 /*** @ingroup m17nCore */
292 /***en @defgroup m17nCharacter Character */
293 /***ja @defgroup m17nCharacter Ê¸»ú */
294 /*=*/
295
296 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
297 #define MCHAR_MAX 0x3FFFFF
298 /*#define MCHAR_MAX 0x7FFFFFFF*/
299 #endif
300
301 extern MSymbol Mscript;
302 extern MSymbol Mname;
303 extern MSymbol Mcategory;
304 extern MSymbol Mcombining_class;
305 extern MSymbol Mbidi_category;
306 extern MSymbol Msimple_case_folding;
307 extern MSymbol Mcomplicated_case_folding;
308
309 extern MSymbol mchar_define_property (const char *name, MSymbol type);
310
311 extern void *mchar_get_prop (int c, MSymbol key);
312
313 extern int mchar_put_prop (int c, MSymbol key, void *val);
314
315 /* (C3) Handling chartable */
316
317 /*** @ingroup m17nCore */
318 /***en @defgroup m17nChartable Chartable */
319 /***ja @defgroup m17nChartable Ê¸»ú¥Æ¡¼¥Ö¥ë */
320 /*=*/
321 extern MSymbol Mchar_table;
322
323 /***
324     @ingroup m17nChartable */
325 /***en
326     @brief Type of chartables.
327
328     The type #MCharTable is for a @e chartable objects.  Its
329     internal structure is concealed from application programs.  */
330
331 /***ja
332     @brief Ê¸»ú¥Æ¡¼¥Ö¥ë¤Î·¿Àë¸À.
333
334     #MCharTable ¤Ï @e Ê¸»ú¥Æ¡¼¥Ö¥ë (chartable) ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
335     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
336
337 typedef struct MCharTable MCharTable;
338 /*=*/
339
340 extern MCharTable *mchartable (MSymbol key, void *default_value);
341
342 extern int mchartable_min_char (MCharTable *table);
343
344 extern int mchartable_max_char (MCharTable *table);
345
346 extern void *mchartable_lookup (MCharTable *table, int c);
347
348 extern int mchartable_set (MCharTable *table, int c, void *val);
349
350 extern int mchartable_set_range (MCharTable *table, int from, int to,
351                                  void *val);
352
353 extern int mchartable_map (MCharTable *table, void *ignore,
354                            void (*func) (int, int, void *, void *), 
355                            void *func_arg);
356
357 extern void mchartable_range (MCharTable *table, int *from, int *to);
358
359 extern MCharTable *mchar_get_prop_table (MSymbol key, MSymbol *type);
360
361 /*
362  *  (5) Handling M-text.
363  *      "M" of M-text stands for:
364  *      o Multilingual
365  *      o Metamorphic
366  *      o More than string
367  */
368
369 /*** @ingroup m17nCore */
370 /***en @defgroup m17nMtext M-text */
371 /***ja @defgroup m17nMtext M-text */
372 /*=*/
373
374 /*
375  * (5-1) M-text basics
376  */
377 /*=*/
378 /*** @ingroup m17nMtext */
379 /***en
380     @brief Type of @e M-texts.
381
382     The type #MText is for an @e M-text object.  Its internal
383     structure is concealed from application programs.  */
384
385 /***ja
386     @brief @e MText ¤Î·¿Àë¸À.
387
388     #Mtext ¤Ï @e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
389     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£ 
390
391     @latexonly \IPAlabel{MText} @endlatexonly
392     @latexonly \IPAlabel{MText->MPlist} @endlatexonly  */
393
394 typedef struct MText MText;
395
396 /*=*/
397
398 /*** @ingroup m17nMtext */
399 /***en
400     @brief Enumeration for specifying the format of an M-text.
401
402     The enum #MTextFormat is used as an argument of the
403     mtext_from_data () function to specify the format of data from
404     which an M-text is created.  */
405
406 /***ja
407     @brief M-text ¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ëÎóµó·¿.
408
409     Îóµó·¿ #MTextFormat ¤Ï´Ø¿ô
410     mtext_from_data () ¤Î°ú¿ô¤È¤·¤ÆÍѤ¤¤é¤ì¡¢
411     M-text ¤òÀ¸À®¤¹¤ë¸µ¤È¤Ê¤ë¥Ç¡¼¥¿¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ë¡£  */
412
413 enum MTextFormat
414   {
415     MTEXT_FORMAT_US_ASCII,
416     MTEXT_FORMAT_UTF_8,
417     MTEXT_FORMAT_UTF_16LE,
418     MTEXT_FORMAT_UTF_16BE,
419     MTEXT_FORMAT_UTF_32LE,
420     MTEXT_FORMAT_UTF_32BE,
421     MTEXT_FORMAT_MAX
422   };
423 /*=*/
424
425 extern MText *mtext ();
426
427 extern void *mtext_data (MText *mt, enum MTextFormat *fmt, int *nunits,
428                          int *pos_idx, int *unit_idx);
429
430 /*=*/
431
432 /***en @name Variables: Default Endian of UTF-16 and UTF-32 */
433 /***ja @name ÊÑ¿ô: UTF-16 ¤È UTF-32 ¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥¨¥ó¥Ç¥£¥¢¥ó */
434 /*** @{ */
435 /*=*/
436
437 /*** @ingroup m17nMtext */
438 /***en
439     @brief Variable of value MTEXT_FORMAT_UTF_16LE or MTEXT_FORMAT_UTF_16BE.
440
441     The global variable #MTEXT_FORMAT_UTF_16 is initialized to
442     #MTEXT_FORMAT_UTF_16LE on a "Little Endian" system (storing words
443     with the least significant byte first), and to
444     #MTEXT_FORMAT_UTF_16BE on a "Big Endian" system (storing words
445     with the most significant byte first).  */
446
447 /***ja
448     @brief Ãͤ¬ MTEXT_FORMAT_UTF_16LE ¤« MTEXT_FORMAT_UTF_16BE ¤Ç¤¢¤ëÊÑ¿ô
449
450     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_16 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
451     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
452     #MTEXT_FORMAT_UTF_16LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
453     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
454     #MTEXT_FORMAT_UTF_16BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
455
456 /***
457     @seealso
458     mtext_from_data ()  */
459
460 extern const enum MTextFormat MTEXT_FORMAT_UTF_16;
461 /*=*/
462
463 /*** @ingroup m17nMtext */
464 /***en
465     @brief Variable of value MTEXT_FORMAT_UTF_32LE or MTEXT_FORMAT_UTF_32BE.
466
467     The global variable #MTEXT_FORMAT_UTF_32 is initialized to
468     #MTEXT_FORMAT_UTF_32LE on a "Little Endian" system (storing words
469     with the least significant byte first), and to
470     #MTEXT_FORMAT_UTF_32BE on a "Big Endian" system (storing
471     words with the most significant byte first).  */
472
473 /***ja
474     @brief Ãͤ¬ MTEXT_FORMAT_UTF_32LE ¤« MTEXT_FORMAT_UTF_32BE ¤Ç¤¢¤ëÊÑ¿ô
475
476     Âç°èÊÑ¿ô #MTEXT_FORMAT_UTF_32 ¤Ï¥ê¥È¥ë¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
477     ¡Ê¥ï¡¼¥É¤ò LSB (Least Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
478     #MTEXT_FORMAT_UTF_32LE ¤Ë½é´ü²½¤µ¤ì¡¢¥Ó¥Ã¥°¡¦¥¨¥ó¥Ç¥£¥¢¥ó¡¦¥·¥¹¥Æ¥à
479     ¡Ê¥ï¡¼¥É¤ò MSB (Most Significant Byte) ¤òÀè¤Ë¤·¤Æ³ÊǼ¡Ë¾å¤Ç¤Ï
480     #MTEXT_FORMAT_UTF_32BE ¤Ë½é´ü²½¤µ¤ì¤ë¡£  */
481
482 /***
483     @seealso
484     mtext_from_data ()  */
485
486 extern const int MTEXT_FORMAT_UTF_32;
487
488 /*=*/
489 /*** @} */
490 /*=*/
491
492 extern MText *mtext_from_data (const void *data, int nitems,
493                                enum MTextFormat format);
494
495 /*=*/
496 /*** @} */
497
498 extern MSymbol Mlanguage;
499
500 /*
501  *  (5-2) Functions to manipulate M-texts.  They correspond to string
502  *   manipulating functions in libc.
503  *   In the following functions, mtext_XXX() corresponds to strXXX().
504  */
505
506 extern int mtext_len (MText *mt);
507
508 extern int mtext_ref_char (MText *mt, int pos);
509
510 extern int mtext_set_char (MText *mt, int pos, int c);
511
512 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
513
514 extern int mtext_compare (MText *mt1, int from1, int to1,
515                           MText *mt2, int from2, int to2);
516
517 extern int mtext_case_compare (MText *mt1, int from1, int to1,
518                                MText *mt2, int from2, int to2);
519
520 extern int mtext_character (MText *mt, int from, int to, int c);
521
522 extern int mtext_del (MText *mt, int from, int to);
523
524 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
525
526 extern int mtext_insert (MText *mt1, int pos, MText *mt2, int from, int to);
527
528 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
529
530 extern int mtext_replace (MText *mt1, int from1, int to1,
531                           MText *mt2, int from2, int to2);
532
533 extern MText *mtext_cat_char (MText *mt, int c);
534
535 extern MText *mtext_duplicate (MText *mt, int from, int to);
536
537 extern MText *mtext_dup (MText *mt);
538
539 extern MText *mtext_cat (MText *mt1, MText *mt2);
540
541 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
542
543 extern MText *mtext_cpy (MText *mt1, MText *mt2);
544
545 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
546
547 extern int mtext_chr (MText *mt, int c);
548
549 extern int mtext_rchr (MText *mt, int c);
550
551 extern int mtext_cmp (MText *mt1, MText *mt2);
552
553 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
554
555 extern int mtext_spn (MText *mt1, MText *mt2);
556
557 extern int mtext_cspn (MText *mt1, MText *mt2);
558
559 extern int mtext_pbrk (MText *mt1, MText *mt2);
560
561 extern int mtext_text (MText *mt1, int pos, MText *mt2);
562
563 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
564
565 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
566
567 extern int mtext_casecmp (MText *mt1, MText *mt2);
568
569 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
570
571 extern int mtext_lowercase (MText *mt);
572
573 extern int mtext_titlecase (MText *mt);
574
575 extern int mtext_uppercase (MText *mt);
576
577 /***en
578     @brief Enumeration for specifying a set of line breaking option.
579
580     The enum #MTextLineBreakOption is to control the line breaking
581     algorithm of the function mtext_line_break () by specifying
582     logical-or of the members in the arg @e option.  */
583
584 enum MTextLineBreakOption
585   {
586     /***en Specify the legacy support for space character as base for
587        combining marks.  See the section 8.3 of UAX#14. */
588     MTEXT_LBO_SP_CM = 1,
589     /***en Specify to use space characters for line breaking Korean
590         text.  */
591     MTEXT_LBO_KOREAN_SP = 2,
592     /***en Specify to treat characters of ambiguous line-breaking
593         class as of ideographic line-breaking class.  */
594     MTEXT_LBO_AI_AS_ID = 4,
595     MTEXT_LBO_MAX
596   };
597
598 extern int mtext_line_break (MText *mt, int pos, int option, int *after);
599
600 /*** @ingroup m17nPlist */
601 extern MPlist *mplist_deserialize (MText *mt);
602
603 /*
604  * (5-3) Text properties
605  */
606 /*=*/
607 /*** @ingroup m17nCore */
608 /***en @defgroup m17nTextProperty Text Property */
609 /***ja @defgroup m17nTextProperty ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
610 /*=*/
611 /*** @ingroup m17nTextProperty */
612 /***en
613     @brief Flag bits to control text property.
614
615     The mtext_property () function accepts logical OR of these flag
616     bits as an argument.  They control the behaviour of the created
617     text property as described in the documentation of each flag
618     bit.  */
619
620 /***ja
621     @brief ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤òÀ©¸æ¤¹¤ë¥Õ¥é¥°¥Ó¥Ã¥È.
622
623     ´Ø¿ô mtext_property () ¤Ï°Ê²¼¤Î¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÏÀÍý
624     OR ¤ò°ú¿ô¤È¤·¤Æ¤È¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
625     ¥Õ¥é¥°¥Ó¥Ã¥È¤ÏÀ¸À®¤µ¤ì¤¿¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î¿¶Éñ¤¤¤òÀ©¸æ¤¹¤ë¡£
626     ¾ÜºÙ¤Ï³Æ¥Õ¥é¥°¥Ó¥Ã¥È¤ÎÀâÌÀ¤ò»²¾È¡£*/
627
628 enum MTextPropertyControl
629   {
630     /***en If this flag bit is on, an M-text inserted at the start
631         position or at the middle of the text property inherits the
632         text property.  */
633     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î»Ï¤Þ¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
634         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
635         */
636     MTEXTPROP_FRONT_STICKY = 0x01,
637
638     /***en If this flag bit is on, an M-text inserted at the end
639         position or at the middle of the text property inherits the
640         text property.  */
641     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î½ª¤ï¤ëÅÀ¤¢¤ë¤¤¤ÏÃæ´Ö¤ËÁÞÆþ¤µ¤ì¤¿
642         M-text ¤Ï¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ò·Ñ¾µ¤¹¤ë¡£
643         */
644     MTEXTPROP_REAR_STICKY = 0x02,
645
646     /***en If this flag bit is on, the text property is removed if a
647         text in its region is modified.  */
648     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£  */
649     MTEXTPROP_VOLATILE_WEAK = 0x04,
650
651     /***en If this flag bit is on, the text property is removed if a
652         text or the other text property in its region is modified.  */
653     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤ÎÈÏ°ÏÆâ¤Î¥Æ¥­¥¹¥È¤¢¤ë¤¤¤ÏÊ̤Υƥ­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¤³¤Î¥Æ¥­
654         ¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¼è¤ê½ü¤«¤ì¤ë¡£*/
655     MTEXTPROP_VOLATILE_STRONG = 0x08,
656
657     /***en If this flag bit is on, the text property is not
658         automatically merged with the others.  */
659     /***ja ¤³¤Î¥Ó¥Ã¥È¤¬ on ¤Ê¤é¤Ð¡¢¤³¤Î¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¾¤Î¥×¥í¥Ñ¥Æ¥£¤È¼«Æ°Åª¤Ë¤Ï¥Þ¡¼¥¸¤µ¤ì¤Ê¤¤¡£ */
660     MTEXTPROP_NO_MERGE = 0x10,
661
662     MTEXTPROP_CONTROL_MAX = 0x1F
663   };
664
665 /*=*/
666 extern MSymbol Mtext_prop_serializer;
667 extern MSymbol Mtext_prop_deserializer;
668
669
670 /*** @ingroup m17nTextProperty */
671 /***en
672     @brief Type of serializer functions.
673
674     This is the type of serializer functions.  If the key of a symbol
675     property is #Mtext_prop_serializer, the value must be of this
676     type.
677
678     @seealso
679     mtext_serialize (), #Mtext_prop_serializer
680 */
681 /***ja
682     @brief ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
683
684     ¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
685     #Mtext_prop_serializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
686
687     @seealso
688     mtext_serialize (), #Mtext_prop_serializer
689 */
690
691 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
692
693 /*** @ingroup m17nTextProperty */
694 /***en
695     @brief Type of deserializer functions.
696
697     This is the type of deserializer functions.  If the key of a
698     symbol property is #Mtext_prop_deserializer, the value must be of
699     this type.
700
701     @seealso
702     mtext_deserialize (), #Mtext_prop_deserializer
703 */
704 /***ja
705     @brief ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿Àë¸À.
706
707     ¥Ç¥·¥ê¥¢¥é¥¤¥¶´Ø¿ô¤Î·¿¤Ç¤¢¤ë¡£ ¤¢¤ë¥·¥ó¥Ü¥ë¤Î¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤¬ @c
708     #Msymbol_prop_deserializer ¤Ç¤¢¤ë¤È¤­¡¢ ÃͤϤ³¤Î·¿¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
709
710     @seealso
711     Mtext_prop_deserialize (), Mtext_prop_deserializer
712 */
713 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
714
715 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
716
717 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
718                                   void **values, int num);
719
720 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
721
722 extern int mtext_put_prop (MText *mt, int from, int to,
723                            MSymbol key, void *val);
724
725 extern int mtext_put_prop_values (MText *mt, int from, int to,
726                                   MSymbol key, void **values, int num);
727
728 extern int mtext_push_prop (MText *mt, int from, int to,
729                             MSymbol key, void *val);
730
731 extern int mtext_pop_prop (MText *mt, int from, int to,
732                            MSymbol key);
733
734 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
735                              int *from, int *to, int deeper);
736
737 /*=*/
738 /***
739     @ingroup m17nTextProperty */
740 /***en
741     @brief Type of text properties.
742
743     The type #MTextProperty is for a @e text @e property objects.  Its
744     internal structure is concealed from application programs.  */
745 /***ja
746     @brief @c ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î·¿Àë¸À.
747
748     #MTextProperty ¤Ï @e ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ç¤¢¤ë¡£
749     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
750
751 typedef struct MTextProperty MTextProperty;
752
753 /*=*/
754
755 extern MTextProperty *mtext_property (MSymbol key, void *val,
756                                       int control_bits);
757
758 extern MText *mtext_property_mtext (MTextProperty *prop);
759
760 extern MSymbol mtext_property_key (MTextProperty *prop);
761
762 extern void *mtext_property_value (MTextProperty *prop);
763
764 extern int mtext_property_start (MTextProperty *prop);
765
766 extern int mtext_property_end (MTextProperty *prop);
767
768 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
769
770 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
771                                  MTextProperty **props, int num);
772
773 extern int mtext_attach_property (MText *mt, int from, int to,
774                                   MTextProperty *prop);
775
776 extern int mtext_detach_property (MTextProperty *prop);
777
778 extern int mtext_push_property (MText *mt, int from, int to,
779                                 MTextProperty *prop);
780
781 extern MText *mtext_serialize (MText *mt, int from, int to,
782                                MPlist *property_list);
783
784 extern MText *mtext_deserialize (MText *mt);
785
786 /*** @ingroup m17nCore */
787 /***en @defgroup m17nDatabase Database */
788 /***ja @defgroup m17nDatabase ¥Ç¡¼¥¿¥Ù¡¼¥¹ */
789 /*=*/
790
791 /* Directory of an application specific databases.  */
792 extern char *mdatabase_dir;
793 /*=*/
794 /***
795     @ingroup m17nDatabase  */ 
796 /***en
797     @brief Type of database.
798
799     The type #MDatabase is for a database object.  Its internal
800     structure is concealed from an application program.  */
801 /***ja 
802     @brief ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î·¿Àë¸À.
803
804     #MDatabase ·¿¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤǤ¢¤ë¡£
805     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
806     */
807
808 typedef struct MDatabase MDatabase;
809
810 /*=*/
811
812 /* Look for a data.  */
813 extern MDatabase *mdatabase_find (MSymbol tag1, MSymbol tag2,
814                                   MSymbol tag3, MSymbol tag4);
815
816 extern MPlist *mdatabase_list (MSymbol tag0, MSymbol tag1,
817                                MSymbol tag2, MSymbol tag3);
818
819 /* Load a data.  */
820 void *mdatabase_load (MDatabase *mdb);
821
822 /* Get tags of a data.  */
823 extern MSymbol *mdatabase_tag (MDatabase *mdb);
824
825 /* Define a data.  */
826 extern MDatabase *mdatabase_define (MSymbol tag1, MSymbol tag2,
827                                     MSymbol tag3, MSymbol tag4,
828                                     void *(*loader) (MSymbol *, void *),
829                                     void *extra_info);
830
831 M17N_END_HEADER
832
833 #endif /* _M17N_CORE_H_ */
834
835 /*
836   Local Variables:
837   coding: euc-japan
838   End:
839 */