亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? scim_pinyin.h

?? 嵌入式Linux上的拼音輸入法
?? H
?? 第 1 頁 / 共 2 頁
字號:
/** @file scim_pinyin.h
 *  @brief the definitions of pinyin related classes and structs.
 */

/*
 * Smart Chinese Input Method
 * 
 * Copyright (c) 2002 James Su <suzhe@turbolinux.com.cn>
 *
 * $Id: scim_pinyin.h,v 1.2 2004/07/17 07:05:32 Lu Mu Exp $
 *
 */

#if !defined (__SCIM_PINYIN_H)
#define __SCIM_PINYIN_H
//#include "config.h"

#if defined (HAVE_HASH_MAP)
#include <hash_map>
#elif defined (HAVE_EXT_HASH_MAP)
#include <ext/hash_map>
#else
#include <map>
#endif

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

#ifndef X86
#include <algo.h>
#endif

#include <stdint.h>
#include <linux/types.h>
/*
#ifdef __STDC_ISO_10646__
    typedef wchar_t ucs4_t;
#else
    typedef uint32 ucs4_t;
#endif
*/
typedef unsigned short ucs4_t;

typedef std::basic_string<char> String;
typedef std::basic_string<ucs4_t> WideString;

typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;


#define SCIM_PINYIN_KEY_MAXLEN	7
#define SCIM_MAX_CHAR_FREQUENCY (~0)

//using namespace scim;
/*
class PinyinError: public Exception {
public:
	PinyinError (const String& what_arg)
		: Exception (String("Pinyin: ") + what_arg) { }
};
*/

// Predefinition of some classes and structs
class PinyinKey;
class PinyinEntry;
class PinyinTable;
class PinyinValidator;

class PinyinKeyLessThan;
class PinyinKeyEqualTo;

class PinyinKeyExactLessThan;
class PinyinKeyExactEqualTo;

struct PinyinParsedKey;
struct PinyinToken;
struct PinyinCustomSettings;

typedef std::vector<ucs4_t>           CharVector;
typedef std::vector<PinyinKey>        PinyinKeyVector;
typedef std::vector<PinyinParsedKey>  PinyinParsedKeyVector;

typedef std::pair<ucs4_t, uint32>     CharFrequencyPair;

extern const PinyinToken scim_pinyin_initials [];
extern const PinyinToken scim_pinyin_finals [];

extern const PinyinCustomSettings scim_default_custom_settings;
extern const PinyinValidator scim_default_pinyin_validator;

/**
 * enums of pinyin initial element.
 *
 * A pinyin key can be divided into three tokens:
 * Initial -- such as B P M F D T N L  etc.
 * Final   -- such as A O E I U V etc.
 * Tone    -- can be 1, 2, 3, 4 and 5.
 */
enum PinyinInitial
{
	SCIM_PINYIN_ZeroInitial = 0,	/**< zero initial. indicates invaild initial */
	SCIM_PINYIN_Bo  = 1,
	SCIM_PINYIN_Ci  = 2,
	SCIM_PINYIN_Chi = 3,
	SCIM_PINYIN_De  = 4,
	SCIM_PINYIN_Fo  = 5,
	SCIM_PINYIN_Ge  = 6,
	SCIM_PINYIN_He  = 7,
	SCIM_PINYIN_Ji  = 8,
	SCIM_PINYIN_Ke  = 9,
	SCIM_PINYIN_Le  =10,
	SCIM_PINYIN_Mo  =11,
	SCIM_PINYIN_Ne  =12,
	SCIM_PINYIN_Po  =13,
	SCIM_PINYIN_Qi  =14,
	SCIM_PINYIN_Ri  =15,
	SCIM_PINYIN_Si  =16,
	SCIM_PINYIN_Shi =17,
	SCIM_PINYIN_Te  =18,
	SCIM_PINYIN_Wo  =19,
	SCIM_PINYIN_Xi  =20,
	SCIM_PINYIN_Yi  =21,
	SCIM_PINYIN_Zi  =22,
	SCIM_PINYIN_Zhi =23,
	SCIM_PINYIN_LastInitial = SCIM_PINYIN_Zhi,	/**< the last initial */
	SCIM_PINYIN_InitialNumber = SCIM_PINYIN_LastInitial + 1
};

