型定義 | |
typedef MPlist *(*) | MTextPropSerializeFunc (void *val) |
シリアライザ関数の型宣言. | |
typedef void *(*) | MTextPropDeserializeFunc (MPlist *plist) |
デシリアライザ関数の型宣言. | |
typedef MTextProperty | MTextProperty |
テキストプロパティの型宣言 . | |
列挙型 | |
enum | MTextPropertyControl { MTEXTPROP_FRONT_STICKY = 0x01, MTEXTPROP_REAR_STICKY = 0x02, MTEXTPROP_VOLATILE_WEAK = 0x04, MTEXTPROP_VOLATILE_STRONG = 0x08, MTEXTPROP_NO_MERGE = 0x10, MTEXTPROP_CONTROL_MAX = 0x1F } |
テキストプロパティを制御するフラグビット. [詳細] | |
関数 | |
void * | mtext_get_prop (MText *mt, int pos, MSymbol key) |
テキストプロパティの一番上の値を得る. | |
int | mtext_get_prop_values (MText *mt, int pos, MSymbol key, void **values, int num) |
テキストプロパティの値を複数個得る. | |
int | mtext_get_prop_keys (MText *mt, int pos, MSymbol **keys) |
M-text の指定した位置のテキストプロパティのキーのリストを得る. | |
int | mtext_put_prop (MText *mt, int from, int to, MSymbol key, void *val) |
テキストプロパティを設定する. | |
int | mtext_put_prop_values (MText *mt, int from, int to, MSymbol key, void **values, int num) |
同じキーのテキストプロパティを複数設定する. | |
int | mtext_push_prop (MText *mt, int from, int to, MSymbol key, void *val) |
テキストプロパティをプッシュする. | |
int | mtext_pop_prop (MText *mt, int from, int to, MSymbol key) |
テキストプロパティをポップする. | |
int | mtext_prop_range (MText *mt, MSymbol key, int pos, int *from, int *to, int deeper) |
テキストプロパティが同じ値をとる範囲を調べる. | |
MTextProperty * | mtext_property (MSymbol key, void *val, int control_bits) |
テキストプロパティを生成する. | |
MText * | mtext_property_mtext (MTextProperty *prop) |
あるテキストプロパティを持つ M-text を返す. | |
MSymbol | mtext_property_key (MTextProperty *prop) |
テキストプロパティのキーを返す. | |
void * | mtext_property_value (MTextProperty *prop) |
テキストプロパティの値を返す. | |
int | mtext_property_start (MTextProperty *prop) |
テキストプロパティの開始位置を返す. | |
int | mtext_property_end (MTextProperty *prop) |
テキストプロパティの終了位置を返す. | |
MTextProperty * | mtext_get_property (MText *mt, int pos, MSymbol key) |
一番上のテキストプロパティを得る. | |
int | mtext_get_properties (MText *mt, int pos, MSymbol key, MTextProperty **props, int num) |
複数のテキストプロパティを得る. | |
int | mtext_attach_property (MText *mt, int from, int to, MTextProperty *prop) |
M-textにテキストプロパティを付加する. | |
int | mtext_detach_property (MTextProperty *prop) |
M-text からテキストプロパティを分離する. | |
int | mtext_push_property (MText *mt, int from, int to, MTextProperty *prop) |
M-text にテキストプロパティをプッシュする. | |
MText * | mtext_serialize (MText *mt, int from, int to, MPlist *property_list) |
M-text 中のテキストプロパティをシリアライズする. | |
MText * | mtext_deserialize (MText *mt) |
M-text 中のテキストプロパティをデシリアライズする. | |
変数 | |
MSymbol | Mtext_prop_serializer |
シリアライザ関数を指定するシンボル. | |
MSymbol | Mtext_prop_deserializer |
デシリアライザ関数を指定するシンボル. |
テキストプロパティは キー と 値 からなる。キーはシンボルであ り、値は (void *)
型にキャストできるものなら何でもよい。 他のタイプのプロパティと異なり、一つのテキストプロパティが複数の値 を持つことが許される。「キーが K であるテキストプロパティ」のこと を簡単に「K プロパティ」と呼ぶことがある。
typedef MPlist*(*) MTextPropSerializeFunc(void *val) |
シリアライザ関数の型である。 あるシンボルのプロパティのキーが Mtext_prop_serializer
であるとき、 値はこの型でなくてはならない。
typedef void*(*) MTextPropDeserializeFunc(MPlist *plist) |
デシリアライザ関数の型である。 あるシンボルのプロパティのキーが Msymbol_prop_deserializer
であるとき、 値はこの型でなくてはならない。
typedef struct MTextProperty MTextProperty |
MTextProperty は テキストプロパティ オブジェクトの型である。 内部構造はアプリケーションプログラムからは見えない。
enum MTextPropertyControl |
関数 mtext_property() は以下のフラグビットの論理 OR を引数としてとることができる。 フラグビットは生成されたテキストプロパティの振舞いを制御する。 詳細は各フラグビットの説明を参照。
関数 mtext_get_prop() は、M-text mt 内の位置 pos にある文字のテ キストプロパティのうち、キーが key であるものを探す。
NULL
を返す。NULL
を返し、外部変 数 merror_code にエラーコードを設定する。
NULL
が返された場合には二つの可能性がある。NULL
である。
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_get_prop_values() は、M-text mt 内で pos という位置 にある文字のプロパティのうち、キーが key であるものを探す。もしそ のようなプロパティが見つかれば、それが持つ値 (複数可) を values の指すメモリ領域に格納する。num は格納する値の数の上限である。
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_get_prop_keys() は、M-text mt 内で pos の位置にある すべてのテキストプロパティのキーを要素とする配列を作り、その配列の アドレスを *keys に設定する。この配列のために確保されたメモリを解 放するのはユーザの責任である。
MERROR_RANGE
関数 mtext_put_prop() は、M-text mt の from (含まれる)から to (含まれない)の範囲の文字に、キーが key で値が val であるよ うなテキストプロパティを設定する。この関数によって
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP: <------------------ OLD_VAL -------------------->
は次のようになる。
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP: <-- OLD_VAL-><-------- VAL -------><-- OLD_VAL-->
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_put_prop_values() は、M-Text mt のfrom (含まれる) から to (含まれない)の範囲の文字に、テキストプロパティを設定す る。テキストプロパティのキーは key によって、値(複数可)は values によって指定される。num は設定される値の個数である。
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_push_prop() は、キーが key で値が val であるテキスト プロパティを、M-text mt 中の from (含まれる)から to (含まれな い)の範囲の文字にプッシュする。この関数によって
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------ OLD_VAL -------------------->
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------- OLD_VAL -------------------> PROP : <-------- VAL ------->
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_pop_prop() は、キーが key であるテキストプロパティの うち一番上のものを、M-text mt の from (含まれる)から to(含ま れない)の範囲の文字から取り除く。
指定範囲の文字がそのようなプロパティを持たないならば、この関数は何 もしない。この関数によって、
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <------------------ OLD_VAL -------------------->
FROM TO M-text: |<------------|-------- MT ---------|------------>| PROP : <--OLD_VAL-->| |<--OLD_VAL-->|
MERROR_RANGE
, MERROR_SYMBOL
関数 mtext_prop_range() は、指定したテキストプロパティの値が同じ である連続した文字の範囲を調べる。まず M-text mt の pos の位置に ある文字のプロパティのうち、キー key で指定されたもの値を見つけ る。そして前後の文字も key のプロパティの値が同じであるかどうかを 調べる。見つけた範囲の最初と最後を、それぞれ from と to にポイン トされる変数に保存する。from に保存される文字の位置は見つけた範囲 に含まれるが、to は含まれない。(to の前で同じ値をとる範囲は終わ る。)この範囲指定法は、関数 mtext_put_prop() などと共通である。
deeper が 0 でなければ、key というキーを持つプロパティのうち一番 上のものだけでなく、スタック中のすべてのものが比較される。
from が NULL
ならば、範囲の始まりは探索しない。to が NULL
ならば、範囲の終りは探索しない。
MERROR_RANGE
, MERROR_SYMBOL
MTextProperty* mtext_property | ( | MSymbol | key, | |
void * | val, | |||
int | control_bits | |||
) |
関数 mtext_property() は key をキー、val を値とする新しく割り当 てられたテキストプロパティを返す。生成したテキストプロパティはいか なる M-text にも付加されていない、すなわち分離して (detached) いる。
control_bits は 0 であるか enum
MTextPropertyControl
の論理 OR でなくてはならない。
MText* mtext_property_mtext | ( | MTextProperty * | prop | ) |
関数 mtext_property_mtext() は、テキストプロパティprop が付加さ れている M-text を返す。その時点で prop が分離していれば NULL を 返す。
MSymbol mtext_property_key | ( | MTextProperty * | prop | ) |
関数 mtext_property_key() は、テキストプロパティ prop のキー(シ ンボル)を返す。
void* mtext_property_value | ( | MTextProperty * | prop | ) |
関数 mtext_property_value() は、テキストプロパティ prop の値を返 す。
int mtext_property_start | ( | MTextProperty * | prop | ) |
関数 mtext_property_start() は、テキストプロパティ prop の開始位 置を返す。開始位置とは M-text 中で prop が始まる文字位置である。 prop が分離されていれば、-1 を返す。
int mtext_property_end | ( | MTextProperty * | prop | ) |
関数 mtext_property_end() は、テキストプロパティ prop の終了位置 を返す。終了位置とは M-text 中で prop が終る文字位置である。prop が分離されていれば、-1 を返す。
MTextProperty* mtext_get_property | ( | MText * | mt, | |
int | pos, | |||
MSymbol | key | |||
) |
関数 mtext_get_property() は M-text mt の位置 pos の文字がキー が key であるテキストプロパティを持つかどうかを調べる。
NULL
を返す。NULL
を返し、外 部変数 merror_code にエラーコードを設定する。
int mtext_get_properties | ( | MText * | mt, | |
int | pos, | |||
MSymbol | key, | |||
MTextProperty ** | props, | |||
int | num | |||
) |
関数 mtext_get_properties() は M-text mt の位置 pos の文字がキー が key であるテキストプロパティを持つかどうかを調べる。そのような プロパティがみつかれば、props が指すメモリ領域に保存する。num は 保存されるプロパティの数の上限である。
int mtext_attach_property | ( | MText * | mt, | |
int | from, | |||
int | to, | |||
MTextProperty * | prop | |||
) |
関数 mtext_attach_property() は、M-text mt の from から to ま での領域にテキストプロパティ prop を付加する。もし prop が既に M-text に付加されていれば、mt に付加する前に分離される。
int mtext_detach_property | ( | MTextProperty * | prop | ) |
int mtext_push_property | ( | MText * | mt, | |
int | from, | |||
int | to, | |||
MTextProperty * | prop | |||
) |
関数 mtext_push_property() は、テキストプロパティ prop を、 M-text mt 中の from (含まれる)から to (含まれない)の範囲の 文字にプッシュする。
関数 mtext_serialize() は M-text mt の from から to までのテキ ストをシリアライズする。シリアライズした結果は XML 形式の M-text で ある。 property_list はシリアライズされるテキストプロパティを限定 する。対象となるテキストプロパティは、そのキーが
生成される XML の DTD は以下の通り:
<!DOCTYPE mtext [ <!ELEMENT mtext (property*,body+)> <!ELEMENT property EMPTY> <!ELEMENT body (#PCDATA)> <!ATTLIST property key CDATA #REQUIRED> <!ATTLIST property value CDATA #REQUIRED> <!ATTLIST property from CDATA #REQUIRED> <!ATTLIST property to CDATA #REQUIRED> <!ATTLIST property control CDATA #REQUIRED> ]>
この関数は libxml2 ライブラリに依存する。m17n ライブラリがlibxml2 無しに設定されている場合、この関数は常に失敗する。
NULL
を返して外部変数merror_code にエラーコード を設定する。関数 mtext_deserialize() は M-text mt をデシリアライズする。mt は次の DTD を持つ XML でなくてはならない。
<!DOCTYPE mtext [ <!ELEMENT mtext (property*,body+)> <!ELEMENT property EMPTY> <!ELEMENT body (#PCDATA)> <!ATTLIST property key CDATA #REQUIRED> <!ATTLIST property value CDATA #REQUIRED> <!ATTLIST property from CDATA #REQUIRED> <!ATTLIST property to CDATA #REQUIRED> <!ATTLIST property control CDATA #REQUIRED> ]>
この関数は libxml2 ライブラリに依存する。m17n ライブラリがlibxml2 無しに設定されている場合、この関数は常に失敗する。
NULL
を返して外部変数 merror_code にエラー コードを設定する。
テキストプロパティをシリアライズするためには、そのテキストプロパ ティ用のシリアライザ関数を与えなくてはならない。具体的には、 Mtext_prop_serializer をキーとし、適切なシリアライズ関数へのポイ ンタを値とするシンボルプロパティを指定する。
テキストプロパティをデシリアライズするためには、そのテキストプロ パティ用のデシリアライザ関数を与えなくてはならない。具体的には、 Mtext_prop_deserializer をキーとし、適切なデシリアライズ関数への ポインタを値とするシンボルプロパティを指定する。