Main Page   Modules   Data Structures   Globals   Appendix  

m17n-core.h

Go to the documentation of this file.
00001 /* m17n-core.h -- header file for the CORE API of the m17n library.
00002    Copyright (C) 2003, 2004
00003      National Institute of Advanced Industrial Science and Technology (AIST)
00004      Registration Number H15PRO112
00005 
00006    This file is part of the m17n library.
00007 
00008    The m17n library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public License
00010    as published by the Free Software Foundation; either version 2.1 of
00011    the License, or (at your option) any later version.
00012 
00013    The m17n library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with the m17n library; if not, write to the Free
00020    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021    02111-1307, USA.  */
00022 
00023 #ifndef _M17N_CORE_H_
00024 #define _M17N_CORE_H_
00025 
00026 #ifdef __cplusplus
00027 extern "C"
00028 {
00029 #endif
00030 
00031 /*
00032  * Header file for m17n library.
00033  */
00034 
00035 /* (C1) Introduction */
00036 
00037 /***en @defgroup m17nIntro Introduction  */
00038 /***ja @defgroup m17nIntro はじめに  */
00039 /*=*/
00040 
00041 #define M17NLIB_MAJOR_VERSION 1
00042 #define M17NLIB_MINOR_VERSION 0
00043 #define M17NLIB_VERSION_NAME "1.0"
00044 
00045 extern void m17n_init_core (void);
00046 #define M17N_INIT() m17n_init_core ()
00047 extern void m17n_fini_core (void);
00048 #define M17N_FINI() m17n_fini_core ()
00049 
00050 /***en @defgroup m17nCore CORE API  */
00051 /***ja @defgroup m17nCore CORE API */
00052 /*=*/
00053 /*** @ingroup m17nCore */
00054 /***en @defgroup m17nObject Managed Object */
00055 /***ja @defgroup m17nObject 管理下オブジェクト */
00056 /*=*/
00057 
00058 /*** @ingroup m17nObject  */
00059 /***en
00060     @brief The first member of a managed object.
00061 
00062     When an application program defines a new structure for managed
00063     objects, its first member must be of the type @c struct
00064     #M17NObjectHead.  Its contents are used by the m17n library, and
00065     application programs should never touch them.  */
00066 
00067 typedef struct
00068 {
00069   void *filler[2];
00070 } M17NObjectHead;
00071 
00072 /*=*/
00073 
00074 /* Return a newly allocated managed object.  */
00075 extern void *m17n_object_setup (int size, void (*freer) (void *));
00076 
00077 /* Increment the reference count of managed object OBJECT.  */
00078 extern int m17n_object_ref (void *object);
00079 
00080 /* Decrement the reference count of managed object OBJECT.  */
00081 extern int m17n_object_unref (void *object);
00082 
00083 /*=*/
00084 
00085 /* (C2) Symbol handling */
00086 
00087 /*** @ingroup m17nCore */
00088 /***en @defgroup m17nSymbol Symbol  */
00089 /***ja @defgroup m17nSymbol シンボル */
00090 /*=*/
00091 
00092 /***
00093     @ingroup m17nSymbol */
00094 /***en
00095     @brief Type of symbols.
00096 
00097     The type #MSymbol is for a @e symbol object.  Its internal
00098     structure is concealed from application programs.  */
00099 
00100 /***ja
00101     @brief シンボルの型
00102 
00103     #MSymbol はシンボルオブジェクトの型へのポインタである。 */
00104 
00105 typedef struct MSymbol *MSymbol;
00106 
00107 /*=*/
00108 
00109 /* Predefined symbols. */ 
00110 extern MSymbol Mnil;
00111 extern MSymbol Mt;
00112 extern MSymbol Mstring;
00113 extern MSymbol Msymbol;
00114 extern MSymbol Mtext;
00115 
00116 /* Return a symbol of name NAME.  */
00117 extern MSymbol msymbol (const char *name);
00118 
00119 /* Return a managing key of name NAME.  */
00120 extern MSymbol msymbol_as_managing_key (const char *name);
00121 
00122 /* Return a symbol of name NAME if it already exists.  */
00123 extern MSymbol msymbol_exist (const char *name);
00124 
00125 /* Return the name of SYMBOL.  */
00126 extern char *msymbol_name (MSymbol symbol);
00127 
00128 /* Give SYMBOL KEY property with value VALUE.  */
00129 extern int msymbol_put (MSymbol symbol, MSymbol key, void *val);
00130 
00131 /*** Return KEY property value of SYMBOL.  */
00132 extern void *msymbol_get (MSymbol symbol, MSymbol key);
00133 
00134 /* 
00135  *  (2-1) Property List
00136  */
00137 
00138 /*** @ingroup m17nCore */
00139 /***en @defgroup m17nPlist Property List */
00140 /***ja @defgroup m17nPlist プロパティリスト・オブジェクト */
00141 /*=*/
00142 
00143 /***
00144     @ingroup m17nPlist */ 
00145 /***en
00146     @brief Type of property list objects.
00147 
00148     The type #MPlist is for a property list object.  Its internal
00149     structure is concealed from application programs.  */
00150 
00151 typedef struct MPlist MPlist;
00152 
00153 /*=*/
00154 
00155 extern MSymbol Mplist, Minteger;
00156 
00157 extern MPlist *mplist ();
00158 
00159 extern MPlist *mplist_copy (MPlist *plist);
00160 
00161 extern MPlist *mplist_add (MPlist *plist, MSymbol key, void *val);
00162 
00163 extern MPlist *mplist_push (MPlist *plist, MSymbol key, void *val);
00164 
00165 extern void *mplist_pop (MPlist *plist);
00166 
00167 extern MPlist *mplist_put (MPlist *plist, MSymbol key, void *val);
00168 
00169 extern void *mplist_get (MPlist *plist, MSymbol key);
00170 
00171 extern MPlist *mplist_find_by_key (MPlist *plist, MSymbol key);
00172 
00173 extern MPlist *mplist_find_by_value (MPlist *plist, void *val);
00174 
00175 extern MPlist *mplist_next (MPlist *plist);
00176 
00177 extern MPlist *mplist_set (MPlist *plist, MSymbol key, void *val);
00178 
00179 extern int mplist_length (MPlist *plist);
00180 
00181 extern MSymbol mplist_key (MPlist *plist);
00182 
00183 extern void *mplist_value (MPlist *plist);
00184 
00185 /* (S1) Characters */
00186 
00187 /*=*/
00188 /*** @ingroup m17nCore */
00189 /***en @defgroup m17nCharacter Character */
00190 /***ja @defgroup m17nCharacter 文字 */
00191 /*=*/
00192 
00193 #define MCHAR_MAX 0x3FFFFF
00194 /*#define MCHAR_MAX 0x7FFFFFFF*/
00195 
00196 extern MSymbol Mscript;
00197 extern MSymbol Mname;
00198 extern MSymbol Mcategory;
00199 extern MSymbol Mcombining_class;
00200 extern MSymbol Mbidi_category;
00201 extern MSymbol Msimple_case_folding;
00202 extern MSymbol Mcomplicated_case_folding;
00203 
00204 extern MSymbol mchar_define_property (char *name, MSymbol type);
00205 
00206 extern void *mchar_get_prop (int c, MSymbol key);
00207 
00208 extern int mchar_put_prop (int c, MSymbol key, void *val);
00209 
00210 /* (C3) Handling chartable */
00211 
00212 /*** @ingroup m17nCore */
00213 /***en @defgroup m17nChartable Chartable */
00214 /***ja @defgroup m17nChartable 文字テーブル */
00215 /*=*/
00216 extern MSymbol Mchar_table;
00217 
00218 /***
00219     @ingroup m17nChartable */
00220 /***en
00221     @brief Type of chartables.
00222 
00223     The type #MCharTable is for a @e chartable objects.  Its
00224     internal structure is concealed from application programs.  */
00225 
00226 /***ja
00227     @brief 文字テーブルの型
00228 
00229     #MCharTable 型は @e 文字テーブル オブジェクト用の構造体である。
00230     内部構造はアプリケーションプログラムからは見えない。  */
00231 
00232 typedef struct MCharTable MCharTable;
00233 /*=*/
00234 
00235 extern MCharTable *mchartable (MSymbol key, void *default_value);
00236 
00237 extern void *mchartable_lookup (MCharTable *table, int c);
00238 
00239 extern int mchartable_set (MCharTable *table, int c, void *val);
00240 
00241 extern int mchartable_set_range (MCharTable *table, int from, int to,
00242                                  void *val);
00243 
00244 extern int mchartable_map (MCharTable *table, void *ignore,
00245                            void (*func) (int from, int to,
00246                                          void *val, void *arg), 
00247                            void *func_arg);
00248 
00249 extern void mchartable_range (MCharTable *table, int *from, int *to);
00250 
00251 /*
00252  *  (5) Handling M-text.
00253  *      "M" of M-text stands for:
00254  *      o Multilingual
00255  *      o Metamorphic
00256  *      o More than string
00257  */
00258 
00259 /*** @ingroup m17nCore */
00260 /***en @defgroup m17nMtext M-text */
00261 /***ja @defgroup m17nMtext M-text */
00262 /*=*/
00263 
00264 /*
00265  * (5-1) M-text basics
00266  */
00267 
00268 /*** @ingroup m17nMtext */
00269 /***en
00270     @brief Type of @e M-texts.
00271 
00272     The type #MText is for an @e M-text object.  Its internal
00273     structure is concealed from application programs.  */
00274 
00275 /***ja
00276     @brief @e MText 用構造体 
00277 
00278     #Mtext 構造体は @e M-text オブジェクトに用いられる。内部構造はア
00279     プリケーションプログラムからは見えない。
00280 
00281     @latexonly \IPAlabel{MText} @endlatexonly
00282     @latexonly \IPAlabel{MText->MPlist} @endlatexonly  */
00283 
00284 typedef struct MText MText;
00285 
00286 /*=*/
00287 
00288 extern MText *mtext ();
00289 
00290 /*=*/
00291 
00292 /***en
00293     @brief Enumeration for specifying the format of an M-text.
00294 
00295     The enum #MTextFormat is used as an argument of the
00296     mtext_from_data () function to specify the format of data from
00297     which an M-text is created.  */
00298 
00299 enum MTextFormat
00300   {
00301     MTEXT_FORMAT_US_ASCII,
00302     MTEXT_FORMAT_UTF_8,
00303     MTEXT_FORMAT_UTF_16LE,
00304     MTEXT_FORMAT_UTF_16BE,
00305     MTEXT_FORMAT_UTF_32LE,
00306     MTEXT_FORMAT_UTF_32BE,
00307     MTEXT_FORMAT_MAX
00308   };
00309 /*=*/
00310 
00311 extern MText *mtext_from_data (void *data, int nitems,
00312                                enum MTextFormat format);
00313 
00314 
00315 /*=*/
00316 
00317 /*
00318  *  (5-2) Functions to manipulate M-texts.  They correspond to string
00319  *   manipulating functions in libc.
00320  *   In the following functions, mtext_XXX() corresponds to strXXX().
00321  */
00322 
00323 extern int mtext_len (MText *mt);
00324 
00325 extern int mtext_ref_char (MText *mt, int pos);
00326 
00327 extern int mtext_set_char (MText *mt, int pos, int c);
00328 
00329 extern MText *mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to);
00330 
00331 extern int mtext_compare (MText *mt1, int from1, int to1,
00332                           MText *mt2, int from2, int to2);
00333 
00334 extern int mtext_case_compare (MText *mt1, int from1, int to1,
00335                                MText *mt2, int from2, int to2);
00336 
00337 extern int mtext_character (MText *mt, int from, int to, int c);
00338 
00339 extern int mtext_del (MText *mt, int from, int to);
00340 
00341 extern int mtext_ins (MText *mt1, int pos, MText *mt2);
00342 
00343 extern int mtext_ins_char (MText *mt, int pos, int c, int n);
00344 
00345 extern MText *mtext_cat_char (MText *mt, int c);
00346 
00347 extern MText *mtext_duplicate (MText *mt, int from, int to);
00348 
00349 extern MText *mtext_dup (MText *mt);
00350 
00351 extern MText *mtext_cat (MText *mt1, MText *mt2);
00352 
00353 extern MText *mtext_ncat (MText *mt1, MText *mt2, int n);
00354 
00355 extern MText *mtext_cpy (MText *mt1, MText *mt2);
00356 
00357 extern MText *mtext_ncpy (MText *mt1, MText *mt2, int n);
00358 
00359 extern int mtext_chr (MText *mt, int c);
00360 
00361 extern int mtext_rchr (MText *mt, int c);
00362 
00363 extern int mtext_cmp (MText *mt1, MText *mt2);
00364 
00365 extern int mtext_ncmp (MText *mt1, MText *mt2, int n);
00366 
00367 extern int mtext_spn (MText *mt1, MText *mt2);
00368 
00369 extern int mtext_cspn (MText *mt1, MText *mt2);
00370 
00371 extern int mtext_pbrk (MText *mt1, MText *mt2);
00372 
00373 extern int mtext_text (MText *mt1, int pos, MText *mt2);
00374 
00375 extern int mtext_search (MText *mt1, int from, int to, MText *mt2);
00376 
00377 extern MText *mtext_tok (MText *mt, MText *delim, int *pos);
00378 
00379 extern int mtext_casecmp (MText *mt1, MText *mt2);
00380 
00381 extern int mtext_ncasecmp (MText *mt1, MText *mt2, int n);
00382 
00383 /*
00384  * (5-3) Text properties
00385  */
00386 
00387 /*** @ingroup m17nCore */
00388 /***en @defgroup m17nTextProperty Text Property */
00389 /***ja @defgroup m17nTextProperty テキストプロパティ */
00390 /*=*/
00391 /*** @ingroup m17nTextProperty */
00392 /***en
00393     @brief Flag bits to control text property.
00394 
00395     The mtext_property () funciton accepts logical OR of these flag
00396     bits as an argument.  They control the behaviour of the created
00397     text property as described in the documentation of each flag
00398     bit.  */
00399 
00400 enum MTextPropertyControl
00401   {
00402     /***en If this flag bit is on, an M-text inserted at the start
00403         position or at the middle of the text property inherits the
00404         text property.  */
00405     MTEXTPROP_FRONT_STICKY = 0x01,
00406 
00407     /***en If this flag bit is on, an M-text inserted at the end
00408         position or at the middle of the text property inherits the
00409         text property.  */
00410     MTEXTPROP_REAR_STICKY = 0x02,
00411 
00412     /***en If this flag bit is on, the text property is removed if a
00413         text in its region is modified.  */
00414     MTEXTPROP_VOLATILE_WEAK = 0x04,
00415 
00416     /***en If this flag bit is on, the text property is removed if a
00417         text or the other text property in its region is modified.  */
00418     MTEXTPROP_VOLATILE_STRONG = 0x08,
00419 
00420     /***en If this flag bit is on, the text property is not
00421         automatically merged with the others.  */
00422     MTEXTPROP_NO_MERGE = 0x10,
00423 
00424     MTEXTPROP_CONTROL_MAX = 0x1F
00425   };
00426 
00427 /*=*/
00428 extern MSymbol Mtext_prop_serializer;
00429 extern MSymbol Mtext_prop_deserializer;
00430 
00431 
00432 /*** @ingroup m17nTextProperty */
00433 /***en
00434     @brief Type of serializer functions.
00435 
00436     This is the type of serializer functions.  If the key of a symbol
00437     property is #Msymbol_prop_serializer, the value must be of this
00438     type.
00439 
00440     @seealso Mtext_prop_serialize (), Mtext_prop_serializer
00441 */
00442 
00443 typedef MPlist *(*MTextPropSerializeFunc) (void *val);
00444 
00445 /*** @ingroup m17nTextProperty */
00446 /***en
00447     @brief Type of deserializer functions.
00448 
00449     This is the type of deserializer functions.  If the key of a
00450     symbol property is #Msymbol_prop_deserializer, the value must be
00451     of this type.
00452 
00453     @seealso Mtext_prop_deserialize (), Mtext_prop_deserializer
00454 */
00455 typedef void *(*MTextPropDeserializeFunc) (MPlist *plist);
00456 
00457 extern void *mtext_get_prop (MText *mt, int pos, MSymbol key);
00458 
00459 extern int mtext_get_prop_values (MText *mt, int pos, MSymbol key,
00460                                   void **values, int num);
00461 
00462 extern int mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys);
00463 
00464 extern int mtext_put_prop (MText *mt, int from, int to,
00465                            MSymbol key, void *val);
00466 
00467 extern int mtext_put_prop_values (MText *mt, int from, int to,
00468                                   MSymbol key, void **values, int num);
00469 
00470 extern int mtext_push_prop (MText *mt, int from, int to,
00471                             MSymbol key, void *val);
00472 
00473 extern int mtext_pop_prop (MText *mt, int from, int to,
00474                            MSymbol key);
00475 
00476 extern int mtext_change_prop (MText *mt, int from, int to,
00477                               MSymbol key,
00478                               int (*func) (int, void ***, int *));
00479 
00480 extern int mtext_prop_range (MText *mt, MSymbol key, int pos,
00481                              int *from, int *to, int deeper);
00482 
00483 /*=*/
00484 typedef struct MTextProperty MTextProperty;
00485 
00486 /*=*/
00487 
00488 extern MTextProperty *mtext_property (MSymbol key, void *val,
00489                                       int control_bits);
00490 
00491 extern MText *mtext_property_mtext (MTextProperty *prop);
00492 
00493 extern MSymbol mtext_property_key (MTextProperty *prop);
00494 
00495 extern void *mtext_property_value (MTextProperty *prop);
00496 
00497 extern int mtext_property_start (MTextProperty *prop);
00498 
00499 extern int mtext_property_end (MTextProperty *prop);
00500 
00501 extern MTextProperty *mtext_get_property (MText *mt, int pos, MSymbol key);
00502 
00503 extern int mtext_get_properties (MText *mt, int pos, MSymbol key,
00504                                  MTextProperty **props, int num);
00505 
00506 extern int mtext_attach_property (MText *mt, int from, int to,
00507                                   MTextProperty *prop);
00508 
00509 extern int mtext_detach_property (MTextProperty *prop);
00510 
00511 extern int mtext_push_property (MText *mt, int from, int to,
00512                                 MTextProperty *prop);
00513 
00514 extern MText *mtext_serialize (MText *mt, int from, int to,
00515                                MPlist *property_list);
00516 
00517 extern MText *mtext_deserialize (MText *mt);
00518 
00519 #ifdef __cplusplus
00520 }
00521 #endif
00522 
00523 #endif /* _M17N_CORE_H_ */
00524 
00525 /*
00526   Local Variables:
00527   coding: euc-japan
00528   End:
00529 */

Top of this page

Main Page   Modules   Data Structures   Globals   Appendix  

mulemark mule-aist@m17n.org