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_VERSION_NAME "1.0"
45 extern void m17n_init_core (void);
46 #define M17N_INIT() m17n_init_core ()
47 extern void m17n_fini_core (void);
48 #define M17N_FINI() m17n_fini_core ()
50 /***en @defgroup m17nCore CORE API */
51 /***ja @defgroup m17nCore CORE API */
53 /*** @ingroup m17nCore */
54 /***en @defgroup m17nObject Managed Object */
55 /***ja @defgroup m17nObject ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È */
58 /*** @ingroup m17nObject */
60 @brief The first member of a managed object.
62 When an application program defines a new structure for managed
63 objects, its first member must be of the type @c struct
64 #M17NObjectHead. Its contents are used by the m17n library, and
65 application programs should never touch them. */
74 /* Return a newly allocated managed object. */
75 extern void *m17n_object_setup (int size, void (*freer) (void *));
77 /* Increment the reference count of managed object OBJECT. */
78 extern int m17n_object_ref (void *object);
80 /* Decrement the reference count of managed object OBJECT. */
81 extern int m17n_object_unref (void *object);
85 /* (C2) Symbol handling */
87 /*** @ingroup m17nCore */
88 /***en @defgroup m17nSymbol Symbol */
89 /***ja @defgroup m17nSymbol ¥·¥ó¥Ü¥ë */
93 @ingroup m17nSymbol */
95 @brief Type of symbols.
97 The type #MSymbol is for a @e symbol object. Its internal
98 structure is concealed from application programs. */
103 #MSymbol ¤Ï¥·¥ó¥Ü¥ë¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ */
105 typedef struct MSymbol *MSymbol;
109 /* Predefined symbols. */
112 extern MSymbol Mstring;
113 extern MSymbol Msymbol;
114 extern MSymbol Mtext;
116 /* Return a symbol of name NAME. */
117 extern MSymbol msymbol (const char *name);
119 /* Return a managing key of name NAME. */
120 extern MSymbol msymbol_as_managing_key (const char *name);
122 /* Return a symbol of name NAME if it already exists. */
123 extern MSymbol msymbol_exist (const char *name);
125 /* Return the name of SYMBOL. */
126 extern char *msymbol_name (MSymbol symbol);
128 /* Give SYMBOL KEY property with value VALUE. */
129 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
131 /*** Return KEY property value of SYMBOL. */
132 extern void *msymbol_get (MSymbol symbol, MSymbol key);
135 * (2-1) Property List
138 /*** @ingroup m17nCore */
139 /***en @defgroup m17nPlist Property List */
140 /***ja @defgroup m17nPlist ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¡¦¥ª¥Ö¥¸¥§¥¯¥È */
144 @ingroup m17nPlist */
146 @brief Type of property list objects.
148 The type #MPlist is for a property list object. Its internal
149 structure is concealed from application programs. */
151 typedef struct MPlist MPlist;
155 extern MSymbol Mplist, Minteger;
157 extern MPlist *mplist ();
159 extern MPlist *mplist_copy (MPlist *plist);
161 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
163 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
165 extern void *mplist_pop (MPlist *plist);
167 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
169 extern void *mplist_get (MPlist *plist, MSymbol key);
171 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
173 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
175 extern MPlist *mplist_next (MPlist *plist);
177 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
179 extern int mplist_length (MPlist *plist);
181 extern MSymbol mplist_key (MPlist *plist);
183 extern void *mplist_value (MPlist *plist);
185 /* (S1) Characters */
188 /*** @ingroup m17nCore */
189 /***en @defgroup m17nCharacter Character */
190 /***ja @defgroup m17nCharacter ʸ»ú */
193 #define MCHAR_MAX 0x3FFFFF
194 /*#define MCHAR_MAX 0x7FFFFFFF*/
196 extern MSymbol Mscript;
197 extern MSymbol Mname;
198 extern MSymbol Mcategory;
199 extern MSymbol Mcombining_class;
200 extern MSymbol Mbidi_category;
201 extern MSymbol Msimple_case_folding;
202 extern MSymbol Mcomplicated_case_folding;
204 extern MSymbol mchar_define_property (char *name, MSymbol type);
206 extern void *mchar_get_prop (int c, MSymbol key);
208 extern int mchar_put_prop (int c, MSymbol key, void *val);
210 /* (C3) Handling chartable */
212 /*** @ingroup m17nCore */
213 /***en @defgroup m17nChartable Chartable */
214 /***ja @defgroup m17nChartable ʸ»ú¥Æ¡¼¥Ö¥ë */
216 extern MSymbol Mchar_table;
219 @ingroup m17nChartable */
221 @brief Type of chartables.
223 The type #MCharTable is for a @e chartable objects. Its
224 internal structure is concealed from application programs. */
227 @brief ʸ»ú¥Æ¡¼¥Ö¥ë¤Î·¿
229 #MCharTable ·¿¤Ï @e ʸ»ú¥Æ¡¼¥Ö¥ë ¥ª¥Ö¥¸¥§¥¯¥ÈÍѤι½Â¤ÂΤǤ¢¤ë¡£
230 ÆâÉô¹½Â¤¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£ */
232 typedef struct MCharTable MCharTable;
235 extern MCharTable *mchartable (MSymbol key, void *default_value);
237 extern void *mchartable_lookup (MCharTable *table, int c);
239 extern int mchartable_set (MCharTable *table, int c, void *val);
241 extern int mchartable_set_range (MCharTable *table, int from, int to,
244 extern int mchartable_map (MCharTable *table, void *ignore,
245 void (*func) (int from, int to,
246 void *val, void *arg),
249 extern void mchartable_range (MCharTable *table, int *from, int *to);
252 * (5) Handling M-text.
253 * "M" of M-text stands for:
259 /*** @ingroup m17nCore */
260 /***en @defgroup m17nMtext M-text */
261 /***ja @defgroup m17nMtext M-text */
265 * (5-1) M-text basics
268 /*** @ingroup m17nMtext */
270 @brief Type of @e M-texts.
272 The type #MText is for an @e M-text object. Its internal
273 structure is concealed from application programs. */
276 @brief @e MText Íѹ½Â¤ÂÎ
278 #Mtext ¹½Â¤ÂÎ¤Ï @e M-text ¥ª¥Ö¥¸¥§¥¯¥È¤ËÍѤ¤¤é¤ì¤ë¡£ÆâÉô¹½Â¤¤Ï¥¢
279 ¥×¥ê¥±¡¼¥·¥ç¥ó¥×¥í¥°¥é¥à¤«¤é¤Ï¸«¤¨¤Ê¤¤¡£
281 @latexonly \IPAlabel{MText} @endlatexonly
282 @latexonly \IPAlabel{MText->MPlist} @endlatexonly */
284 typedef struct MText MText;
288 extern MText *mtext ();
293 @brief Enumeration for specifying the format of an M-text.
295 The enum #MTextFormat is used as an argument of the
296 mtext_from_data () function to specify the format of data from
297 which an M-text is created. */
301 MTEXT_FORMAT_US_ASCII,
303 MTEXT_FORMAT_UTF_16LE,
304 MTEXT_FORMAT_UTF_16BE,
305 MTEXT_FORMAT_UTF_32LE,
306 MTEXT_FORMAT_UTF_32BE,
311 extern MText *mtext_from_data (void *data, int nitems,
312 enum MTextFormat format);
318 * (5-2) Functions to manipulate M-texts. They correspond to string
319 * manipulating functions in libc.
320 * In the following functions, mtext_XXX() corresponds to strXXX().
323 extern int mtext_len (MText *mt);
325 extern int mtext_ref_char (MText *mt, int pos);
327 extern int mtext_set_char (MText *mt, int pos, int c);
329 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
331 extern int mtext_compare (MText *mt1, int from1, int to1,
332 MText *mt2, int from2, int to2);
334 extern int mtext_case_compare (MText *mt1, int from1, int to1,
335 MText *mt2, int from2, int to2);
337 extern int mtext_character (MText *mt, int from, int to, int c);
339 extern int mtext_del (MText *mt, int from, int to);
341 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
343 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
345 extern MText *mtext_cat_char (MText *mt, int c);
347 extern MText *mtext_duplicate (MText *mt, int from, int to);
349 extern MText *mtext_dup (MText *mt);
351 extern MText *mtext_cat (MText *mt1, MText *mt2);
353 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
355 extern MText *mtext_cpy (MText *mt1, MText *mt2);
357 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
359 extern int mtext_chr (MText *mt, int c);
361 extern int mtext_rchr (MText *mt, int c);
363 extern int mtext_cmp (MText *mt1, MText *mt2);
365 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
367 extern int mtext_spn (MText *mt1, MText *mt2);
369 extern int mtext_cspn (MText *mt1, MText *mt2);
371 extern int mtext_pbrk (MText *mt1, MText *mt2);
373 extern int mtext_text (MText *mt1, int pos, MText *mt2);
375 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
377 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
379 extern int mtext_casecmp (MText *mt1, MText *mt2);
381 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
384 * (5-3) Text properties
387 /*** @ingroup m17nCore */
388 /***en @defgroup m17nTextProperty Text Property */
389 /***ja @defgroup m17nTextProperty ¥Æ¥¥¹¥È¥×¥í¥Ñ¥Æ¥£ */
391 /*** @ingroup m17nTextProperty */
393 @brief Flag bits to control text property.
395 The mtext_property () funciton accepts logical OR of these flag
396 bits as an argument. They control the behaviour of the created
397 text property as described in the documentation of each flag
400 enum MTextPropertyControl
402 /***en If this flag bit is on, an M-text inserted at the start
403 position or at the middle of the text property inherits the
405 MTEXTPROP_FRONT_STICKY = 0x01,
407 /***en If this flag bit is on, an M-text inserted at the end
408 position or at the middle of the text property inherits the
410 MTEXTPROP_REAR_STICKY = 0x02,
412 /***en If this flag bit is on, the text property is removed if a
413 text in its region is modified. */
414 MTEXTPROP_VOLATILE_WEAK = 0x04,
416 /***en If this flag bit is on, the text property is removed if a
417 text or the other text property in its region is modified. */
418 MTEXTPROP_VOLATILE_STRONG = 0x08,
420 /***en If this flag bit is on, the text property is not
421 automatically merged with the others. */
422 MTEXTPROP_NO_MERGE = 0x10,
424 MTEXTPROP_CONTROL_MAX = 0x1F
428 extern MSymbol Mtext_prop_serializer;
429 extern MSymbol Mtext_prop_deserializer;
432 /*** @ingroup m17nTextProperty */
434 @brief Type of serializer functions.
436 This is the type of serializer functions. If the key of a symbol
437 property is #Msymbol_prop_serializer, the value must be of this
440 @seealso Mtext_prop_serialize (), Mtext_prop_serializer
443 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
445 /*** @ingroup m17nTextProperty */
447 @brief Type of deserializer functions.
449 This is the type of deserializer functions. If the key of a
450 symbol property is #Msymbol_prop_deserializer, the value must be
453 @seealso Mtext_prop_deserialize (), Mtext_prop_deserializer
455 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
457 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
459 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
460 void **values, int num);
462 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
464 extern int mtext_put_prop (MText *mt, int from, int to,
465 MSymbol key, void *val);
467 extern int mtext_put_prop_values (MText *mt, int from, int to,
468 MSymbol key, void **values, int num);
470 extern int mtext_push_prop (MText *mt, int from, int to,
471 MSymbol key, void *val);
473 extern int mtext_pop_prop (MText *mt, int from, int to,
476 extern int mtext_change_prop (MText *mt, int from, int to,
478 int (*func) (int, void ***, int *));
480 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
481 int *from, int *to, int deeper);
484 typedef struct MTextProperty MTextProperty;
488 extern MTextProperty *mtext_property (MSymbol key, void *val,
491 extern MText *mtext_property_mtext (MTextProperty *prop);
493 extern MSymbol mtext_property_key (MTextProperty *prop);
495 extern void *mtext_property_value (MTextProperty *prop);
497 extern int mtext_property_start (MTextProperty *prop);
499 extern int mtext_property_end (MTextProperty *prop);
501 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
503 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
504 MTextProperty **props, int num);
506 extern int mtext_attach_property (MText *mt, int from, int to,
507 MTextProperty *prop);
509 extern int mtext_detach_property (MTextProperty *prop);
511 extern int mtext_push_property (MText *mt, int from, int to,
512 MTextProperty *prop);
514 extern MText *mtext_serialize (MText *mt, int from, int to,
515 MPlist *property_list);
517 extern MText *mtext_deserialize (MText *mt);
523 #endif /* _M17N_CORE_H_ */