libxml++ r170 - in trunk: . docs docs/reference docs/reference/html libxml++/nodes
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: libxml++ r170 - in trunk: . docs docs/reference docs/reference/html libxml++/nodes
- Date: Wed, 26 Mar 2008 16:32:24 +0000 (GMT)
Author: murrayc
Date: Wed Mar 26 16:32:24 2008
New Revision: 170
URL: http://svn.gnome.org/viewvc/libxml++?rev=170&view=rev
Log:
2008-03-26 Murray Cumming <murrayc murrayc com>
* libxml++/nodes/element.cc:
* libxml++/nodes/element.h: Added add_child_text() with a previous_node
parameter, for adding between existing nodes.
Added add_child_text_before() too.
* libxml++/nodes/node.cc:
* libxml++/nodes/node.h: Added add_child() with a previous_node
parameter, for adding between existing nodes.
Added add_child_before() too.
* docs/index.html: Removed the license clarifications text because I
always found it to be arbitrary and not very informative.
* docs/reference/Doxyfile.in: Added a newin2p24 doxygen keyword.
* docs/reference/Makefile.am: Do not create a version-specific
directory name for reference documentation. The Since: text and links
in the documentation are enough to know what was in what version.
Removed:
trunk/docs/reference/html/
Modified:
trunk/ChangeLog
trunk/docs/index.html
trunk/docs/reference/Doxyfile.in
trunk/docs/reference/Makefile.am
trunk/libxml++/nodes/element.cc
trunk/libxml++/nodes/element.h
trunk/libxml++/nodes/node.cc
trunk/libxml++/nodes/node.h
Modified: trunk/docs/index.html
==============================================================================
--- trunk/docs/index.html (original)
+++ trunk/docs/index.html Wed Mar 26 16:32:24 2008
@@ -16,50 +16,22 @@
<h2>Introduction</h2>
<p>
libxml++ is a C++ wrapper for the <a href="http://www.xmlsoft.org">libxml</a> XML parser library.
-Its original author is Ari Johnson and it is currently maintained by Christophe de Vienne and Murray Cumming.
</p>
<h2>License</h2>
<p>Libxml++ is released under the <a href="http://www.gnu.org/licenses/lgpl.html#TOC1">LGPL</a> version 2 or above</p>
-<h3>Clarifications</h3>
-<p>As requested by some users, here are a few clarifications on the licence:</p>
-<ul>
-<li>Things that proprietary projects can do:</li>
-<ul>
-<LI>Deriving sub-classes based on libxml++ classes</LI>
-</ul>
-<li>Things that proprietary projects cannot do:</li>
-<ul>
-<li>Change their own copy of libxml++ and distribute object code (for
-instance, an application+DLLs that a user installs) for that changed
-libxml++, but then refuse to give the changes to people who have received
-the object code.</LI></ul>
-</ul>
+
<h2>Download</h2>
<p>You can download libxml++ from <a href="http://ftp.gnome.org/pub/GNOME/sources/libxml++/">here</a>.</p>
<h2>Required Libraries</h2>
<ul>
-<li>For libxml++ 1.0
-<ul><li><a href="http://www.xmlsoft.org">libxml2</a> >= 2.5.8 </li></ul>
-</li>
-<li>For libxml++ 2.6 and above
-<ul>
-<li><a href="http://www.xmlsoft.org/">libxml2</a> >= 2.6.1 </li>
-<li><a href="http://www.gtkmm.org/">glibmm-2.4</a> >= 2.4.0 (or a subset of it containing at least Glib::ustring)</li>
-</ul>
-</li>
+<li><a href="http://www.xmlsoft.org/">libxml2</a></li>
+<li><a href="http://www.gtkmm.org/">glibmm-2.4</a> (or a subset of it containing at least Glib::ustring)</li>
</ul>
<h2>Documentation</h2>
-<p>This short <a href="docs/manual/html/index.html">manual</a> gives an overview of the libxml++ API.</p>
-<p>
-You can browse online the Reference documentation generated by
-<a href="http://www.stack.nl/~dimitri/doxygen/index.html">
-<img src="reference/1.0/html/doxygen.png" alt="doxygen" align="middle" border=0 ></a>
+<p>The short <a href="docs/manual/html/index.html">manual</a> gives an overview of the libxml++ API. You can also browse online the <a href="docs/reference/stable/html/hierarchy.html">reference documentation</a>.
</p>
-<ul>
-<li><a href="docs/reference/1.0/html/hierarchy.html">1.0 API</a></li>
-<li><a href="docs/reference/stable/html/hierarchy.html">2.14 API</a></li>
</ul>
<h2>Development</h2>
Modified: trunk/docs/reference/Doxyfile.in
==============================================================================
--- trunk/docs/reference/Doxyfile.in (original)
+++ trunk/docs/reference/Doxyfile.in Wed Mar 26 16:32:24 2008
@@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
PROJECT_NAME = @PACKAGE@
PROJECT_NUMBER = @VERSION@
-OUTPUT_DIRECTORY = @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@
+OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
@@ -26,7 +26,8 @@
TAB_SIZE = 8
ALIASES = "newin2p18=\xrefitem newin2p18s \"Since libxml++ 2.18\" \"New API in libxml++ 2.18\" \n" \
"newin2p20=\xrefitem newin2p20s \"Since libxml++ 2.20\" \"New API in libxml++ 2.20\" \n" \
- "newin2p22=\xrefitem newin2p22s \"Since libxml++ 2.22\" \"New API in libxml++ 2.22\" \n"
+ "newin2p22=\xrefitem newin2p22s \"Since libxml++ 2.22\" \"New API in libxml++ 2.22\" \n" \
+ "newin2p24=\xrefitem newin2p24s \"Since libxml++ 2.24\" \"New API in libxml++ 2.24\" \n"
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
Modified: trunk/docs/reference/Makefile.am
==============================================================================
--- trunk/docs/reference/Makefile.am (original)
+++ trunk/docs/reference/Makefile.am Wed Mar 26 16:32:24 2008
@@ -5,24 +5,23 @@
web_path_reference = $(web_path_docs)reference
-EXTRA_DIST = README Doxyfile libxml++_doxygen_tags @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@/html \
+EXTRA_DIST = README Doxyfile libxml++_doxygen_tags html \
libstdc++.tag.xml
#Ideally, libstdc++.tag.xml would be installed by gcc, instead of being copied into every project.
-index_html = @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@/html/index.html
+index_html = html/index.html
$(index_html): $(doxygen_configfile_source)
doxygen $(doxygen_configfile)
- rm -f stable && ln -s @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@ stable
- GENERIC_MAJOR_VERSION@ GENERIC_MINOR_VERSION@/html: $(index_html)
+html: $(index_html)
libxml++_doxygen_tags: $(index_html)
libxml++-reference-html.tar.gz: $(index_html)
- tar cf - @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@/html | gzip -c --best >$@
+ tar cf - html | gzip -c --best >$@
# Upload to the web site:
@@ -33,12 +32,12 @@
all-local: $(index_html)
doc-clean:
- -rm -rf @GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@/html
+ -rm -rf html
-rm -f libxml++_doxygen_tags
-rm -f $libxml++-reference-html.tar.gz
-referencedir = $(docdir)/reference/@GENERIC_MAJOR_VERSION @GENERIC_MINOR_VERSION@/html
+referencedir = $(docdir)/reference/html
install-reference: $(index_html)
@$(NORMAL_INSTALL)
Modified: trunk/libxml++/nodes/element.cc
==============================================================================
--- trunk/libxml++/nodes/element.cc (original)
+++ trunk/libxml++/nodes/element.cc Wed Mar 26 16:32:24 2008
@@ -156,6 +156,40 @@
return 0;
}
+TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content)
+{
+ if(!previous_sibling)
+ return 0;
+
+ if(cobj()->type == XML_ELEMENT_NODE)
+ {
+ xmlNode* node = xmlNewText((const xmlChar*)content.c_str());
+
+ // Use the result, because node can be freed when merging text nodes:
+ node = xmlAddNextSibling(previous_sibling->cobj(), node);
+
+ return static_cast<TextNode*>(node->_private);
+ }
+ return 0;
+}
+
+TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content)
+{
+ if(!next_sibling)
+ return 0;
+
+ if(cobj()->type == XML_ELEMENT_NODE)
+ {
+ xmlNode* node = xmlNewText((const xmlChar*)content.c_str());
+
+ // Use the result, because node can be freed when merging text nodes:
+ node = xmlAddPrevSibling(next_sibling->cobj(), node);
+
+ return static_cast<TextNode*>(node->_private);
+ }
+ return 0;
+}
+
bool Element::has_child_text() const
{
return get_child_text() != 0;
Modified: trunk/libxml++/nodes/element.h
==============================================================================
--- trunk/libxml++/nodes/element.h (original)
+++ trunk/libxml++/nodes/element.h Wed Mar 26 16:32:24 2008
@@ -94,6 +94,26 @@
*/
TextNode* add_child_text(const Glib::ustring& content = Glib::ustring());
+ /** Add a new text node after the specified existing child node.
+ *
+ * @newin2p24
+ *
+ * @param previous_sibling An existing child node.
+ * @param content The text. This should be unescaped - see ContentNode::set_content().
+ * @returns The new text node.
+ */
+ TextNode* add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content = Glib::ustring());
+
+ /** Add a new text node before the specified existing child node.
+ *
+ * @newin2p24
+ *
+ * @param next_sibling An existing child node.
+ * @param content The text. This should be unescaped - see ContentNode::set_content().
+ * @returns The new text node.
+ */
+ TextNode* add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content = Glib::ustring());
+
/** Set the text of the first text node, adding one if necessary.
* This is a convenience method, meant as an alternative to iterating over all the child nodes to find the first suitable node then and setting the text directly.
* @param content The text. This should be unescaped - see ContentNode::set_content().
Modified: trunk/libxml++/nodes/node.cc
==============================================================================
--- trunk/libxml++/nodes/node.cc (original)
+++ trunk/libxml++/nodes/node.cc Wed Mar 26 16:32:24 2008
@@ -97,7 +97,55 @@
Element* Node::add_child(const Glib::ustring& name,
const Glib::ustring& ns_prefix)
{
- xmlNode* node = 0;
+ _xmlNode* child = create_new_child_node(name, ns_prefix);
+ if(!child)
+ return 0;
+
+ _xmlNode* node = xmlAddChild(impl_, child);
+ if(node)
+ return static_cast<Element*>(node->_private);
+ else
+ return 0;
+}
+
+Element* Node::add_child(xmlpp::Node* previous_sibling,
+ const Glib::ustring& name,
+ const Glib::ustring& ns_prefix)
+{
+ if(!previous_sibling)
+ return 0;
+
+ _xmlNode* child = create_new_child_node(name, ns_prefix);
+ if(!child)
+ return 0;
+
+ _xmlNode* node = xmlAddNextSibling(previous_sibling->cobj(), child);
+ if(node)
+ return static_cast<Element*>(node->_private);
+ else
+ return 0;
+}
+
+Element* Node::add_child_before(xmlpp::Node* next_sibling,
+ const Glib::ustring& name,
+ const Glib::ustring& ns_prefix)
+{
+ if(!next_sibling)
+ return 0;
+
+ _xmlNode* child = create_new_child_node(name, ns_prefix);
+ if(!child)
+ return 0;
+
+ _xmlNode* node = xmlAddPrevSibling(next_sibling->cobj(), child);
+ if(node)
+ return static_cast<Element*>(node->_private);
+ else
+ return 0;
+}
+
+_xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix)
+{
xmlNs* ns = 0;
if(impl_->type != XML_ELEMENT_NODE)
@@ -124,14 +172,10 @@
}
}
- node = xmlAddChild(impl_, xmlNewNode(ns, (const xmlChar*)name.c_str()));
-
- if(node)
- return static_cast<Element*>(node->_private);
- else
- return 0;
+ return xmlNewNode(ns, (const xmlChar*)name.c_str());
}
+
void Node::remove_child(Node* node)
{
//TODO: Allow a node to be removed without deleting it, to allow it to be moved?
Modified: trunk/libxml++/nodes/node.h
==============================================================================
--- trunk/libxml++/nodes/node.h (original)
+++ trunk/libxml++/nodes/node.h Wed Mar 26 16:32:24 2008
@@ -20,7 +20,8 @@
}
#endif //DOXYGEN_SHOULD_SKIP_THIS
-namespace xmlpp {
+namespace xmlpp
+{
class TextNode;
class Element;
@@ -50,7 +51,7 @@
*/
void set_name(const Glib::ustring& name);
- /** Set the namespace prefix used by the node
+ /** Set the namespace prefix used by the node.
* If no such namespace prefix has been declared then this method will throw an exception.
* @param ns_prefix The namespace prefix.
*/
@@ -64,32 +65,32 @@
*/
int get_line() const;
- /** Get the parent element for this node
+ /** Get the parent element for this node.
* @returns The parent node
*/
const Element* get_parent() const;
- /** Get the parent element for this node
+ /** Get the parent element for this node.
* @returns The parent node
*/
Element* get_parent();
- /** Get the next sibling for this node
+ /** Get the next sibling for this node.
* @returns The next sibling
*/
const Node* get_next_sibling() const;
- /** Get the next sibling for this node
+ /** Get the next sibling for this node.
* @returns The next sibling
*/
Node* get_next_sibling();
- /** Get the previous sibling for this node
+ /** Get the previous sibling for this node .
* @returns The previous sibling
*/
const Node* get_previous_sibling() const;
- /** Get the previous sibling for this node
+ /** Get the previous sibling for this node.
* @returns The previous sibling
*/
Node* get_previous_sibling();
@@ -106,7 +107,7 @@
*/
const NodeList get_children(const Glib::ustring& name = Glib::ustring()) const;
- /** Add a child element to this node
+ /** Add a child element to this node.
* @param name The new node name
* @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception.
* @returns The newly-created element
@@ -114,6 +115,28 @@
Element* add_child(const Glib::ustring& name,
const Glib::ustring& ns_prefix = Glib::ustring());
+ /** Add a child element to this node after the specified existing child node.
+ *
+ * @newin2p24
+ *
+ * @param name The new node name
+ * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception.
+ * @returns The newly-created element
+ */
+ Element* add_child(xmlpp::Node* previous_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_prefix = Glib::ustring());
+
+ /** Add a child element to this node before the specified existing child node.
+ *
+ * @newin2p24
+ *
+ * @param name The new node name
+ * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception.
+ * @returns The newly-created element
+ */
+ Element* add_child_before(xmlpp::Node* next_sibling, const Glib::ustring& name,
+ const Glib::ustring& ns_prefix = Glib::ustring());
+
/** Remove the child node.
* @param node The child node to remove. This Node will be deleted and therefore unusable after calling this method.
*/
@@ -127,12 +150,12 @@
Node* import_node(const Node* node, bool recursive = true);
- /** Return the XPath of this node
+ /** Return the XPath of this node.
* @result The XPath of the node.
*/
Glib::ustring get_path() const;
- /** Find nodes from a XPath expression
+ /** Find nodes from a XPath expression.
* @param xpath The XPath of the nodes.
*/
NodeSet find(const Glib::ustring& xpath) const;
@@ -141,7 +164,7 @@
*/
typedef std::map<Glib::ustring, Glib::ustring> PrefixNsMap;
- /** Find nodes from a XPath expression
+ /** Find nodes from a XPath expression.
* @param xpath The XPath of the nodes.
* @param namespaces A map of namespace prefixes to namespace URIs to be used while finding.
*/
@@ -154,6 +177,11 @@
///Access the underlying libxml implementation.
const _xmlNode* cobj() const;
+protected:
+
+ ///Create the C instance ready to be added to the parent node.
+ _xmlNode* create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix);
+
private:
_xmlNode* impl_;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]