VirtualBox

Changeset 36405 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 24, 2011 3:57:03 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70760
Message:

IPRT/xml: add optional parameter for adding a comment to the created xml file. Used by VirtualBox.xml and the VM config files to include a "do not edit" notice.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r36395 r36405  
    5252
    5353/*
    54  * Copyright (C) 2007-2010 Oracle Corporation
     54 * Copyright (C) 2007-2011 Oracle Corporation
    5555 *
    5656 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    864864    m->pDoc = new xml::Document;
    865865
    866     m->pelmRoot = m->pDoc->createRootElement("VirtualBox");
     866    m->pelmRoot = m->pDoc->createRootElement("VirtualBox",
     867                                             "\n"
     868                                             "** DO NOT EDIT THIS FILE.\n"
     869                                             "** If you make changes to this file while any VirtualBox related application\n"
     870                                             "** is running, your changes will be overwritten later, without taking effect.\n"
     871                                             "** Use VBoxManage or the VirtualBox Manager GUI to make changes.\n"
     872);
    867873    m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE);
    868874
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r35729 r36405  
    55
    66/*
    7  * Copyright (C) 2007-2010 Oracle Corporation
     7 * Copyright (C) 2007-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    13081308    xmlDocPtr   plibDocument;
    13091309    ElementNode *pRootElement;
     1310    ElementNode *pComment;
    13101311
    13111312    Data()
     
    13131314        plibDocument = NULL;
    13141315        pRootElement = NULL;
     1316        pComment = NULL;
    13151317    }
    13161318
     
    14031405 * only work if the document is empty; otherwise EDocumentNotEmpty is thrown.
    14041406 */
    1405 ElementNode* Document::createRootElement(const char *pcszRootElementName)
     1407ElementNode* Document::createRootElement(const char *pcszRootElementName,
     1408                                         const char *pcszComment /* = NULL */)
    14061409{
    14071410    if (m->pRootElement || m->plibDocument)
     
    14151418        throw std::bad_alloc();
    14161419    xmlDocSetRootElement(m->plibDocument, plibRootNode);
    1417 
    14181420    // now wrap this in C++
    14191421    m->pRootElement = new ElementNode(NULL, NULL, plibRootNode);
     1422
     1423    // add document global comment if specified
     1424    if (pcszComment != NULL)
     1425    {
     1426        xmlNode *pComment;
     1427        if (!(pComment = xmlNewDocComment(m->plibDocument,
     1428                                          (const xmlChar *)pcszComment)))
     1429            throw std::bad_alloc();
     1430        xmlAddPrevSibling(plibRootNode, pComment);
     1431        // now wrap this in C++
     1432        m->pComment = new ElementNode(NULL, NULL, pComment);
     1433    }
    14201434
    14211435    return m->pRootElement;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette