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