VirtualBox

Changeset 17362 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Mar 4, 2009 6:10:58 PM (16 years ago)
Author:
vboxsync
Message:

OVF: partial implementation of write support in XML classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/xml.h

    r16539 r17362  
    139139{
    140140public:
    141 
    142141    XmlError(xmlErrorPtr aErr);
    143142
     
    151150{
    152151public:
    153 
    154     ENotImplemented (const char *aMsg = NULL) : LogicError (aMsg) {}
    155     ENotImplemented (RT_SRC_POS_DECL) : LogicError (RT_SRC_POS_ARGS) {}
     152    ENotImplemented(const char *aMsg = NULL) : LogicError(aMsg) {}
     153    ENotImplemented(RT_SRC_POS_DECL) : LogicError(RT_SRC_POS_ARGS) {}
    156154};
    157155
     
    159157{
    160158public:
    161 
    162     EInvalidArg (const char *aMsg = NULL) : LogicError (aMsg) {}
    163     EInvalidArg (RT_SRC_POS_DECL) : LogicError (RT_SRC_POS_ARGS) {}
     159    EInvalidArg(const char *aMsg = NULL) : LogicError(aMsg) {}
     160    EInvalidArg(RT_SRC_POS_DECL) : LogicError(RT_SRC_POS_ARGS) {}
     161};
     162
     163class VBOXXML_CLASS EDocumentNotEmpty : public LogicError
     164{
     165public:
     166    EDocumentNotEmpty(const char *aMsg = NULL) : LogicError(aMsg) {}
     167    EDocumentNotEmpty(RT_SRC_POS_DECL) : LogicError(RT_SRC_POS_ARGS) {}
    164168};
    165169
     
    170174{
    171175public:
    172 
    173     ENoMemory (const char *aMsg = NULL) : RuntimeError (aMsg) {}
     176    ENoMemory(const char *aMsg = NULL) : RuntimeError (aMsg) {}
    174177    virtual ~ENoMemory() throw() {}
    175178};
     
    321324
    322325    /**
    323      * Destrroys the File object. If the object was created from a file name
     326     * Destroys the File object. If the object was created from a file name
    324327     * the corresponding file will be automatically closed. If the object was
    325328     * created from a file handle, it will remain open.
     
    418421
    419422/*
    420  * Node
    421  *
     423 * Node:
     424 *  an XML node, which represents either an element or an attribute.
     425 *
     426 *  For elements, getName() returns the element name, and getValue()
     427 *  returns the text contents, if any.
     428 *
     429 *  For attributes, getName() returns the attribute name, and getValue()
     430 *  returns the attribute value, if any.
     431 *
     432 *  Since the default constructor is private, one can create new nodes
     433 *  only through factory methods provided by the XML classes. These are:
     434 *
     435 *  --  xml::Document::createRootElement()
     436 *  --  xml::Node::createChild()
     437 *  --  xml::Node::setAttribute()
    422438 */
    423439
     
    428444{
    429445public:
    430     Node();
    431446    ~Node();
    432447
     
    451466    bool getAttributeValue(const char *pcszMatch, uint64_t &i) const;
    452467
    453 private:
     468    Node* createChild(const char *pcszElementName);
     469    Node* setAttribute(const char *pcszName, const char *pcszValue);
     470
     471private:
     472    // hide the default constructor so people use only our factory methods
     473    Node();
     474
    454475    friend class Document;
    455476    friend class XmlFileParser;
     
    477498
    478499private:
     500    /* Obscure class data */
    479501    struct Data;
    480502    Data *m;
     
    491513    Document();
    492514    ~Document();
     515
    493516    Document(const Document &x);
    494517    Document& operator=(const Document &x);
     
    496519    const Node* getRootElement() const;
    497520
     521    Node* createRootElement(const char *pcszRootElementName);
     522
    498523private:
    499524    friend class XmlFileParser;
     525    friend class XmlFileWriter;
    500526
    501527    void refreshInternals();
     
    539565
    540566    static int ReadCallback(void *aCtxt, char *aBuf, int aLen);
    541 
    542567    static int CloseCallback (void *aCtxt);
    543568};
    544569
    545 
     570/*
     571 * XmlFileWriter
     572 *
     573 */
     574
     575class VBOXXML_CLASS XmlFileWriter
     576{
     577public:
     578    XmlFileWriter(Document &doc);
     579    ~XmlFileWriter();
     580
     581    void write(const char *pcszFilename);
     582
     583    static int WriteCallback(void *aCtxt, const char *aBuf, int aLen);
     584    static int CloseCallback (void *aCtxt);
     585
     586private:
     587    /* Obscure class data */
     588    struct Data;
     589    Data *m;
     590};
    546591
    547592#if defined(_MSC_VER)
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