|
The mtext_get_prop() function searches the character at pos in M-text mt for the text property whose key is key.
- Return value:
- If a text property is found, mtext_get_prop() returns the value of the property. If the property has multiple values, it returns the topmost one. If no such property is found, it returns
NULL without changing the external variable merror_code.
If an error is detected, mtext_get_prop() returns NULL and assigns an error code to the external variable merror_code.
- Note:
- If
NULL is returned without an error, there are two possibilities:
- the character at pos does not have a property whose key is key, or
- the character does have such a property and its value is
NULL .
If you need to distinguish these two cases, use the mtext_get_prop_values() function instead.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_get_prop_values(), mtext_put_prop(), mtext_put_prop_values(), mtext_push_prop(), mtext_pop_prop(), mtext_prop_range()
|
int mtext_get_prop_values |
( |
MText * |
mt, |
|
|
int |
pos, |
|
|
MSymbol |
key, |
|
|
void ** |
values, |
|
|
int |
num | |
|
) |
| | |
|
The mtext_get_prop_values() function searches the character at pos in M-text mt for the property whose key is key. If such a property is found, its values are stored in the memory area pointed to by values. num limits the maximum number of stored values.
- Return value:
- If the operation was successful, mtext_get_prop_values() returns the number of actually stored values. If the character at pos does not have a property whose key is key, the return value is 0. If an error is detected, mtext_get_prop_values() returns -1 and assigns an error code to the external variable merror_code.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_get_prop(), mtext_put_prop(), mtext_put_prop_values(), mtext_push_prop(), mtext_pop_prop(), mtext_prop_range()
|
int mtext_put_prop |
( |
MText * |
mt, |
|
|
int |
from, |
|
|
int |
to, |
|
|
MSymbol |
key, |
|
|
void * |
val | |
|
) |
| | |
|
The mtext_put_prop() function sets a text property to the characters between from (inclusive) and to (exclusive) in M-text mt. key and val specify the key and the value of the text property. With this function,
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <-- OLD_VAL-><-------- VAL -------><-- OLD_VAL-->
- Return value:
- If the operation was successful, mtext_put_prop() returns 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_put_prop_values(), mtext_get_prop(), mtext_get_prop_values(), mtext_push_prop(), mtext_pop_prop(), mtext_prop_range()
|
int mtext_put_prop_values |
( |
MText * |
mt, |
|
|
int |
from, |
|
|
int |
to, |
|
|
MSymbol |
key, |
|
|
void ** |
values, |
|
|
int |
num | |
|
) |
| | |
|
The mtext_put_prop_values() function sets a text property to the characters between from (inclusive) and to (exclusive) in M-text mt. key and values specify the key and the values of the text property. num specifies the number of property values to be set.
- Return value:
- If the operation was successful, mtext_put_prop_values() returns 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_put_prop(), mtext_get_prop(), mtext_get_prop_values(), mtext_push_prop(), mtext_pop_prop(), mtext_prop_range()
|
int mtext_push_prop |
( |
MText * |
mt, |
|
|
int |
from, |
|
|
int |
to, |
|
|
MSymbol |
key, |
|
|
void * |
val | |
|
) |
| | |
|
The mtext_push_prop() function pushes a text property whose key is key and value is val to the characters between from (inclusive) and to (exclusive) in M-text mt. With this function,
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <------------------- OLD_VAL ------------------->
PROP : <-------- VAL ------->
- Return value:
- If the operation was successful, mtext_push_prop() returns 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_put_prop(), mtext_put_prop_values(), mtext_get_prop(), mtext_get_prop_values(), mtext_pop_prop(), mtext_prop_range()
|
int mtext_pop_prop |
( |
MText * |
mt, |
|
|
int |
from, |
|
|
int |
to, |
|
|
MSymbol |
key | |
|
) |
| | |
|
The mtext_pop_prop() function removes the topmost text property whose key is key from the characters between from (inclusive) and and to (exclusive) in mt.
This function does nothing if characters in the region have no such text property. With this function,
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <------------------ OLD_VAL -------------------->
becomes
FROM TO
M-text: |<------------|-------- MT ---------|------------>|
PROP : <--OLD_VAL-->| |<--OLD_VAL-->|
- Return value:
- If the operation was successful, mtext_pop_prop() return 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_put_prop(), mtext_put_prop_values(), mtext_get_prop(), mtext_get_prop_values(), mtext_push_prop(), mtext_prop_range()
|
int mtext_prop_range |
( |
MText * |
mt, |
|
|
MSymbol |
key, |
|
|
int |
pos, |
|
|
int * |
from, |
|
|
int * |
to, |
|
|
int |
deeper | |
|
) |
| | |
|
The mtext_prop_range() function investigates the extent where all characters have the same value for a text property. It first finds the value of the property specified by key of the character at pos in M-text mt. Then it checks if adjacent characters have the same value for the property key. The beginning and the end of the found range are stored to the variable pointed to by from and to. The character position stored in from is inclusive but that in to is exclusive; this fashion is compatible with the range specification in the mtext_put_prop() function, etc.
If deeper is not 0, not only the topmost but also all the stacked properties whose key is key are compared.
If from is NULL , the beginning of range is not searched for. If to is NULL , the end of range is not searched for.
- Return value:
If the operation was successful, mtext_prop_range() returns the number of values the property key has at pos. Otherwise it returns -1 and assigns an error code to the external variable merror_code .
- Errors:
MERROR_RANGE , MERROR_SYMBOL
- See Also:
- mtext_put_prop(), mtext_put_prop_values(), mtext_get_prop(), mtext_get_prop_values(), mtext_pop_prop(), mtext_push_prop()
|
|
The mtext_property() function returns a newly allocated text property whose key is key and value is val. The created text property is not attached to any M-text, i.e. it is detached.
control_bits must be 0 or logical OR of enum MTextPropertyControl . |
|
The mtext_property_mtext() function returns the M-text to which text property prop is attached. If prop is currently detached, NULL is returned. |
|
The mtext_property_start() function returns the start position of text property prop. The start position is a character position of an M-text where prop begins. If prop is detached, it returns -1. |
|
The mtext_property_end() function returns the end position of text property prop. The end position is a character position of an M-text where prop ends. If prop is detached, it returns -1. |
|
The mtext_get_property() function searches the character at position pos in M-text mt for a text property whose key is key.
- Return value:
- If a text property is found, mtext_get_property() returns it. If there are multiple text properties, it returns the topmost one. If no such property is found, it returns
NULL without changing the external variable merror_code.
If an error is detected, mtext_get_property() returns NULL and assigns an error code to the external variable merror_code. |
|
The mtext_get_properties() function searches the character at pos in M-text mt for properties whose key is key. If such properties are found, they are stored in the memory area pointed to by props. num limits the maximum number of stored properties.
- Return value:
- If the operation was successful, mtext_get_properties() returns the number of actually stored properties. If the character at pos does not have a property whose key is key, the return value is 0. If an error is detected, mtext_get_properties() returns -1 and assigns an error code to the external variable merror_code.
|
|
The mtext_attach_property() function attaches text property prop to the range between from and to in M-text mt. If prop is already attached to an M-text, it is detached before attached to mt.
- Return value:
- If the operation was successful, mtext_attach_property() returns 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
|
|
The mtext_detach_property() function makes text property prop detached.
- Return value:
- This function always returns 0.
|
|
The mtext_push_property() function pushes text property prop to the characters between from (inclusive) and to (exclusive) in M-text mt.
- Return value:
- If the operation was successful, mtext_push_property() returns 0. Otherwise it returns -1 and assigns an error code to the external variable merror_code.
|
|
The mtext_serialize() function serializes the text between from and to in M-text mt. The serialized result is an M-text in a form of XML. property_list limits the text properties to be serialized. Only those text properties whose key
are serialized as a "property" element in the resulting XML representation.
The DTD of the generated XML is as follows:
<!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>
]>
This function depends on the libxml2 library. If the m17n library is configured without libxml2, this function always fails.
- Return value:
- If the operation was successful, mtext_serialize() returns an M-text in the form of XML. Otherwise it returns
NULL and assigns an error code to the external variable merror_code.
- See Also:
- mtext_deserialize(), Mtext_prop_serializer
|
|
The mtext_deserialize() function deserializes M-text mt. mt must be an XML having the following 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>
]>
This function depends on the libxml2 library. If the m17n library is configured without libxml2, this function always fail.
- Return value:
- If the operation was successful, mtext_deserialize() returns the resulting M-text. Otherwise it returns
NULL and assigns an error code to the external variable merror_code.
- See Also:
- mtext_serialize(), Mtext_prop_deserializer
|
|