diff --git a/documentation.html b/documentation.html index b141ea4..4af344e 100644 --- a/documentation.html +++ b/documentation.html @@ -11,23 +11,19 @@
Node Type
+The XML node type.
Name | Description |
---|
Name | Description |
---|---|
parent | Parent node |
where | Where to add |
child | Child node for where |
where | Where to add, MXML_ADD_BEFORE or MXML_ADD_AFTER |
child | Child node for where or MXML_ADD_TO_PARENT |
node | Node to add |
Nothing.
Delete a node and all of its children.
+Delete a node and all of its children. + +If the specified node has a parent, this function first removes the +node from its parent using the mxmlRemove() function.
void mxmlDelete( - mxml_node_t * node); + mxml_node_t * node);
Name | Description |
---|---|
node | Node |
node | Node to delete |
Nothing.
Get an attribute.
+Get an attribute. + +This function returns NULL if the node is not an element or the +named attribute does not exist.
const char * mxmlElementGetAttr( - mxml_node_t * node, + mxml_node_t * node, const char * name);
Attribute value or NULL
Set an attribute.
+Set an attribute. + +If the named attribute already exists, the value of the attribute +is replaced by the new string value. The string value is copied +into the element node. This function does nothing if the node is +not an element.
void mxmlElementSetAttr( - mxml_node_t * node, + mxml_node_t * node, const char * name, const char * value);@@ -138,13 +152,22 @@ mxmlElementSetAttr(
Nothing.
Find the named element.
+Find the named element. + +The search is constrained by the name, attribute name, and value; any +NULL names or values are treated as wildcards, so different kinds of +searches can be implemented by looking for all elements of a given name +or all elements with a specific attribute. The descend argument determines +whether the search descends into child nodes; normally you will use +MXML_DESCEND_FIRST for the initial search and MXML_NO_DESCEND to find +additional direct descendents of the node. The top node argument +constrains the search to a particular node's children.
-mxml_node_t * +mxml_node_t * mxmlFindElement( - mxml_node_t * node, - mxml_node_t * top, + mxml_node_t * node, + mxml_node_t * top, const char * name, const char * attr, const char * value, @@ -159,20 +182,27 @@ mxmlFindElement(name Element name or NULL for any attr Attribute name, or NULL for none - value Attribute value, or NULL for any + descend Descend into tree? descend Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST
Element node or NULL
Load a file into an XML node tree.
+Load a file into an XML node tree. + +The nodes in the specified file are added to the specified top node. +If no top node is provided, the XML file MUST be well-formed with a +single parent node like <?xml> for the entire file. The callback +function returns the value type that should be used for child nodes. +If MXML_NO_CALLBACK is specified then all child nodes will be either +MXML_ELEMENT or MXML_TEXT nodes.
-mxml_node_t * +mxml_node_t * mxmlLoadFile( - mxml_node_t * top, + mxml_node_t * top, FILE * fp, - mxml_type_t (*cb)(mxml_node_t *)); + mxml_type_t (*cb)(mxml_node_t *));
top | Top node |
fp | File to read from |
(*cb)(mxml_node_t *) | Callback function |
(*cb)(mxml_node_t *) | Callback function or MXML_NO_CALLBACK |
First node
+First node or NULL if the file could not be read.
Create a new element node.
+Create a new element node. + +The new element node is added to the end of the specified parent's child +list. The constant MXML_NO_PARENT can be used to specify that the new +element node has no parent.
-mxml_node_t * +mxml_node_t * mxmlNewElement( - mxml_node_t * parent, + mxml_node_t * parent, const char * name);
Name | Description |
---|---|
parent | Parent node |
parent | Parent node or MXML_NO_PARENT |
name | Name of element |
New node
Create a new integer node.
+Create a new integer node. + +The new integer node is added to the end of the specified parent's child +list. The constant MXML_NO_PARENT can be used to specify that the new +integer node has no parent.
-mxml_node_t * +mxml_node_t * mxmlNewInteger( - mxml_node_t * parent, + mxml_node_t * parent, int integer);
Name | Description |
---|---|
parent | Parent node |
parent | Parent node or MXML_NO_PARENT |
integer | Integer value |
New node
Create a new opaque string.
+Create a new opaque string. + +The new opaque node is added to the end of the specified parent's child +list. The constant MXML_NO_PARENT can be used to specify that the new +opaque node has no parent. The opaque string must be nul-terminated and +is copied into the new node.
-mxml_node_t * +mxml_node_t * mxmlNewOpaque( - mxml_node_t * parent, + mxml_node_t * parent, const char * opaque);
Name | Description |
---|---|
parent | Parent node |
parent | Parent node or MXML_NO_PARENT |
opaque | Opaque string |
New node
Create a new real number node.
+Create a new real number node. + +The new real number node is added to the end of the specified parent's +child list. The constant MXML_NO_PARENT can be used to specify that +the new real number node has no parent.
-mxml_node_t * +mxml_node_t * mxmlNewReal( - mxml_node_t * parent, + mxml_node_t * parent, double real);
Name | Description |
---|---|
parent | Parent node |
parent | Parent node or MXML_NO_PARENT |
real | Real number value |
New node
Create a new text fragment node.
+Create a new text fragment node. + +The new text node is added to the end of the specified parent's child +list. The constant MXML_NO_PARENT can be used to specify that the new +text node has no parent. The whitespace parameter is used to specify +whether leading whitespace is present before the node. The text +string must be nul-terminated and is copied into the new node.
-mxml_node_t * +mxml_node_t * mxmlNewText( - mxml_node_t * parent, + mxml_node_t * parent, int whitespace, const char * string);@@ -275,20 +328,23 @@ mxmlNewText(
Name | Description |
---|---|
parent | Parent node |
whitespace | Leading whitespace? |
parent | Parent node or MXML_NO_PARENT |
whitespace | 1 = leading whitespace, 0 = no whitespace |
string | String |
New node
Remove a node from its parent.
+Remove a node from its parent. + +Does not free memory used by the node - use mxmlDelete() for that. +This function does nothing if the node has no parent.
void mxmlRemove( - mxml_node_t * node); + mxml_node_t * node);
node | Node to write |
fp | File to write to |
(*cb)(mxml_node_t *int) | Whitespace callback |
(*cb)(mxml_node_t *int) | Whitespace callback or MXML_NO_CALLBACK |
0 on success, -1 on error
+0 on success, -1 on error.
Walk to the next logical node in the tree.
+Walk to the next logical node in the tree. + +The descend argument controls whether the first child is considered +to be the next node. The top node argument constrains the walk to +the node's children.
-mxml_node_t * +mxml_node_t * mxmlWalkNext( - mxml_node_t * node, - mxml_node_t * top, + mxml_node_t * node, + mxml_node_t * top, int descend);
Next node or NULL
Walk to the previous logical node in the tree.
+Walk to the previous logical node in the tree. + +The descend argument controls whether the previous node's last child +is considered to be the previous node. The top node argument constrains +the walk to the node's children.
-mxml_node_t * +mxml_node_t * mxmlWalkPrev( - mxml_node_t * node, - mxml_node_t * top, + mxml_node_t * node, + mxml_node_t * top, int descend);
Previous node or NULL
@@ -370,7 +440,7 @@ mxmlWalkPrev(Attribute Value
+An XML element attribute value.
struct mxml_attr_s @@ -388,18 +458,18 @@ struct mxml_attr_s
mxml_node_s
-Node
+Data types...
Definition
struct mxml_node_s { - mxml_node_t * child; - mxml_node_t * last_child; - mxml_node_t * next; - mxml_node_t * parent; - mxml_node_t * prev; - mxml_type_t type; - mxml_value_t value; + mxml_node_t * child; + mxml_node_t * last_child; + mxml_node_t * next; + mxml_node_t * parent; + mxml_node_t * prev; + mxml_type_t type; + mxml_value_t value; };Members
@@ -416,7 +486,7 @@ struct mxml_node_s
mxml_text_s
-Text Value
+An XML text value.
Definition
struct mxml_text_s @@ -434,12 +504,12 @@ struct mxml_text_s
mxml_value_s
-Element Value
+An XML element value.
Definition
struct mxml_value_s { - mxml_attr_t * attrs; + mxml_attr_t * attrs; char * name; int num_attrs; }; @@ -456,44 +526,52 @@ struct mxml_value_s
Attribute Value
+An XML element attribute value.
-typedef struct mxml_attr_s mxml_attr_t; +typedef struct mxml_attr_s mxml_attr_t;
Element Value
+An XML element value.
-typedef struct mxml_value_s mxml_element_t; +typedef struct mxml_value_s mxml_element_t; ++
An XML node.
++typedef struct mxml_node_s mxml_node_t;
Text Value
+An XML text value.
-typedef struct mxml_text_s mxml_text_t; +typedef struct mxml_text_s mxml_text_t;
Node Type
+The XML node type.
-typedef enum mxml_type_e mxml_type_t; +typedef enum mxml_type_e mxml_type_t;
Node Value
+An XML node value.
-typedef union mxml_value_u mxml_value_t; +typedef union mxml_value_u mxml_value_t;
Node Value
+An XML node value.
struct mxml_value_u { - mxml_element_t element; + mxml_element_t element; int integer; char * opaque; double real; - mxml_text_t text; + mxml_text_t text; };
", stdout); - write_element(description); - puts("
"); + name = mxmlElementGetAttr(scut, "name"); + printf("\t"); + puts(""); - printf("struct %s\n{\n", name); - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) + for (scut = mxmlFindElement(doc, doc, "class", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "class", NULL, NULL, + MXML_NO_DESCEND)) { - printf(" "); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("%s
\n", name, name); + + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("", stdout); + write_element(NULL, description); + puts("
"); + } + + puts("Definition
"); + puts(""); + + printf("struct %s\n{\n", name); + for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(" "); + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + } + + puts("};\n"); + + puts("Members
"); + + puts("
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts(" |
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts(" |
", stdout); - write_element(description); - puts("
"); + name = mxmlElementGetAttr(scut, "name"); + printf("\tName | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name"));
+ name = mxmlElementGetAttr(scut, "name");
+ puts(" "); + printf(" %s\n", name, name); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("", stdout); + write_element(NULL, description); + puts(" "); + } - puts(" |
", stdout); - write_element(description); - puts("
"); - } - - puts(""); - - arg = mxmlFindElement(function, function, "returnvalue", NULL, - NULL, MXML_DESCEND_FIRST); - - if (arg) - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - else - fputs("void", stdout); - - printf("\n%s", name); - for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, - MXML_DESCEND_FIRST), prefix = '('; - arg; - arg = mxmlFindElement(arg, function, "argument", NULL, NULL, - MXML_NO_DESCEND), prefix = ',') - { - printf("%c\n ", prefix); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s", mxmlElementGetAttr(arg, "name")); - } - - if (prefix == '(') - puts("(void);\n"); - else - puts(");\n"); - - puts("
None.
"); - else - { puts("Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); + write_element(doc, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); - puts(" |
Nothing.
"); - else + for (function = mxmlFindElement(doc, doc, "function", NULL, NULL, + MXML_DESCEND_FIRST); + function; + function = mxmlFindElement(function, doc, "function", NULL, NULL, + MXML_NO_DESCEND)) { - fputs("", stdout); - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - puts("
"); + name = mxmlElementGetAttr(function, "name"); + printf("\t", stdout); + write_element(NULL, description); + puts("
"); + } + + puts(""); + + arg = mxmlFindElement(function, function, "returnvalue", NULL, + NULL, MXML_DESCEND_FIRST); + + if (arg) + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + else + fputs("void", stdout); + + printf("\n%s", name); + for (arg = mxmlFindElement(function, function, "argument", NULL, NULL, + MXML_DESCEND_FIRST), prefix = '('; + arg; + arg = mxmlFindElement(arg, function, "argument", NULL, NULL, + MXML_NO_DESCEND), prefix = ',') + { + printf("%c\n ", prefix); + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + printf(" %s", mxmlElementGetAttr(arg, "name")); + } + + if (prefix == '(') + puts("(void);\n"); + else + puts(");\n"); + + puts("
None.
"); + else + { + puts("Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts(" |
Nothing.
"); + else + { + fputs("", stdout); + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + puts("
"); + } } } @@ -1608,205 +1683,265 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */ * List of structures... */ - puts("", stdout); - write_element(description); - puts("
"); + name = mxmlElementGetAttr(scut, "name"); + printf("\t"); + puts(""); - printf("struct %s\n{\n", name); - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, - MXML_DESCEND_FIRST); - arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, - MXML_NO_DESCEND)) + for (scut = mxmlFindElement(doc, doc, "struct", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "struct", NULL, NULL, + MXML_NO_DESCEND)) { - printf(" "); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + name = mxmlElementGetAttr(scut, "name"); + puts("
"); + printf("%s
\n", name, name); + + description = mxmlFindElement(scut, scut, "description", NULL, + NULL, MXML_DESCEND_FIRST); + if (description) + { + fputs("", stdout); + write_element(NULL, description); + puts("
"); + } + + puts("Definition
"); + puts(""); + + printf("struct %s\n{\n", name); + for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(" "); + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + } + + puts("};\n"); + + puts("Members
"); + + puts("
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts(" |
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts(" |
", stdout); - write_element(description); - puts("
"); + name = mxmlElementGetAttr(scut, "name"); + printf("\t"); + puts(""); - printf("typedef "); - write_element(mxmlFindElement(scut, scut, "type", NULL, - NULL, MXML_DESCEND_FIRST)); - printf(" %s;\n\n", name); + for (scut = mxmlFindElement(doc, doc, "typedef", NULL, NULL, + MXML_DESCEND_FIRST); + scut; + scut = mxmlFindElement(scut, doc, "typedef", NULL, NULL, + MXML_NO_DESCEND)) + { + name = mxmlElementGetAttr(scut, "name"); + puts("
", stdout); + write_element(NULL, description); + puts("
"); + } + + puts(""); + + printf("typedef "); + write_element(doc, mxmlFindElement(scut, scut, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + printf(" %s;\n\n", name); + } } /* * List of unions... */ - puts("
", stdout); + write_element(NULL, description); + puts("
"); + } + + puts(""); + + printf("struct %s\n{\n", name); + for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + MXML_DESCEND_FIRST); + arg; + arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + MXML_NO_DESCEND)) + { + printf(" "); + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); + printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + } + + puts("};\n"); + + puts("
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); + + write_element(NULL, mxmlFindElement(arg, arg, "description", NULL, + NULL, MXML_DESCEND_FIRST)); + + puts(" |
", stdout); - write_element(description); - puts("
"); - } - - puts(""); - - printf("struct %s\n{\n", name); - for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL, + for (arg = mxmlFindElement(doc, doc, "variable", NULL, NULL, MXML_DESCEND_FIRST); arg; - arg = mxmlFindElement(arg, scut, "variable", NULL, NULL, + arg = mxmlFindElement(arg, doc, "variable", NULL, NULL, MXML_NO_DESCEND)) { - printf(" "); - write_element(mxmlFindElement(arg, arg, "type", NULL, - NULL, MXML_DESCEND_FIRST)); + name = mxmlElementGetAttr(arg, "name"); + printf("\t
", stdout); + write_element(NULL, description); + puts("
"); + } + + puts(""); + + write_element(doc, mxmlFindElement(arg, arg, "type", NULL, + NULL, MXML_DESCEND_FIRST)); printf(" %s;\n", mxmlElementGetAttr(arg, "name")); + + puts(""); } - - puts("};\n"); - - puts("
Name | Description |
---|---|
%s | ", mxmlElementGetAttr(arg, "name")); - - write_element(mxmlFindElement(arg, arg, "description", NULL, - NULL, MXML_DESCEND_FIRST)); - - puts(" |