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