00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef UNIHAN_H_
00030 #define UNIHAN_H_
00031 #include "Unihan_enum.h"
00032 #include "Unihan_phonetic.h"
00033 #include "sqlite_functions.h"
00034 #include "str_functions.h"
00035
00040 #define FIELD_CACHE_DB "field.cache"
00041
00049 typedef struct {
00050 const char *name;
00051 const char *description;
00052 } UnihanIRG_SourceData;
00053
00059 typedef struct {
00060 UnihanField field;
00061 UnihanTable table;
00062 } UnihanFieldTablePair;
00063
00071 typedef struct {
00072 UnihanIRG_SourceId sourceId;
00073 const char *sourceMapping;
00074 } UnihanIRG_SourceRec;
00075
00076
00081 typedef struct {
00082 const char* funcName;
00083 int argc;
00084 void (*func)(sqlite3_context *context, int argc, sqlite3_value **argv);
00085 void (*stepFunc)(sqlite3_context *context, int argc, sqlite3_value **argv);
00086 void (*finalizeFunc)(sqlite3_context *context);
00087 } DatabaseFuncStru;
00088
00093 extern const DatabaseFuncStru DATABASE_FUNCS[];
00094
00105 typedef guint UnihanQueryOption;
00106
00107 #define UNIHAN_QUERY_OPTION_LIKE 1
00108 #define UNIHAN_QUERY_OPTION_SCALAR_STRING 1 << 1
00109 #define UNIHAN_QUERY_OPTION_SHOW_GIVEN_FIELD 1 << 2
00110 #define UNIHAN_QUERY_OPTION_PINYIN_TONE_ACCENT 1 << 3
00111 #define UNIHAN_QUERY_OPTION_PINYIN_FORMAT_MASK 7 << 4
00112 #define UNIHAN_QUERY_OPTION_ZHUYIN_FORCE_DISPLAY 1 << 7
00113 #define UNIHAN_QUERY_OPTION_ZHUYIN_FORMAT_MASK 7 << 8
00114
00115 #define UNIHAN_QUERY_OPTION_DEFAULT (PINYIN_ACCENT_UNIHAN << 4) | (ZHUYIN_TONEMARK_ORIGINAL << 8)
00117
00118
00124 #define UNIHAN_QUERY_OPTION_GET_PINYIN_FORMAT(options) (options & UNIHAN_QUERY_OPTION_PINYIN_FORMAT_MASK) >> 4
00125
00132 #define UNIHAN_QUERY_OPTION_SET_PINYIN_FORMAT(options,format) options |= format << 4
00133
00140 #define UNIHAN_QUERY_OPTION_GET_ZHUYIN_FORMAT(options) (options & UNIHAN_QUERY_OPTION_ZHUYIN_FORMAT_MASK) >> 8
00141
00148 #define UNIHAN_QUERY_OPTION_SET_ZHUYIN_FORMAT(options,format) options |= format << 8
00149
00175 SQL_Result *unihan_find_all_matched(UnihanField givenField, const char *givenValue,
00176 UnihanField queryField, UnihanQueryOption qOption);
00177
00194 char* unihan_find_first_matched(UnihanField givenField, const char* givenValue,
00195 UnihanField queryField, UnihanQueryOption qOption );
00196
00211 int unihan_count_matched_record(UnihanTable table,StringList *valueList);
00212
00227 int unihan_insert(UnihanTable table,StringList *valueList);
00228
00240 int unihan_insert_no_duplicate(UnihanTable table,StringList *valueList);
00241
00265 int unihan_insert_value(gunichar code, UnihanField field, const char *value);
00266
00274 gboolean unihanChar_has_field(gunichar code, UnihanField field);
00275
00283 gboolean unihanChar_is_in_source(gunichar code, UnihanIRG_SourceId source);
00284
00294 UnihanIRG_SourceId unihanChar_is_in_sources(gunichar code, UnihanIRG_SourceId source, ...);
00295
00308 gboolean unihanChar_is_common_in_locale(gunichar code, UnihanLocale locale);
00309
00317 UnihanRange unihanChar_in_range(gunichar code);
00318
00325 gunichar unihanChar_parse(const char *str);
00326
00338 char *unihanChar_to_scalar_string(gunichar code);
00339
00340
00348 sqlite3 *unihanDb_get();
00349
00350
00364 UnihanTable *unihanDb_get_all_tables();
00365
00379 SQL_Result *unihanDb_get_all_tableNames();
00380
00381
00415 int unihanDb_open(const char *filename, int flags);
00416
00425 int unihanDb_open_default();
00426
00435 int unihanDb_close();
00436
00444 int unihanField_array_index(UnihanField field, const UnihanField* fieldArray);
00445
00453 UnihanIRG_Source unihanField_get_IRG_source(UnihanField field);
00454
00471 UnihanTable unihanField_get_table(UnihanField field);
00472
00484 UnihanTable *unihanField_get_all_tables(UnihanField field);
00485
00503 UnihanTable unihanField_get_extra_table(UnihanField field);
00504
00520 UnihanTable *unihanField_get_required_tables(UnihanField field);
00521
00529 gboolean unihanField_is_IRG_Source(UnihanField field);
00530
00531
00542 gboolean unihanField_is_indexed(UnihanField field);
00543
00550 gboolean unihanField_is_integer(UnihanField field);
00551
00552
00565 gboolean unihanField_is_uppercase(UnihanField field);
00566
00582 gboolean unihanField_is_lowercase(UnihanField field);
00583
00590 gboolean unihanField_is_mandarin(UnihanField field);
00591
00609 gboolean unihanField_is_pseudo(UnihanField field);
00610
00619 gboolean unihanField_is_ucs4(UnihanField field);
00620
00635 gboolean unihanField_is_singleton(UnihanField field);
00636
00643 UnihanField unihanField_parse(const char *str);
00644
00651 const char* unihanField_to_string(UnihanField field);
00652
00663 gboolean unihanIRG_Source_has_no_mapping(UnihanIRG_SourceId sourceId);
00664
00672 const UnihanIRG_SourceData *unihanIRG_SourceData_get(UnihanIRG_SourceId sourceId);
00673
00680 UnihanIRG_SourceId unihanIRG_SourceId_parse(const char *sourceShortName);
00681
00691 UnihanIRG_SourceRec* unihanIRG_SourceRec_parse(UnihanField field,const char *value);
00692
00698 void unihanIRG_SourceRec_free(UnihanIRG_SourceRec *rec);
00699
00709 int unihanSql_count_matches(const char * sqlClause, char **errMsg_ptr);
00710
00722 int unihanSql_exec(char *sqlClause, sqlite_exec_callback callback,
00723 void *callbackOption, char **errMsg_ptr);
00724
00732 SQL_Result *unihanSql_get_sql_result(const char *sqlClause);
00733
00734
00741 UnihanLocale unihanLocale_parse(char *str);
00742
00751 const char *unihanLocale_to_string(UnihanLocale locale);
00752
00761 const char *unihanRange_to_string(UnihanRange uRange);
00762
00769 UnihanTable unihanTable_parse(const char * tableName);
00770
00779 const char *unihanTable_to_string(UnihanTable table);
00780
00781
00794 UnihanField* unihanTable_get_db_fields(UnihanTable table);
00795
00810 UnihanField* unihanTable_get_fields(UnihanTable table);
00811
00821 UnihanField* unihanTable_get_primary_key_fields(UnihanTable table);
00822 #endif