summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/r3/xml.cpp
diff options
context:
space:
mode:
authorFelix Geyer <debfx-pkg@fobos.de>2011-04-22 11:24:51 +0200
committerFelix Geyer <debfx-pkg@fobos.de>2011-04-22 11:24:51 +0200
commit3c3b014d3682252dbc133a6d2cd5dd2f8a028bbe (patch)
treeb5eb77e20ee70b9bd9b767e52888639d4136c81d /src/VBox/Runtime/r3/xml.cpp
parent0eeddfd8dc6b9702278fdefa2dee1d3f465e0ea2 (diff)
downloadvirtualbox-3c3b014d3682252dbc133a6d2cd5dd2f8a028bbe.tar.gz
Imported Upstream version 4.0.6-dfsgupstream/4.0.6-dfsg
Diffstat (limited to 'src/VBox/Runtime/r3/xml.cpp')
-rw-r--r--src/VBox/Runtime/r3/xml.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/VBox/Runtime/r3/xml.cpp b/src/VBox/Runtime/r3/xml.cpp
index 602917250..c1007a4da 100644
--- a/src/VBox/Runtime/r3/xml.cpp
+++ b/src/VBox/Runtime/r3/xml.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2007-2010 Oracle Corporation
+ * Copyright (C) 2007-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -1307,11 +1307,13 @@ struct Document::Data
{
xmlDocPtr plibDocument;
ElementNode *pRootElement;
+ ElementNode *pComment;
Data()
{
plibDocument = NULL;
pRootElement = NULL;
+ pComment = NULL;
}
~Data()
@@ -1402,7 +1404,8 @@ ElementNode* Document::getRootElement()
* Creates a new element node and sets it as the root element. This will
* only work if the document is empty; otherwise EDocumentNotEmpty is thrown.
*/
-ElementNode* Document::createRootElement(const char *pcszRootElementName)
+ElementNode* Document::createRootElement(const char *pcszRootElementName,
+ const char *pcszComment /* = NULL */)
{
if (m->pRootElement || m->plibDocument)
throw EDocumentNotEmpty(RT_SRC_POS);
@@ -1414,10 +1417,21 @@ ElementNode* Document::createRootElement(const char *pcszRootElementName)
(const xmlChar*)pcszRootElementName)))
throw std::bad_alloc();
xmlDocSetRootElement(m->plibDocument, plibRootNode);
-
// now wrap this in C++
m->pRootElement = new ElementNode(NULL, NULL, plibRootNode);
+ // add document global comment if specified
+ if (pcszComment != NULL)
+ {
+ xmlNode *pComment;
+ if (!(pComment = xmlNewDocComment(m->plibDocument,
+ (const xmlChar *)pcszComment)))
+ throw std::bad_alloc();
+ xmlAddPrevSibling(plibRootNode, pComment);
+ // now wrap this in C++
+ m->pComment = new ElementNode(NULL, NULL, pComment);
+ }
+
return m->pRootElement;
}