Change /***ja to /***oldja
[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
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., 59 Temple Place, Suite 330, Boston, MA
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 /***oldja @defgroup m17nIntro ¤Ï¤¸¤á¤Ë  */
39 /*=*/
40
41 #define M17NLIB_MAJOR_VERSION 1
42 #define M17NLIB_MINOR_VERSION 0
43 #define M17NLIB_PATCH_LEVEL 2
44 #define M17NLIB_VERSION_NAME "1.0.2"
45
46 extern void m17n_init_core (void);
47 #define M17N_INIT() m17n_init_core ()
48 extern void m17n_fini_core (void);
49 #define M17N_FINI() m17n_fini_core ()
50
51 /***en @defgroup m17nCore CORE API  */
52 /***oldja @defgroup m17nCore CORE API */
53 /*=*/
54 /*** @ingroup m17nCore */
55 /***en @defgroup m17nObject Managed Object */
56 /***oldja @defgroup m17nObject ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È */
57 /*=*/
58
59 /*** @ingroup m17nObject  */
60 /***en
61     @brief The first member of a managed object.
62
63     When an application program defines a new structure for managed
64     objects, its first member must be of the type @c struct
65     #M17NObjectHead.  Its contents are used by the m17n library, and
66     application programs should never touch them.  */
67
68 typedef struct
69 {
70   void *filler[2];
71 } M17NObjectHead;
72
73 /*=*/
74
75 /* Return a newly allocated managed object.  */
76 extern void *m17n_object_setup (int size, void (*freer) (void *));
77
78 /* Increment the reference count of managed object OBJECT.  */
79 extern int m17n_object_ref (void *object);
80
81 /* Decrement the reference count of managed object OBJECT.  */
82 extern int m17n_object_unref (void *object);
83
84 /*=*/
85
86 /* (C2) Symbol handling */
87
88 /*** @ingroup m17nCore */
89 /***en @defgroup m17nSymbol Symbol  */
90 /***oldja @defgroup m17nSymbol ¥·¥ó¥Ü¥ë */
91 /*=*/
92
93 /***
94     @ingroup m17nSymbol */
95 /***en
96     @brief Type of symbols.
97
98     The type #MSymbol is for a @e symbol object.  Its internal
99     structure is concealed from application programs.  */
100
101 /***oldja
102     @brief ¥·¥ó¥Ü¥ë¤Î·¿
103
104     #MSymbol ¤Ï¥·¥ó¥Ü¥ë¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ */
105
106 typedef struct MSymbol *MSymbol;
107
108 /*=*/
109
110 /* Predefined symbols. */ 
111 extern MSymbol Mnil;
112 extern MSymbol Mt;
113 extern MSymbol Mstring;
114 extern MSymbol Msymbol;
115 extern MSymbol Mtext;
116
117 /* Return a symbol of name NAME.  */
118 extern MSymbol msymbol (const char *name);
119
120 /* Return a managing key of name NAME.  */
121 extern MSymbol msymbol_as_managing_key (const char *name);
122
123 /* Return a symbol of name NAME if it already exists.  */
124 extern MSymbol msymbol_exist (const char *name);
125
126 /* Return the name of SYMBOL.  */
127 extern char *msymbol_name (MSymbol symbol);
128
129 /* Give SYMBOL KEY property with value VALUE.  */
130 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
131
132 /*** Return KEY property value of SYMBOL.  */
133 extern void *msymbol_get (MSymbol symbol, MSymbol key);
134
135 /* 
136  *  (2-1) Property List
137  */
138
139 /*** @ingroup m17nCore */
140 /***en @defgroup m17nPlist Property List */
141 /***oldja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È */
142 /*=*/
143
144 /***
145     @ingroup m17nPlist */ 
146 /***en
147     @brief Type of property list objects.
148
149     The type #MPlist is for a property list object.  Its internal
150     structure is concealed from application programs.  */
151
152 typedef struct MPlist MPlist;
153
154 /*=*/
155
156 extern MSymbol Mplist, Minteger;
157
158 extern MPlist *mplist ();
159
160 extern MPlist *mplist_copy (MPlist *plist);
161
162 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
163
164 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
165
166 extern void *mplist_pop (MPlist *plist);
167
168 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
169
170 extern void *mplist_get (MPlist *plist, MSymbol key);
171
172 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
173
174 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
175
176 extern MPlist *mplist_next (MPlist *plist);
177
178 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
179
180 extern int mplist_length (MPlist *plist);
181
182 extern MSymbol mplist_key (MPlist *plist);
183
184 extern void *mplist_value (MPlist *plist);
185
186 /* (S1) Characters */
187
188 /*=*/
189 /*** @ingroup m17nCore */
190 /***en @defgroup m17nCharacter Character */
191 /***oldja @defgroup m17nCharacter Ê¸»ú */
192 /*=*/
193
194 #define MCHAR_MAX 0x3FFFFF
195 /*#define MCHAR_MAX 0x7FFFFFFF*/
196
197 extern MSymbol Mscript;
198 extern MSymbol Mname;
199 extern MSymbol Mcategory;
200 extern MSymbol Mcombining_class;
201 extern MSymbol Mbidi_category;
202 extern MSymbol Msimple_case_folding;
203 extern MSymbol Mcomplicated_case_folding;
204
205 extern MSymbol mchar_define_property (char *name, MSymbol type);
206
207 extern void *mchar_get_prop (int c, MSymbol key);
208
209 extern int mchar_put_prop (int c, MSymbol key, void *val);
210
211 /* (C3) Handling chartable */
212
213 /*** @ingroup m17nCore */
214 /***en @defgroup m17nChartable Chartable */
215 /***oldja @defgroup m17nChartable Ê¸»ú¥Æ¡¼¥Ö¥ë */
216 /*=*/
217 extern MSymbol Mchar_table;
218
219 /***
220     @ingroup m17nChartable */
221 /***en
222     @brief Type of chartables.
223
224     The type #MCharTable is for a @e chartable objects.  Its
225     internal structure is concealed from application programs.  */
226
227 /***oldja
228     @brief Ê¸»ú¥Æ¡¼¥Ö¥ë¤Î·¿
229
230     #MCharTable ·¿¤Ï @e Ê¸»ú¥Æ¡¼¥Ö¥ë ¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤǤ¢¤ë¡£
231     ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£  */
232
233 typedef struct MCharTable MCharTable;
234 /*=*/
235
236 extern MCharTable *mchartable (MSymbol key, void *default_value);
237
238 extern void *mchartable_lookup (MCharTable *table, int c);
239
240 extern int mchartable_set (MCharTable *table, int c, void *val);
241
242 extern int mchartable_set_range (MCharTable *table, int from, int to,
243                                  void *val);
244
245 extern int mchartable_map (MCharTable *table, void *ignore,
246                            void (*func) (int from, int to,
247                                          void *val, void *arg), 
248                            void *func_arg);
249
250 extern void mchartable_range (MCharTable *table, int *from, int *to);
251
252 /*
253  *  (5) Handling M-text.
254  *      "M" of M-text stands for:
255  *      o Multilingual
256  *      o Metamorphic
257  *      o More than string
258  */
259
260 /*** @ingroup m17nCore */
261 /***en @defgroup m17nMtext M-text */
262 /***oldja @defgroup m17nMtext M-text */
263 /*=*/
264
265 /*
266  * (5-1) M-text basics
267  */
268
269 /*** @ingroup m17nMtext */
270 /***en
271     @brief Type of @e M-texts.
272
273     The type #MText is for an @e M-text object.  Its internal
274     structure is concealed from application programs.  */
275
276 /***oldja
277     @brief @e MText Íѹ½Â¤ÂΠ
278
279     #Mtext ¹½Â¤ÂΤϠ@e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤ËÍѤ¤¤é¤ì¤ë¡£ÆâÉô¹½Â¤¤Ï¥¢
280     ¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
281
282     @latexonly \IPAlabel{MText} @endlatexonly
283     @latexonly \IPAlabel{MText->MPlist} @endlatexonly  */
284
285 typedef struct MText MText;
286
287 /*=*/
288
289 extern MText *mtext ();
290
291 /*=*/
292
293 /***en
294     @brief Enumeration for specifying the format of an M-text.
295
296     The enum #MTextFormat is used as an argument of the
297     mtext_from_data () function to specify the format of data from
298     which an M-text is created.  */
299
300 enum MTextFormat
301   {
302     MTEXT_FORMAT_US_ASCII,
303     MTEXT_FORMAT_UTF_8,
304     MTEXT_FORMAT_UTF_16LE,
305     MTEXT_FORMAT_UTF_16BE,
306     MTEXT_FORMAT_UTF_32LE,
307     MTEXT_FORMAT_UTF_32BE,
308     MTEXT_FORMAT_MAX
309   };
310 /*=*/
311
312 extern MText *mtext_from_data (void *data, int nitems,
313                                enum MTextFormat format);
314
315
316 /*=*/
317
318 /*
319  *  (5-2) Functions to manipulate M-texts.  They correspond to string
320  *   manipulating functions in libc.
321  *   In the following functions, mtext_XXX() corresponds to strXXX().
322  */
323
324 extern int mtext_len (MText *mt);
325
326 extern int mtext_ref_char (MText *mt, int pos);
327
328 extern int mtext_set_char (MText *mt, int pos, int c);
329
330 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
331
332 extern int mtext_compare (MText *mt1, int from1, int to1,
333                           MText *mt2, int from2, int to2);
334
335 extern int mtext_case_compare (MText *mt1, int from1, int to1,
336                                MText *mt2, int from2, int to2);
337
338 extern int mtext_character (MText *mt, int from, int to, int c);
339
340 extern int mtext_del (MText *mt, int from, int to);
341
342 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
343
344 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
345
346 extern MText *mtext_cat_char (MText *mt, int c);
347
348 extern MText *mtext_duplicate (MText *mt, int from, int to);
349
350 extern MText *mtext_dup (MText *mt);
351
352 extern MText *mtext_cat (MText *mt1, MText *mt2);
353
354 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
355
356 extern MText *mtext_cpy (MText *mt1, MText *mt2);
357
358 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
359
360 extern int mtext_chr (MText *mt, int c);
361
362 extern int mtext_rchr (MText *mt, int c);
363
364 extern int mtext_cmp (MText *mt1, MText *mt2);
365
366 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
367
368 extern int mtext_spn (MText *mt1, MText *mt2);
369
370 extern int mtext_cspn (MText *mt1, MText *mt2);
371
372 extern int mtext_pbrk (MText *mt1, MText *mt2);
373
374 extern int mtext_text (MText *mt1, int pos, MText *mt2);
375
376 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
377
378 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
379
380 extern int mtext_casecmp (MText *mt1, MText *mt2);
381
382 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
383
384 /*** @ingroup m17nPlist */
385 extern MPlist *mplist_deserialize (MText *mt);
386
387 /*
388  * (5-3) Text properties
389  */
390
391 /*** @ingroup m17nCore */
392 /***en @defgroup m17nTextProperty Text Property */
393 /***oldja @defgroup m17nTextProperty ¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
394 /*=*/
395 /*** @ingroup m17nTextProperty */
396 /***en
397     @brief Flag bits to control text property.
398
399     The mtext_property () funciton accepts logical OR of these flag
400     bits as an argument.  They control the behaviour of the created
401     text property as described in the documentation of each flag
402     bit.  */
403
404 enum MTextPropertyControl
405   {
406     /***en If this flag bit is on, an M-text inserted at the start
407         position or at the middle of the text property inherits the
408         text property.  */
409     MTEXTPROP_FRONT_STICKY = 0x01,
410
411     /***en If this flag bit is on, an M-text inserted at the end
412         position or at the middle of the text property inherits the
413         text property.  */
414     MTEXTPROP_REAR_STICKY = 0x02,
415
416     /***en If this flag bit is on, the text property is removed if a
417         text in its region is modified.  */
418     MTEXTPROP_VOLATILE_WEAK = 0x04,
419
420     /***en If this flag bit is on, the text property is removed if a
421         text or the other text property in its region is modified.  */
422     MTEXTPROP_VOLATILE_STRONG = 0x08,
423
424     /***en If this flag bit is on, the text property is not
425         automatically merged with the others.  */
426     MTEXTPROP_NO_MERGE = 0x10,
427
428     MTEXTPROP_CONTROL_MAX = 0x1F
429   };
430
431 /*=*/
432 extern MSymbol Mtext_prop_serializer;
433 extern MSymbol Mtext_prop_deserializer;
434
435
436 /*** @ingroup m17nTextProperty */
437 /***en
438     @brief Type of serializer functions.
439
440     This is the type of serializer functions.  If the key of a symbol
441     property is #Msymbol_prop_serializer, the value must be of this
442     type.
443
444     @seealso Mtext_prop_serialize (), Mtext_prop_serializer
445 */
446
447 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
448
449 /*** @ingroup m17nTextProperty */
450 /***en
451     @brief Type of deserializer functions.
452
453     This is the type of deserializer functions.  If the key of a
454     symbol property is #Msymbol_prop_deserializer, the value must be
455     of this type.
456
457     @seealso Mtext_prop_deserialize (), Mtext_prop_deserializer
458 */
459 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
460
461 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
462
463 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
464                                   void **values, int num);
465
466 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
467
468 extern int mtext_put_prop (MText *mt, int from, int to,
469                            MSymbol key, void *val);
470
471 extern int mtext_put_prop_values (MText *mt, int from, int to,
472                                   MSymbol key, void **values, int num);
473
474 extern int mtext_push_prop (MText *mt, int from, int to,
475                             MSymbol key, void *val);
476
477 extern int mtext_pop_prop (MText *mt, int from, int to,
478                            MSymbol key);
479
480 extern int mtext_change_prop (MText *mt, int from, int to,
481                               MSymbol key,
482                               int (*func) (int, void ***, int *));
483
484 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
485                              int *from, int *to, int deeper);
486
487 /*=*/
488 typedef struct MTextProperty MTextProperty;
489
490 /*=*/
491
492 extern MTextProperty *mtext_property (MSymbol key, void *val,
493                                       int control_bits);
494
495 extern MText *mtext_property_mtext (MTextProperty *prop);
496
497 extern MSymbol mtext_property_key (MTextProperty *prop);
498
499 extern void *mtext_property_value (MTextProperty *prop);
500
501 extern int mtext_property_start (MTextProperty *prop);
502
503 extern int mtext_property_end (MTextProperty *prop);
504
505 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
506
507 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
508                                  MTextProperty **props, int num);
509
510 extern int mtext_attach_property (MText *mt, int from, int to,
511                                   MTextProperty *prop);
512
513 extern int mtext_detach_property (MTextProperty *prop);
514
515 extern int mtext_push_property (MText *mt, int from, int to,
516                                 MTextProperty *prop);
517
518 extern MText *mtext_serialize (MText *mt, int from, int to,
519                                MPlist *property_list);
520
521 extern MText *mtext_deserialize (MText *mt);
522
523 #ifdef __cplusplus
524 }
525 #endif
526
527 #endif /* _M17N_CORE_H_ */
528
529 /*
530   Local Variables:
531   coding: euc-japan
532   End:
533 */