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
6 This file is part of the m17n library.
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.
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.
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
32 * Header file for m17n library.
35 /* (C1) Introduction */
37 /***en @defgroup m17nIntro Introduction */
38 /***ja @defgroup m17nIntro ¤Ï¤¸¤á¤Ë */
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"
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 ()
51 /***en @defgroup m17nCore CORE API */
52 /***ja @defgroup m17nCore CORE API */
54 /*** @ingroup m17nCore */
55 /***en @defgroup m17nObject Managed Object */
56 /***ja @defgroup m17nObject ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È */
59 /*** @ingroup m17nObject */
61 @brief The first member of a managed object.
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. */
75 /* Return a newly allocated managed object. */
76 extern void *m17n_object_setup (int size, void (*freer) (void *));
78 /* Increment the reference count of managed object OBJECT. */
79 extern int m17n_object_ref (void *object);
81 /* Decrement the reference count of managed object OBJECT. */
82 extern int m17n_object_unref (void *object);
86 /* (C2) Symbol handling */
88 /*** @ingroup m17nCore */
89 /***en @defgroup m17nSymbol Symbol */
90 /***ja @defgroup m17nSymbol ¥·¥ó¥Ü¥ë */
94 @ingroup m17nSymbol */
96 @brief Type of symbols.
98 The type #MSymbol is for a @e symbol object. Its internal
99 structure is concealed from application programs. */
104 #MSymbol ¤Ï¥·¥ó¥Ü¥ë¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ */
106 typedef struct MSymbol *MSymbol;
110 /* Predefined symbols. */
113 extern MSymbol Mstring;
114 extern MSymbol Msymbol;
115 extern MSymbol Mtext;
117 /* Return a symbol of name NAME. */
118 extern MSymbol msymbol (const char *name);
120 /* Return a managing key of name NAME. */
121 extern MSymbol msymbol_as_managing_key (const char *name);
123 /* Return a symbol of name NAME if it already exists. */
124 extern MSymbol msymbol_exist (const char *name);
126 /* Return the name of SYMBOL. */
127 extern char *msymbol_name (MSymbol symbol);
129 /* Give SYMBOL KEY property with value VALUE. */
130 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
132 /*** Return KEY property value of SYMBOL. */
133 extern void *msymbol_get (MSymbol symbol, MSymbol key);
136 * (2-1) Property List
139 /*** @ingroup m17nCore */
140 /***en @defgroup m17nPlist Property List */
141 /***ja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È */
145 @ingroup m17nPlist */
147 @brief Type of property list objects.
149 The type #MPlist is for a property list object. Its internal
150 structure is concealed from application programs. */
152 typedef struct MPlist MPlist;
156 extern MSymbol Mplist, Minteger;
158 extern MPlist *mplist ();
160 extern MPlist *mplist_copy (MPlist *plist);
162 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
164 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
166 extern void *mplist_pop (MPlist *plist);
168 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
170 extern void *mplist_get (MPlist *plist, MSymbol key);
172 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
174 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
176 extern MPlist *mplist_next (MPlist *plist);
178 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
180 extern int mplist_length (MPlist *plist);
182 extern MSymbol mplist_key (MPlist *plist);
184 extern void *mplist_value (MPlist *plist);
186 /* (S1) Characters */
189 /*** @ingroup m17nCore */
190 /***en @defgroup m17nCharacter Character */
191 /***ja @defgroup m17nCharacter ʸ»ú */
194 #define MCHAR_MAX 0x3FFFFF
195 /*#define MCHAR_MAX 0x7FFFFFFF*/
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;
205 extern MSymbol mchar_define_property (char *name, MSymbol type);
207 extern void *mchar_get_prop (int c, MSymbol key);
209 extern int mchar_put_prop (int c, MSymbol key, void *val);
211 /* (C3) Handling chartable */
213 /*** @ingroup m17nCore */
214 /***en @defgroup m17nChartable Chartable */
215 /***ja @defgroup m17nChartable ʸ»ú¥Æ¡¼¥Ö¥ë */
217 extern MSymbol Mchar_table;
220 @ingroup m17nChartable */
222 @brief Type of chartables.
224 The type #MCharTable is for a @e chartable objects. Its
225 internal structure is concealed from application programs. */
228 @brief ʸ»ú¥Æ¡¼¥Ö¥ë¤Î·¿
230 #MCharTable ·¿¤Ï @e ʸ»ú¥Æ¡¼¥Ö¥ë ¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤǤ¢¤ë¡£
231 ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£ */
233 typedef struct MCharTable MCharTable;
236 extern MCharTable *mchartable (MSymbol key, void *default_value);
238 extern void *mchartable_lookup (MCharTable *table, int c);
240 extern int mchartable_set (MCharTable *table, int c, void *val);
242 extern int mchartable_set_range (MCharTable *table, int from, int to,
245 extern int mchartable_map (MCharTable *table, void *ignore,
246 void (*func) (int from, int to,
247 void *val, void *arg),
250 extern void mchartable_range (MCharTable *table, int *from, int *to);
253 * (5) Handling M-text.
254 * "M" of M-text stands for:
260 /*** @ingroup m17nCore */
261 /***en @defgroup m17nMtext M-text */
262 /***ja @defgroup m17nMtext M-text */
266 * (5-1) M-text basics
269 /*** @ingroup m17nMtext */
271 @brief Type of @e M-texts.
273 The type #MText is for an @e M-text object. Its internal
274 structure is concealed from application programs. */
277 @brief @e MText Íѹ½Â¤ÂÎ
279 #Mtext ¹½Â¤ÂÎ¤Ï @e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤ËÍѤ¤¤é¤ì¤ë¡£ÆâÉô¹½Â¤¤Ï¥¢
280 ¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
282 @latexonly \IPAlabel{MText} @endlatexonly
283 @latexonly \IPAlabel{MText->MPlist} @endlatexonly */
285 typedef struct MText MText;
289 extern MText *mtext ();
294 @brief Enumeration for specifying the format of an M-text.
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. */
302 MTEXT_FORMAT_US_ASCII,
304 MTEXT_FORMAT_UTF_16LE,
305 MTEXT_FORMAT_UTF_16BE,
306 MTEXT_FORMAT_UTF_32LE,
307 MTEXT_FORMAT_UTF_32BE,
312 extern MText *mtext_from_data (void *data, int nitems,
313 enum MTextFormat format);
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().
324 extern int mtext_len (MText *mt);
326 extern int mtext_ref_char (MText *mt, int pos);
328 extern int mtext_set_char (MText *mt, int pos, int c);
330 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
332 extern int mtext_compare (MText *mt1, int from1, int to1,
333 MText *mt2, int from2, int to2);
335 extern int mtext_case_compare (MText *mt1, int from1, int to1,
336 MText *mt2, int from2, int to2);
338 extern int mtext_character (MText *mt, int from, int to, int c);
340 extern int mtext_del (MText *mt, int from, int to);
342 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
344 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
346 extern MText *mtext_cat_char (MText *mt, int c);
348 extern MText *mtext_duplicate (MText *mt, int from, int to);
350 extern MText *mtext_dup (MText *mt);
352 extern MText *mtext_cat (MText *mt1, MText *mt2);
354 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
356 extern MText *mtext_cpy (MText *mt1, MText *mt2);
358 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
360 extern int mtext_chr (MText *mt, int c);
362 extern int mtext_rchr (MText *mt, int c);
364 extern int mtext_cmp (MText *mt1, MText *mt2);
366 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
368 extern int mtext_spn (MText *mt1, MText *mt2);
370 extern int mtext_cspn (MText *mt1, MText *mt2);
372 extern int mtext_pbrk (MText *mt1, MText *mt2);
374 extern int mtext_text (MText *mt1, int pos, MText *mt2);
376 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
378 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
380 extern int mtext_casecmp (MText *mt1, MText *mt2);
382 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
384 /*** @ingroup m17nPlist */
385 extern MPlist *mplist_deserialize (MText *mt);
388 * (5-3) Text properties
391 /*** @ingroup m17nCore */
392 /***en @defgroup m17nTextProperty Text Property */
393 /***ja @defgroup m17nTextProperty ¥Æ¥¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
395 /*** @ingroup m17nTextProperty */
397 @brief Flag bits to control text property.
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
404 enum MTextPropertyControl
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
409 MTEXTPROP_FRONT_STICKY = 0x01,
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
414 MTEXTPROP_REAR_STICKY = 0x02,
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,
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,
424 /***en If this flag bit is on, the text property is not
425 automatically merged with the others. */
426 MTEXTPROP_NO_MERGE = 0x10,
428 MTEXTPROP_CONTROL_MAX = 0x1F
432 extern MSymbol Mtext_prop_serializer;
433 extern MSymbol Mtext_prop_deserializer;
436 /*** @ingroup m17nTextProperty */
438 @brief Type of serializer functions.
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
444 @seealso Mtext_prop_serialize (), Mtext_prop_serializer
447 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
449 /*** @ingroup m17nTextProperty */
451 @brief Type of deserializer functions.
453 This is the type of deserializer functions. If the key of a
454 symbol property is #Msymbol_prop_deserializer, the value must be
457 @seealso Mtext_prop_deserialize (), Mtext_prop_deserializer
459 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
461 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
463 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
464 void **values, int num);
466 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
468 extern int mtext_put_prop (MText *mt, int from, int to,
469 MSymbol key, void *val);
471 extern int mtext_put_prop_values (MText *mt, int from, int to,
472 MSymbol key, void **values, int num);
474 extern int mtext_push_prop (MText *mt, int from, int to,
475 MSymbol key, void *val);
477 extern int mtext_pop_prop (MText *mt, int from, int to,
480 extern int mtext_change_prop (MText *mt, int from, int to,
482 int (*func) (int, void ***, int *));
484 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
485 int *from, int *to, int deeper);
488 typedef struct MTextProperty MTextProperty;
492 extern MTextProperty *mtext_property (MSymbol key, void *val,
495 extern MText *mtext_property_mtext (MTextProperty *prop);
497 extern MSymbol mtext_property_key (MTextProperty *prop);
499 extern void *mtext_property_value (MTextProperty *prop);
501 extern int mtext_property_start (MTextProperty *prop);
503 extern int mtext_property_end (MTextProperty *prop);
505 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
507 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
508 MTextProperty **props, int num);
510 extern int mtext_attach_property (MText *mt, int from, int to,
511 MTextProperty *prop);
513 extern int mtext_detach_property (MTextProperty *prop);
515 extern int mtext_push_property (MText *mt, int from, int to,
516 MTextProperty *prop);
518 extern MText *mtext_serialize (MText *mt, int from, int to,
519 MPlist *property_list);
521 extern MText *mtext_deserialize (MText *mt);
527 #endif /* _M17N_CORE_H_ */