/**
 * enums of pinyin final element.
 */
enum PinyinFinal
{
	SCIM_PINYIN_ZeroFinal = 0,	/**< zero final. indicates invalid final */
	SCIM_PINYIN_A    = 1,
	SCIM_PINYIN_Ai   = 2,
	SCIM_PINYIN_An   = 3,
	SCIM_PINYIN_Ang  = 4,
	SCIM_PINYIN_Ao   = 5,
	SCIM_PINYIN_E    = 6,
	SCIM_PINYIN_Ei   = 7,
	SCIM_PINYIN_En   = 8,
	SCIM_PINYIN_Eng  = 9,
	SCIM_PINYIN_Er   =10,
	SCIM_PINYIN_I    =11,
	SCIM_PINYIN_Ia   =12,
	SCIM_PINYIN_Ian  =13,
	SCIM_PINYIN_Iang =14,
	SCIM_PINYIN_Iao  =15,
	SCIM_PINYIN_Ie   =16,
	SCIM_PINYIN_In   =17,
	SCIM_PINYIN_Ing  =18,
	SCIM_PINYIN_Iong =19,
	SCIM_PINYIN_Iou  =20,
	SCIM_PINYIN_Iu   =21,
	SCIM_PINYIN_Ng   =22,
	SCIM_PINYIN_O    =23,
	SCIM_PINYIN_Ong  =24,
	SCIM_PINYIN_Ou   =25,
	SCIM_PINYIN_U    =26,
	SCIM_PINYIN_Ua   =27,
	SCIM_PINYIN_Uai  =28,
	SCIM_PINYIN_Uan  =29,
	SCIM_PINYIN_Uang =30,
	SCIM_PINYIN_Ue   =31,
	SCIM_PINYIN_Uei  =32,
	SCIM_PINYIN_Uen  =33,
	SCIM_PINYIN_Ueng =34,
	SCIM_PINYIN_Ui   =35,
	SCIM_PINYIN_Un   =36,
	SCIM_PINYIN_Uo   =37,
	SCIM_PINYIN_V    =38,
	SCIM_PINYIN_Van  =39,
	SCIM_PINYIN_Ve   =40,
	SCIM_PINYIN_Vn   =41,
	SCIM_PINYIN_LastFinal = SCIM_PINYIN_Vn,	/**< the last final */
	SCIM_PINYIN_FinalNumber = SCIM_PINYIN_LastFinal + 1
};

/**
 * enums of pinyin tone element.
 */
enum PinyinTone
{
	SCIM_PINYIN_ZeroTone = 0,	/**< zero tone. this will be matched with all other tones. */
	SCIM_PINYIN_First  = 1,
	SCIM_PINYIN_Second = 2,
	SCIM_PINYIN_Third  = 3,
	SCIM_PINYIN_Fourth = 4,
	SCIM_PINYIN_Fifth  = 5,
	SCIM_PINYIN_LastTone = SCIM_PINYIN_Fifth, /**< the last tone */
	SCIM_PINYIN_ToneNumber = SCIM_PINYIN_LastTone + 1
};

/**
 * struct of pinyin token.
 *
 * this struct store the informations of a pinyin token
 * (an initial or final)
 */
struct PinyinToken
{
	char str[8];	/**< ASCII name of the token. */
       	ucs4_t wstr[4];	/**< Chinese name in unicode. */
	int len;		/**< length of ASCII name. */
       	int wlen;		/**< length of Chinese name. */
};

/**
 * Pinyin key class.
 * 
 * A pinyin key is a composed element of an initial, a final and a tone,
 * which represents one or several Chinese ideographs
 */
class PinyinKey
{
	unsigned int m_initial : 6;		/**< pinyin initial */
	unsigned int m_final : 6;		/**< pinyin final */
	unsigned int m_tone : 4;		/**< pinyin tone */
	/*
	friend class PinyinKeyLessThan;
	friend class PinyinKeyEqualTo;
	*/

