mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-13 23:35:30 +00:00
Make mxmlSet* work like mxmlGet*.
This commit is contained in:
parent
6bd5e6e022
commit
ee923fa82c
@ -1438,7 +1438,7 @@ int mxmlSetCDATA (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not a CDATA element node.
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not a CDATA element node.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><span class="info"> Mini-XML 2.1 </span><a name="mxmlSetCustom">mxmlSetCustom</a></h3>
|
||||
@ -1461,7 +1461,7 @@ int mxmlSetCustom (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not a custom node.
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not a custom node.
|
||||
|
||||
</p>
|
||||
<h3 class="function"><a name="mxmlSetCustomHandlers">mxmlSetCustomHandlers</a></h3>
|
||||
@ -1530,7 +1530,7 @@ int mxmlSetInteger (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not an integer node.</p>
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not an integer node.</p>
|
||||
<h3 class="function"><a name="mxmlSetOpaque">mxmlSetOpaque</a></h3>
|
||||
<p class="description">Set the value of an opaque node.</p>
|
||||
<p class="code">
|
||||
@ -1548,7 +1548,7 @@ int mxmlSetOpaque (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not an opaque node.</p>
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not an opaque node.</p>
|
||||
<h3 class="function"><a name="mxmlSetReal">mxmlSetReal</a></h3>
|
||||
<p class="description">Set the value of a real number node.</p>
|
||||
<p class="code">
|
||||
@ -1566,7 +1566,7 @@ int mxmlSetReal (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not a real number node.</p>
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not a real number node.</p>
|
||||
<h3 class="function"><a name="mxmlSetText">mxmlSetText</a></h3>
|
||||
<p class="description">Set the value of a text node.</p>
|
||||
<p class="code">
|
||||
@ -1587,7 +1587,7 @@ int mxmlSetText (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not a text node.</p>
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not a text node.</p>
|
||||
<h3 class="function"><a name="mxmlSetTextf">mxmlSetTextf</a></h3>
|
||||
<p class="description">Set the value of a text node to a formatted string.</p>
|
||||
<p class="code">
|
||||
@ -1611,7 +1611,7 @@ int mxmlSetTextf (<br>
|
||||
<h4 class="returnvalue">Return Value</h4>
|
||||
<p class="description">0 on success, -1 on failure</p>
|
||||
<h4 class="discussion">Discussion</h4>
|
||||
<p class="discussion">The node is not changed if it is not a text node.</p>
|
||||
<p class="discussion">The node is not changed if it (or its first child) is not a text node.</p>
|
||||
<h3 class="function"><span class="info"> Mini-XML 2.7 </span><a name="mxmlSetUserData">mxmlSetUserData</a></h3>
|
||||
<p class="description">Set the user data pointer for a node.</p>
|
||||
<p class="code">
|
||||
|
44
mxml-set.c
44
mxml-set.c
@ -37,7 +37,7 @@
|
||||
/*
|
||||
* 'mxmlSetCDATA()' - Set the element name of a CDATA node.
|
||||
*
|
||||
* The node is not changed if it is not a CDATA element node.
|
||||
* The node is not changed if it (or its first child) is not a CDATA element node.
|
||||
*
|
||||
* @since Mini-XML 2.3@
|
||||
*/
|
||||
@ -50,6 +50,12 @@ mxmlSetCDATA(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
strncmp(node->value.element.name, "![CDATA[", 8) &&
|
||||
node->child && node->child->type == MXML_ELEMENT &&
|
||||
!strncmp(node->child->value.element.name, "![CDATA[", 8))
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_ELEMENT || !data ||
|
||||
strncmp(node->value.element.name, "![CDATA[", 8))
|
||||
return (-1);
|
||||
@ -70,7 +76,7 @@ mxmlSetCDATA(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetCustom()' - Set the data and destructor of a custom data node.
|
||||
*
|
||||
* The node is not changed if it is not a custom node.
|
||||
* The node is not changed if it (or its first child) is not a custom node.
|
||||
*
|
||||
* @since Mini-XML 2.1@
|
||||
*/
|
||||
@ -85,6 +91,10 @@ mxmlSetCustom(
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_CUSTOM)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_CUSTOM)
|
||||
return (-1);
|
||||
|
||||
@ -135,7 +145,7 @@ mxmlSetElement(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetInteger()' - Set the value of an integer node.
|
||||
*
|
||||
* The node is not changed if it is not an integer node.
|
||||
* The node is not changed if it (or its first child) is not an integer node.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
@ -146,6 +156,10 @@ mxmlSetInteger(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_INTEGER)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_INTEGER)
|
||||
return (-1);
|
||||
|
||||
@ -162,7 +176,7 @@ mxmlSetInteger(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetOpaque()' - Set the value of an opaque node.
|
||||
*
|
||||
* The node is not changed if it is not an opaque node.
|
||||
* The node is not changed if it (or its first child) is not an opaque node.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
@ -173,6 +187,10 @@ mxmlSetOpaque(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_OPAQUE)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_OPAQUE || !opaque)
|
||||
return (-1);
|
||||
|
||||
@ -192,7 +210,7 @@ mxmlSetOpaque(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetReal()' - Set the value of a real number node.
|
||||
*
|
||||
* The node is not changed if it is not a real number node.
|
||||
* The node is not changed if it (or its first child) is not a real number node.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
@ -203,6 +221,10 @@ mxmlSetReal(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_REAL)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_REAL)
|
||||
return (-1);
|
||||
|
||||
@ -219,7 +241,7 @@ mxmlSetReal(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetText()' - Set the value of a text node.
|
||||
*
|
||||
* The node is not changed if it is not a text node.
|
||||
* The node is not changed if it (or its first child) is not a text node.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
@ -231,6 +253,10 @@ mxmlSetText(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_TEXT)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_TEXT || !string)
|
||||
return (-1);
|
||||
|
||||
@ -251,7 +277,7 @@ mxmlSetText(mxml_node_t *node, /* I - Node to set */
|
||||
/*
|
||||
* 'mxmlSetTextf()' - Set the value of a text node to a formatted string.
|
||||
*
|
||||
* The node is not changed if it is not a text node.
|
||||
* The node is not changed if it (or its first child) is not a text node.
|
||||
*/
|
||||
|
||||
int /* O - 0 on success, -1 on failure */
|
||||
@ -267,6 +293,10 @@ mxmlSetTextf(mxml_node_t *node, /* I - Node to set */
|
||||
* Range check input...
|
||||
*/
|
||||
|
||||
if (node && node->type == MXML_ELEMENT &&
|
||||
node->child && node->child->type == MXML_TEXT)
|
||||
node = node->child;
|
||||
|
||||
if (!node || node->type != MXML_TEXT || !format)
|
||||
return (-1);
|
||||
|
||||
|
14
mxml.xml
14
mxml.xml
@ -1128,7 +1128,7 @@ element tags.</description>
|
||||
</returnvalue>
|
||||
<description>Set the element name of a CDATA node.
|
||||
|
||||
The node is not changed if it is not a CDATA element node.
|
||||
The node is not changed if it (or its first child) is not a CDATA element node.
|
||||
|
||||
@since Mini-XML 2.3@</description>
|
||||
<argument name="node" direction="I">
|
||||
@ -1147,7 +1147,7 @@ The node is not changed if it is not a CDATA element node.
|
||||
</returnvalue>
|
||||
<description>Set the data and destructor of a custom data node.
|
||||
|
||||
The node is not changed if it is not a custom node.
|
||||
The node is not changed if it (or its first child) is not a custom node.
|
||||
|
||||
@since Mini-XML 2.1@</description>
|
||||
<argument name="node" direction="I">
|
||||
@ -1211,7 +1211,7 @@ The node is not changed if it is not an element node.</description>
|
||||
</returnvalue>
|
||||
<description>Set the value of an integer node.
|
||||
|
||||
The node is not changed if it is not an integer node.</description>
|
||||
The node is not changed if it (or its first child) is not an integer node.</description>
|
||||
<argument name="node" direction="I">
|
||||
<type>mxml_node_t *</type>
|
||||
<description>Node to set</description>
|
||||
@ -1228,7 +1228,7 @@ The node is not changed if it is not an integer node.</description>
|
||||
</returnvalue>
|
||||
<description>Set the value of an opaque node.
|
||||
|
||||
The node is not changed if it is not an opaque node.</description>
|
||||
The node is not changed if it (or its first child) is not an opaque node.</description>
|
||||
<argument name="node" direction="I">
|
||||
<type>mxml_node_t *</type>
|
||||
<description>Node to set</description>
|
||||
@ -1245,7 +1245,7 @@ The node is not changed if it is not an opaque node.</description>
|
||||
</returnvalue>
|
||||
<description>Set the value of a real number node.
|
||||
|
||||
The node is not changed if it is not a real number node.</description>
|
||||
The node is not changed if it (or its first child) is not a real number node.</description>
|
||||
<argument name="node" direction="I">
|
||||
<type>mxml_node_t *</type>
|
||||
<description>Node to set</description>
|
||||
@ -1262,7 +1262,7 @@ The node is not changed if it is not a real number node.</description>
|
||||
</returnvalue>
|
||||
<description>Set the value of a text node.
|
||||
|
||||
The node is not changed if it is not a text node.</description>
|
||||
The node is not changed if it (or its first child) is not a text node.</description>
|
||||
<argument name="node" direction="I">
|
||||
<type>mxml_node_t *</type>
|
||||
<description>Node to set</description>
|
||||
@ -1283,7 +1283,7 @@ The node is not changed if it is not a text node.</description>
|
||||
</returnvalue>
|
||||
<description>Set the value of a text node to a formatted string.
|
||||
|
||||
The node is not changed if it is not a text node.</description>
|
||||
The node is not changed if it (or its first child) is not a text node.</description>
|
||||
<argument name="node" direction="I">
|
||||
<type>mxml_node_t *</type>
|
||||
<description>Node to set</description>
|
||||
|
Loading…
Reference in New Issue
Block a user