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