	friend class PinyinKeyExactLessThan;
	friend class PinyinKeyExactEqualTo;

public:
	/**
	 * constructor.
	 *
	 * the default constructor of class PinyinKey.
	 */
	PinyinKey (PinyinInitial initial = SCIM_PINYIN_ZeroInitial,
			   PinyinFinal final     = SCIM_PINYIN_ZeroFinal,
			   PinyinTone tone       = SCIM_PINYIN_ZeroTone) {
		m_initial = initial;
		m_final = final;
		m_tone = tone;
	}

	/**
	 * constructor.
	 *
	 * construct a PinyinKey object from a key string, with
	 * specified validator.
	 *
	 * @sa PinyinValidator
	 */
	PinyinKey (const PinyinValidator &validator,
			   const char *key) {
		set_key (validator, key);
	}

	/**
	 * read the pinyin key value from a key string.
	 * 
	 * @param validator a PinyinValidator object to validate the key.
	 * @param key a ASCII string including one or more pinyin keys.
	 * @return the number of characters used by this pinyin key.
	 */ 
	int set_key (const PinyinValidator &validator,
				 const char *key,
				 int keylen = -1);

	/**
	 * set the pinyin key value to initial, final and tone.
	 */
	void set_key (PinyinInitial initial = SCIM_PINYIN_ZeroInitial,
				  PinyinFinal final     = SCIM_PINYIN_ZeroFinal,
				  PinyinTone tone       = SCIM_PINYIN_ZeroTone) {
		m_initial = initial;
		m_final = final;
		m_tone = tone;
	}

	void set_initial (PinyinInitial initial = SCIM_PINYIN_ZeroInitial) {
		m_initial = initial;
	}

	void set_final (PinyinFinal final = SCIM_PINYIN_ZeroFinal) {
		m_final = final;
	}

	void set_tone (PinyinTone tone = SCIM_PINYIN_ZeroTone) {
		m_tone = tone;
	}

	/**
	 * get pinyin initial of this key.
	 */
	PinyinInitial get_initial () const {
		return static_cast<PinyinInitial>(m_initial);
	}

	/**
	 * get pinyin final of this key.
	 */
	PinyinFinal get_final () const {
		return static_cast<PinyinFinal>(m_final);
	}

	/**
	 * get pinyin tone of this key.
	 */
	PinyinTone get_tone () const {
		return static_cast<PinyinTone>(m_tone);
	}

	/**
	 * get the ASCII name of pinyin initial of this key.
	 */
	const char* get_initial_string () const {
		return scim_pinyin_initials [m_initial].str;
	}

	/**
	 * get the Chinese name of pinyin initial of this key.
	const ucs4_t* get_initial_wide_string () const {
		return scim_pinyin_initials [m_initial].wstr;
	}
	 */

	/**
	 * get the ASCII name of pinyin final of this key.
	 */
	const char* get_final_string () const {
		return scim_pinyin_finals [m_final].str;
	}

	/**
	 * get the Chinese name of pinyin final of this key.
	const ucs4_t* get_final_wide_string () const {
		return scim_pinyin_finals [m_final].wstr;
	}
	 */

	/**
	 * get the ASCII name of this key.
	 */
	String get_key_string () const;

	/**
	 * get the Chinese name of this key.
	WideString get_key_wide_string () const;
	 */

	/**
	 * set the pinyin key to zero (invalid) key.
	 */
	bool zero() const {
		return  m_initial == SCIM_PINYIN_ZeroInitial &&
				m_final == SCIM_PINYIN_ZeroFinal;
	}

	/**
	 * output the pinyin key in text format.
	 * 
	 * @param os the ostream object to output to.
	 */
	std::ostream& output_text (std::ostream &os) const;

	/**
	 * output the pinyin key in binary format.
	 * 
	 * @param os the ostream object to output to.
	std::ostream& output_binary (std::ostream &os) const;
	 */

	/**
	 * input the pinyin key in text format.
	 *
	 * @param validator the PinyinValidator object to validate the key.
	 * @paam is the istream object to input from.
	 */
	std::istream& input_text (const PinyinValidator &validator, std::istream &is);

