?? eb_structures.h
字號:
//Last Modify Date : 2003-5-6 17:02:37//: EB_structures.h : ErBiDigital public structures.#ifndef __EB_STRUCTURES_H_#define __EB_STRUCTURES_H_#include <string.h>#include "EB.h"//描述候選字詞的結構體typedef struct __candidate_info { unsigned char inputLen;//輸入串的長度,不包括詞語輸入的分隔符, 0表示為當前輸入串的長度 unsigned char len;//詞語的長度 unsigned char start;//候選字詞在EBInputStruct::candidates的開始位置 unsigned char reserved;//暫時沒有使用} CandInfo;//描述每一次選擇候選字詞的結構體typedef struct __candidate_sel_info { unsigned char inputLen;//輸入串的長度,不包括詞語輸入的分隔符 unsigned char outputLen;//對應候選詞的長度} CandSelInfo;//請注意:每加一個成員我們都需要修改EBDAssocInit, EBInputResettypedef struct __eb_input_struct{//in : can modified by user unsigned char inputMethod ; //輸入法 unsigned char candidateDesireLen ; //用戶需要的候選字長度 unsigned char interpunctionDesireLen;//用戶需要的標點符號的長度 unsigned char inputStringLen ; //已輸入串長度 unsigned char inputString[EB_INPUT_MAX_LEN] ; //已輸入串[0~9,*]#define EB_PHRASE_MAX_LEN 10 //詞的最大長度#define EB_ASSOC_ISN_MAX_LEN (EB_PHRASE_MAX_LEN - 1) //聯想字的最大長度 unsigned short associateISNs[EB_ASSOC_ISN_MAX_LEN] ; //聯想字 unsigned char tone ; //音調 unsigned char associateISNCount; //聯想字的個數 unsigned char syllableIndex ; //當前選擇的準確音節索引[1 -- 6]//out : can not modified by user/* 有字節對齊的問題,不能放在這#if EBD_USE_DESIRE_COUNT > 0 unsigned char candidateDesireCount;//指定輸出候選的個數,candidateLen是指候選的漢字的個數#endif*/ unsigned char candidateLen ; //實際長度 unsigned short candidates[EB_CANDIDATES_MAX_LEN] ; //候選字// syllables以前為一個二維的輸入,現在為1維數組,同樣保存了各個音節,//但是為不定長的方式,各個音節的頭地址可以通過syllablesPointer數組的對應的值獲得,//獲取指定下標的音節//#define EBIS_GET_SYLLABLE(eb, i) ((eb)->syllables + (eb)->syllablesPointer[i]) //獲取當前選擇的音節//#define EBIS_GET_SEL_SYLLABLE(eb) // ((eb)->syllableIndex == EB_NULL) ? NULL : EBIS_GET_SYLLABLE((eb), (eb)->syllableIndex - 1)//上面的兩個宏將幫助用戶獲取某一個特定音節 char syllables[256] ; unsigned short components[EB_COMPONENT_MAX_LEN] ; //部件 unsigned char syllableLen ; //syllables音節數量 unsigned char componentLen ; //components長度//ADD Date : 2003-10-27 15:44:38 by ABING unsigned char noUseSmartPunc; unsigned char noFirstKeyAssoc;//2.0//保存各個音節的對應syllables數組頭地址的偏移 unsigned char syllablesPointer[EB_SYLLABLE_MAX_SELECT];//保存各個候選字詞的信息,主要是對應輸入串的長度,以及字詞的長度 CandInfo cis[EB_CANDIDATES_MAX_LEN];//以下部分內容為EBHelper函數使用,主要是為了方便輸入法的集成//當前的整個輸入串 char fullInputString[EB_INPUT_MAX_LEN + 1] ; //已輸入串[0~9,*]#if EBD_USE_DESIRE_COUNT > 0 unsigned char candidateDesireCount;//指定輸出候選的個數,candidateLen是指候選的漢字的個數#endif //selInfo數組中有效的單元的數據 unsigned char selCount; //當前的輸出字符串 unsigned short fullOutputString[EB_INPUT_MAX_LEN + 1] ; //輸出串[]//當前的各個候選字詞的選擇信息 CandSelInfo selInfo[EB_INPUT_MAX_LEN];} EBInputStruct, *pEBInputStruct ;typedef const EBInputStruct * pcEBInputStruct;//獲取指定下標的音節#define EBIS_GET_SYLLABLE(eb, i) ((eb)->syllables + (eb)->syllablesPointer[i])//獲取當前選擇的音節#define EBIS_GET_SEL_SYLLABLE(eb) \ (((eb)->syllableIndex == EB_NULL) ? NULL : EBIS_GET_SYLLABLE((eb), (eb)->syllableIndex - 1))//(僅用于繁體版)獲取指定下標的注音#define EBIS_GET_SYLLABLE_BPMF(eb, i) ((const unsigned short *)EBIS_GET_SYLLABLE(eb, i))//(僅用于繁體版)獲取當前選擇的注音#define EBIS_GET_SEL_SYLLABLE_BPMF(eb) ((const unsigned short *)EBIS_GET_SEL_SYLLABLE(eb))//Copy一個候選字到一個unsigned short的數組中,target為該數組。#define EBIS_COPY_CANDIDATE(target, eb, i) \ memcpy((target), ((eb)->candidates + (eb)->cis[i].start), (eb)->cis[i].len * sizeof(short));\ (target)[(eb)->cis[i].len] = 0; //INIT ...#define EBISInit(pEBIS) \ memset((void *)(pEBIS), EB_NULL, sizeof(EBInputStruct)) ;#define EBCleanCandidates(pEBIS) \ (pEBIS)->candidateLen = 0 ;\ memset((void *)(pEBIS)->candidates, EB_NULL, sizeof((pEBIS)->candidates)) ;#define EBCleanSyllables(pEBIS) \ (pEBIS)->syllableLen = 0 ; \ (pEBIS)->syllableIndex = 0 ; \ memset((void *)(pEBIS)->syllables, EB_NULL, sizeof((pEBIS)->syllables)) ;#define EBCleanComponents(pEBIS) \ (pEBIS)->componentLen = 0 ;\ memset((void *)(pEBIS)->components, EB_NULL, sizeof((pEBIS)->components)) ;//Macro : EBIsValidInputMethod : Is valid Input Method ?#define EBIsValidInputMethod(im) \ ((im) >= EB_INPUT_METHOD_PINYIN && \ (im) <= EB_INPUT_METHOD_MAX)//Macro : EBHaveInput : Have Input ?#define EBHaveInput(pEBIS) \ ((pEBIS)->inputStringLen > 0 && \ (pEBIS)->inputStringLen <= EB_INPUT_MAX_LEN)//Macro : EBIsValidTone : Is valid Tone ?#define EBIsValidTone(pEBIS) \ (((pEBIS)->tone >= EB_TONE_1 && \ (pEBIS)->tone <= EB_TONE_6) || \ (pEBIS)->tone == EB_NULL)//Macro : EBCanSelectSyllables : can select Syllables ?#define EBCanSelectSyllable(pEBIS) \ ((pEBIS)->syllableLen > 0 && \ (pEBIS)->syllableLen <= EB_SYLLABLE_MAX_SELECT)//Macro : EBHaveComponents : have Components ?#define EBHaveComponents(pEBIS) \ ((pEBIS)->componentLen > 0 && \ (pEBIS)->componentLen <= EB_COMPONENT_MAX_LEN)//Macro : EBHaveCandidates : have Candidates ?#define EBHaveCandidates(pEBIS) \ ((pEBIS)->candidateLen > 0 && \ (pEBIS)->candidateLen <= EB_CANDIDATES_MAX_LEN)//Macro : EBIsValidDesireLen : Is valid candidate desire len ?#define EBIsValidDesireLen(pEBIS) \ ((pEBIS)->candidateDesireLen > 0 && \ (pEBIS)->candidateDesireLen <= EB_CANDIDATES_MAX_LEN)//Macro : EBIsValidSyllableIndex : Is valid syllableIndex ?#define EBIsValidSyllableIndex(pEBIS) \ ((pEBIS)->syllableIndex > 0 && \ (pEBIS)->syllableIndex <= (pEBIS)->syllableLen)#endif //__EB_STRUCTURES_H_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -