6 /// A value representing the boolean \a false.
8 /// A value representing the boolean \a true.
12 * Struct to hold all the information regarding an XML tag.
14 typedef struct XmlTag
{
17 /// list containing all the children of the tag.
21 /// parent of the tag.
22 struct XmlTag
*parent
;
27 * \param parent what will be the parent of the tag. May be NULL.
28 * \return a new XmlTag with the specified parent.
30 XmlTag
xml_tag_new(XmlTag parent
);
33 * Frees the memory associated with the tag.
34 * This will free all the memory associated with the tag. So all its members will also be freed.
35 * However, none of its children will be freed. To achieve that, use xml_tree_free().
36 * \param tag the tag to be freed
37 * \see xml_tree_free(XmlTag)
39 void xml_tag_free(XmlTag tag
);
42 * Prints a tree of XmlTag's.
43 * This will print a tree of [XmlTag]s in a rather strange way, here's an example:
57 tagone; value: somevalue;
61 * \param tag the root XmlTag of the tree to be printed
62 * \note \a tag, being regarded as the root of the tree, will not actually be printed.
64 void xml_tree_print(XmlTag tag
);
67 * Prints an error message, including where the error occurred.
68 * \param message the message to print
69 * \param line the line at which the error occurred
70 * \param col the column at which the error occurred
72 void xml_error(const char *message
, unsigned int line
, int col
);
75 * Frees an entire tree of XmlTag's.
76 * This function works recursively, by calling itself for every child of \a root,
77 * right before calling xml_tag_free(XmlTag) with \a root as its argument.
78 * \param root the root of the tree to be freed.
79 * \see xml_tag_free(XmlTag)
81 void xml_tree_free(XmlTag root
);
84 * Parses the file at \a path_to_file.
85 * \param path_to_file a string that will be used as the path to the file to be parsed
86 * \return the root XmlTag of the parsed file, or NULL if an error occurred.
88 XmlTag
xml_parse(char *path_to_file
);
91 * This global variable will hold the error status ID as defined in XML_STATUS_ENUM after an error occurs.
98 enum XML_STATUS_ENUM
{
101 /// A tag has been left unclosed after parsing the entire file.
104 * A value has been encountered without having any open tags.
107 some value <-- this value isn't in any tag.
110 some value <-- this value isn't in any tag.
115 * An invalid character has been encountered. It could be a < when we're defining a tag.
118 <tagname<bla> <-- This tag has a <!
122 /** A tag has been closed that wasn't actually the current open tag.
127 </one> <-- one is not the currently opened tag. two is.
132 /// A tag has been opened without a name.
134 /// An I/O error has occurred.