	/**
	 * input the pinyin key in binary format.
	 *
	 * @param validator the PinyinValidator object to validate the key.
	 * @paam is the istream object to input from.
	std::istream& input_binary (const PinyinValidator &validator, std::istream &is);
	 */

	bool operator == (PinyinKey rhs) const {
		return m_initial == rhs.m_initial && m_final == rhs.m_final && m_tone == rhs.m_tone;
	}

	bool operator != (PinyinKey rhs) const {
		return ! (*this == rhs);
	}

private:

	/**
	 * apply additional pinyin rules to the initial, final pair.
	 *
	 * for example:
	 *
	 *  SCIM_PINYIN_ZeroInitial, SCIM_PINYIN_I  ==> SCIM_PINYIN_Yi, SCIM_PINYIN_I
	 *  SCIM_PINYIN_Ne,          SCIM_PINYIN_Ve ==> SCIM_PINYIN_Ne, SCIM_PINYIN_Ue
	 *
	 *  etc.
	 */
	void apply_additional_rules (PinyinInitial &initial,
								 PinyinFinal &final);

	/**
	 * translate an ASCII string into pinyin initial.
	 *
	 * @param initial a PinyinInitial object reference to store the result.
	 * @param key the ASCII key string.
	 * @param keylen the length of the key string.
	 * @return the number of chars actually translated.
	 */
	int parse_initial (PinyinInitial &initial,
					   const char *key,
					   int keylen);

	/**
	 * translate an ASCII string into pinyin final.
	 *
	 * @param final a PinyinFinal object reference to store the result.
	 * @param key the ASCII key string.
	 * @param keylen the length of the key string.
	 * @return the number of chars actually translated.
	 */
	int parse_final (PinyinFinal &final,
					 const char *key,
					 int keylen);
	
	/**
	 * translate an ASCII string into pinyin tone.
	 *
	 * @param tone a PinyinTone object reference to store the result.
	 * @param key the ASCII key string.
	 * @return the number of chars actually translated.
	 */
	int parse_tone (PinyinTone &tone,
				    const char *key);

	/**
	 * translate an ASCII string into initial, final and tone.
	 *
	 * @param initial store the result of pinyin initial.
	 * @param final store the result of pinyin final.
	 * @param tone store the result of pinyin tone.
	 * @param key the ASCII key string.
	 * @param keylen the length of key.
	 * @return the number of chars actually translated.
	 */
	int parse_key (PinyinInitial &initial,
				   PinyinFinal &final,
				   PinyinTone &tone,
				   const char *key,
				   int keylen);

	void extract_from_bytes (unsigned char byte0,
							 unsigned char byte1) {
		m_initial = (byte0 & 0x3F) % (SCIM_PINYIN_LastInitial+1);
		m_final = ((byte0>>6) | ((byte1 & 0xF)<<2)) % (SCIM_PINYIN_LastFinal+1);
		m_tone = (byte1>>4) % (SCIM_PINYIN_LastTone+1);
	}

	void combine_to_bytes (unsigned char *bytes) const {
		bytes[0] =  (static_cast<unsigned char>(m_initial)) |
					(static_cast<unsigned char>(m_final) << 6);
		bytes[1] =  (static_cast<unsigned char>(m_final) >> 2) |
					(static_cast<unsigned char>(m_tone) << 4);
	}

public:
	/**
	 * translate an ASCII key string into a set of valid PinyinKey objects.
	 *
	 * @param validator to validate the result pinyin keys.
	 * @param vec a PinyinParsedKey vector to store the result keys.
	 * @param key a zero ending ASCII string.
	 * @return the number of chars actually parsed.
	 */
	static int parse_pinyin_key (const PinyinValidator &validator,
								 PinyinParsedKeyVector &vec,
								 const char *key);

	static int parse_pinyin_key (const PinyinValidator &validator,
								 PinyinKeyVector &vec,
								 const char *key);
};

/**
 * Validator of PinyinKey object.
 *
 * This class is used to validate a PinyinKey object.
 */
const int PinyinValidatorBitmapSize = (SCIM_PINYIN_InitialNumber *
						SCIM_PINYIN_FinalNumber *
						SCIM_PINYIN_ToneNumber) / 8 + 1;
class PinyinValidator
{
	/**
	 * pinyin custom settings.
	 *
	 * different custom settings will lead to defferent validators.
	 */
	//PinyinCustomSettings m_custom;

	char m_bitmap [PinyinValidatorBitmapSize];

public:
	PinyinValidator (/*const PinyinCustomSettings &custom,*/
					 const PinyinTable *table = NULL);

	/**
	 * initialize the validator with specified custom settings
	 * and PinyinTable.
	 */
	void initialize (/*const PinyinCustomSettings &custom,*/
					 const PinyinTable *table = NULL);

	/**
	 * overloaded operator () function to validate a pinyin key.
	 *
	 * @param key the key to be validated.
	 * @return true = the key is valid, otherwise it's invalid.
	 */
	bool operator () (PinyinKey key) const;
};

/**
 * a binary functional class to do less than comparison
 * between two pinyin keys.
 *
 * the user custom settings will be taken account into the comparison.
class PinyinKeyLessThan
	: public std::binary_function <PinyinKey, PinyinKey, bool>
{
	PinyinCustomSettings m_custom;
public:
	PinyinKeyLessThan (const PinyinCustomSettings &custom)
		: m_custom (custom) {}

	bool operator () (PinyinKey lhs,
					  PinyinKey rhs) const;
};
 */

/**
 * a binary functional class to do equal to comparison
 * between two pinyin keys.
class PinyinKeyEqualTo
	: public std::binary_function <PinyinKey, PinyinKey, bool>
{
	PinyinCustomSettings m_custom;
public:
	PinyinKeyEqualTo (const PinyinCustomSettings &custom)
		: m_custom (custom) {}

	bool operator () (PinyinKey lhs,
					  PinyinKey rhs) const;
};
 */

