libUnihan  0.5.3
Unihan.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright © 2008 Red Hat, Inc. All rights reserved.
10  * Copyright © 2008 Ding-Yi Chen <dchen at redhat dot com>
11  *
12  * This file is part of the libUnihan Project.
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this program; if not, write to the
26  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
27  * Boston, MA 02111-1307 USA
28  */
29 #ifndef UNIHAN_H_
30 #define UNIHAN_H_
31 #include "Unihan_enum.h"
32 #include "Unihan_phonetic.h"
33 #include "sqlite_functions.h"
34 #include "str_functions.h"
35 
39 typedef int (*UnihanCallback)(void* userOption,int col_num,char** results,char** col_names);
40 
41 
49 typedef struct {
50  const char *name;
51  const char *description;
53 
61 typedef struct {
63  const char *sourceMapping;
65 
66 
71 typedef struct {
72  const char* funcName;
73  int argc;
74  void (*func)(sqlite3_context *context, int argc, sqlite3_value **argv);
75  void (*stepFunc)(sqlite3_context *context, int argc, sqlite3_value **argv);
76  void (*finalizeFunc)(sqlite3_context *context);
78 
83 extern const DatabaseFuncStru DATABASE_FUNCS[];
84 
95 typedef guint UnihanQueryOption;
96 
97 #define UNIHAN_QUERY_OPTION_LIKE 1
98 #define UNIHAN_QUERY_OPTION_SCALAR_STRING 1 << 1
99 #define UNIHAN_QUERY_OPTION_SHOW_GIVEN_FIELD 1 << 2
100 #define UNIHAN_QUERY_OPTION_PINYIN_TONE_ACCENT 1 << 3
101 #define UNIHAN_QUERY_OPTION_PINYIN_FORMAT_MASK 7 << 4
102 #define UNIHAN_QUERY_OPTION_ZHUYIN_FORCE_DISPLAY 1 << 7
103 #define UNIHAN_QUERY_OPTION_ZHUYIN_FORMAT_MASK 7 << 8
104 
105 #define UNIHAN_QUERY_OPTION_DEFAULT (PINYIN_ACCENT_UNIHAN << 4) | (ZHUYIN_TONEMARK_ORIGINAL << 8)
106 
107 
114 #define UNIHAN_QUERY_OPTION_GET_PINYIN_FORMAT(options) (options & UNIHAN_QUERY_OPTION_PINYIN_FORMAT_MASK) >> 4
115 
122 #define UNIHAN_QUERY_OPTION_SET_PINYIN_FORMAT(options,format) options |= format << 4
123 
130 #define UNIHAN_QUERY_OPTION_GET_ZHUYIN_FORMAT(options) (options & UNIHAN_QUERY_OPTION_ZHUYIN_FORMAT_MASK) >> 8
131 
138 #define UNIHAN_QUERY_OPTION_SET_ZHUYIN_FORMAT(options,format) options |= format << 8
139 
165 SQL_Result *unihan_find_all_matched(UnihanField givenField, const char *givenValue,
166  UnihanField queryField, UnihanQueryOption qOption);
167 
184 char* unihan_find_firstMatched(UnihanField givenField, const char* givenValue,
185  UnihanField queryField, UnihanQueryOption qOption );
186 
202 
217 int unihan_insert(UnihanTable table,StringList *valueList);
218 
231 
255 int unihan_insert_value(gunichar code, UnihanField field, const char *value);
256 
264 gboolean unihanChar_has_property(gunichar code, UnihanField field);
265 
273 gboolean unihanChar_is_in_source(gunichar code, UnihanIRG_SourceId source);
274 
285 
298 gboolean unihanChar_is_common_in_locale(gunichar code, UnihanLocale locale);
299 
307 UnihanRange unihanChar_in_range(gunichar code);
308 
315 gunichar unihanChar_parse(const char *str);
316 
323 char *unihanChar_to_scalar_string(gunichar code);
324 
325 
333 sqlite3 *unihanDb_get();
334 
344 
345 
379 int unihanDb_open(const char *filename, int flags);
380 
390 
399 int unihanDb_close();
400 
408 int unihanField_array_index(UnihanField field, const UnihanField* fieldArray);
409 
418 
436 
449 
468 
476 gboolean unihanField_is_IRG_Source(UnihanField field);
477 
478 
489 gboolean unihanField_is_indexed(UnihanField field);
490 
497 gboolean unihanField_is_integer(UnihanField field);
498 
522 
538 gboolean unihanField_is_lowercase(UnihanField field);
539 
546 gboolean unihanField_is_mandarin(UnihanField field);
547 
565 gboolean unihanField_is_pseudo(UnihanField field);
566 
575 gboolean unihanField_is_ucs4(UnihanField field);
576 
591 gboolean unihanField_is_singleton(UnihanField field);
592 
599 UnihanField unihanField_parse(const char *str);
600 
607 const char* unihanField_to_string(UnihanField field);
608 
620 
629 
636 UnihanIRG_SourceId unihanIRG_SourceId_parse(const char *sourceShortName);
637 
648 
655 
665 int unihanSql_count_matches(const char * sqlClause, char **errMsg_ptr);
666 
678 int unihanSql_exec(char *sqlClause, UnihanCallback callback,
679  void *callbackOption, char **errMsg_ptr);
680 
688 SQL_Result *unihanSql_get_sql_result(const char *sqlClause);
689 
690 
698 
707 const char *unihanLocale_to_string(UnihanLocale locale);
708 
717 const char *unihanRange_to_string(UnihanRange uRange);
718 
725 UnihanTable unihanTable_parse(const char * tableName);
726 
735 const char *unihanTable_to_string(UnihanTable table);
736 
737 
751 
767 
778 
779 
780 
781 #endif /* UNIHAN_H */