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