/**
 * a binary functional class to do bitwise less than comparison

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看国产精品网站| 91亚洲永久精品| 成人av资源站| 欧美日韩精品电影| 久久嫩草精品久久久久| 一区二区三区在线视频播放| 日韩高清在线电影| 丁香一区二区三区| 欧美人与z0zoxxxx视频| 国产女主播一区| 一区二区在线观看不卡| 成人免费视频视频| 4438成人网| 亚洲欧洲日韩一区二区三区| 国产中文一区二区三区| 欧美在线观看禁18| 国产欧美一区在线| 日韩一级成人av| 麻豆精品一区二区综合av| 亚洲天堂免费看| 欧美午夜精品免费| 亚洲第一av色| 色综合一区二区| 国产精品乱子久久久久| 国产一区二区福利视频| 欧美国产乱子伦| 91精品欧美一区二区三区综合在| 久久99最新地址| 午夜精品久久久久久| 欧美性一区二区| 午夜精品视频一区| 99热在这里有精品免费| 亚洲高清免费观看| 久久精品综合网| 97精品电影院| 欧美日韩三级视频| 精品久久久久久亚洲综合网| 国产精品视频一区二区三区不卡| 日韩国产在线一| 精品精品国产高清a毛片牛牛| 亚洲欧美日韩国产综合在线| 91精品国产高清一区二区三区蜜臀| 国精产品一区一区三区mba视频| 国产精品久久久久一区二区三区共 | 日韩视频在线你懂得| 成人午夜精品在线| 欧美午夜不卡在线观看免费| 日韩精品资源二区在线| 日韩av电影天堂| 精品视频123区在线观看| 亚洲欧洲99久久| 91色婷婷久久久久合中文| 国产精品卡一卡二| 不卡的电影网站| 久久久久久免费网| av高清久久久| 亚洲资源中文字幕| 欧美影片第一页| 韩国av一区二区三区四区| 久久夜色精品国产噜噜av | 欧美日韩一区二区三区不卡| 亚洲成a人v欧美综合天堂下载 | 亚洲色图色小说| 色综合色综合色综合色综合色综合| 欧美日韩国产一区| 国产一区高清在线| 中文字幕一区二区三区不卡在线| 91视频观看免费| 国产女人aaa级久久久级| 成人av中文字幕| 中文字幕综合网| 精品婷婷伊人一区三区三| 一区二区三区欧美日| 欧美日韩视频不卡| 国产一区二区三区美女| 欧美一区二区三区四区久久| 韩国欧美国产1区| 中文字幕在线观看一区二区| 在线观看亚洲成人| 国产在线视视频有精品| 亚洲成人福利片| 亚洲天天做日日做天天谢日日欢| 日韩欧美第一区| 在线精品国精品国产尤物884a| 福利91精品一区二区三区| 丝袜美腿高跟呻吟高潮一区| 国产精品久久久久永久免费观看| 日韩欧美的一区二区| 欧美三级电影在线看| 波多野结衣亚洲| 国产精品99久| 免费av成人在线| 亚洲国产中文字幕| 亚洲老妇xxxxxx| 亚洲欧美怡红院| 中文字幕不卡一区| 精品成人a区在线观看| 欧美人牲a欧美精品| 在线观看视频一区| 色94色欧美sute亚洲线路一久| 国产伦理精品不卡| 日韩av电影天堂| 日本最新不卡在线| 午夜精品影院在线观看| 亚洲综合小说图片| 一区二区三区美女| 亚洲黄色小说网站| 亚洲卡通动漫在线| 亚洲欧美经典视频| 亚洲精品久久久久久国产精华液| 国产精品免费看片| 日韩码欧中文字| 亚洲人吸女人奶水| 亚洲黄色免费电影| 亚洲综合在线电影| 亚洲国产精品尤物yw在线观看| 亚洲一区二区三区小说| 一区二区三区成人在线视频| 亚洲影院久久精品| 日本亚洲天堂网| 久久国产精品99久久久久久老狼| 另类小说图片综合网| 黄一区二区三区| 成人影视亚洲图片在线| 色综合中文综合网| 日韩美女一区二区三区四区| 欧美一区二区女人| 精品久久久久一区二区国产| 久久久不卡网国产精品一区| 国产精品天美传媒沈樵| 一区二区在线免费| 日本不卡高清视频| 国产成人午夜视频| 色婷婷综合视频在线观看| 欧美无乱码久久久免费午夜一区| 日韩视频一区二区三区| 久久久久国色av免费看影院| 综合电影一区二区三区| 视频一区二区三区在线| 国产成人精品一区二| 色伊人久久综合中文字幕| 欧美麻豆精品久久久久久| 精品精品国产高清一毛片一天堂| 中文字幕欧美日韩一区| 天天av天天翘天天综合网 | 国产99一区视频免费| 91啪亚洲精品| 91精品婷婷国产综合久久性色| 欧美电影精品一区二区| 亚洲日本va午夜在线影院| 日本女优在线视频一区二区| 国产成都精品91一区二区三| 欧美天堂一区二区三区| 久久久美女艺术照精彩视频福利播放| 亚洲欧洲日产国码二区| 日本 国产 欧美色综合| 91一区二区三区在线播放| 日韩精品一区二区三区视频在线观看| 中文字幕一区日韩精品欧美| 免费在线看成人av| 欧美最新大片在线看| 国产欧美一二三区| 日本不卡中文字幕| 91蜜桃在线免费视频| 久久婷婷色综合| 亚洲一区二区三区中文字幕 | 久久精品72免费观看| 91麻豆高清视频| 久久久午夜电影| 日韩电影在线观看电影| 91色porny| 国产精品不卡视频| 激情综合色丁香一区二区| 欧美写真视频网站| 亚洲日本在线a| 国产91精品露脸国语对白| 91精品国产手机| 天堂久久一区二区三区| 色婷婷亚洲精品| 国产精品传媒视频| 国产电影一区在线| 精品国产一区二区三区四区四| 视频一区国产视频| 欧美日韩免费在线视频| 亚洲精品国产视频| 99这里只有精品| 国产精品美日韩| 东方aⅴ免费观看久久av| 国产亲近乱来精品视频| 国产精品自拍网站| 久久久高清一区二区三区| 激情久久五月天| 国产日韩精品一区二区三区在线| 国产一区二区成人久久免费影院| 91精品国产综合久久婷婷香蕉| 日韩一区精品视频| 日韩西西人体444www| 奇米777欧美一区二区| 日韩欧美高清dvd碟片| 激情另类小说区图片区视频区|