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