ISimpleXML



Describes minimum required functionality from SimpleXML component.

You can find more information in comments below. Overrided methods can be found in corresponding base interface.

class ISimpleXML :public virtual IComponent
{
public:
    enum ERROR_TYPE // Error types which may appear during XML parsing 
    {
        etHeaderCloseExpected, // XML header close tag(?>) is expected 
        etIdentifierExpected, // Identifier is expected 
        etAssignmentExpected, // Assignment(=) is expected 
        etStringExpected, // String (either in "" or '') is expected 
        etDuplicateVersion, // Version attribute is already found 
        etDuplicateEncoding, // Encoding attribute is already found 
        etTagOpenExpected, // Tag opening(<) is expected 
        etTagCloseExpected, // Tag closing(> or />) is expected 
        etUnexpectedEnd, // Enexpected end of the file, more data is expected 
        etCloseTagExpected, // Closing tag(starting from String Name; // Name. Cannot be empty 
        String Value; // Value 
    };

    struct ERROR_INFO // Describe error information 
    {
        ERROR_TYPE Type; // Error type 
        int Position; // Position in string/file starting from 0 
    };

    class INode // XML node 
    {
    public:
        virtual INode *getParent() = 0; // Return parent node 
        virtual bool isCData() = 0; // Return whether the value should be exported enclosed in CDATA 
        virtual String getName() = 0; // Return name 
        virtual String getValue() = 0; // Return value 
        virtual String getComment() = 0; // Return comment 
        virtual int getAttributeCount() = 0; // Return attribute count 
        virtual ATTRIBUTE getAttribute(const int index) = 0; // Return attribute by index. Result "Name" and "Value" are both empty if attribute is not found 
        virtual ATTRIBUTE getAttribute(const String &name) = 0; // Return attribute by name. Result "Name" and "Value" are both empty if attribute is not found 
        virtual int getNodeCount() = 0; // Return node count 
        virtual INode *getNode(const int index) = 0; // Return node by index 
        virtual INode *getNode(const String &name) = 0; // Return first found node with specified name 
        virtual bool hasChild(INode *node) = 0; // Check if this or child nodes have specified one 
        virtual bool isValid() = 0; // Return whether node has valid data(no empty names, no duplicate attributes) 

        virtual bool setCData(const bool value) = 0; // Set whether the value should be exported enclosed in CDATA 
        virtual bool setName(const String &value) = 0; // Set name 
        virtual bool setValue(const String &value) = 0; // Set value. Delete all existing nodes 
        virtual bool setComment(const String &value) = 0; // Set comment 

        virtual bool AddAttribute(const String &name, const String &value) = 0; // Add attribute. Name is required. 
        virtual bool SetAttribute(const String &name, const String &value) = 0; // Add or update existing attribute 
        virtual bool DeleteAttribute(const int index) = 0; // Delete attribute by index 
        virtual bool DeleteAttribute(const String &name) = 0; // Delete all attributes with specified name 
        virtual bool DeleteAttributes() = 0; // Delete all attributes 

        virtual INode *AddNode(const String &name) = 0; // Add node if possible and set specified name to it 
        virtual bool DeleteNode(const int index) = 0; // Delete node by index 
        virtual bool DeleteNode(const String &name) = 0; // Delete all nodes with specified name 
        virtual bool DeleteNodes() = 0; // Delete all nodes 

        virtual String ToString(const bool recursive, const bool compact, const String &spaces) = 0; // Convert to string, with or without child nodes, with or without nice(human readable) formatting 
        virtual void Release() = 0; // Delete itself 
    };
public:
    virtual String getVersion() = 0; // Return version 
    virtual String getEncoding() = 0; // Return encoding 
    virtual INode *getRootNode() = 0; // Return root note. Could not be destroyed 

    virtual bool setVersion(const String &value) = 0; // Set version 
    virtual bool setEncoding(const String &value) = 0; // Set encoding 

    virtual String ToString(const bool compact) = 0; // Convert to string, with or without nice(human readable) formatting 
    virtual bool Save(const String &filename, const bool compact) = 0; // Save to file, with or without nice(human readable) formatting 
    virtual bool LoadFromFile(const String &filename, ERROR_INFO &error) = 0; // Load from file containing XML 
    virtual bool LoadFromString(const String &value, ERROR_INFO &error) = 0; // Load from string containing XML 
};
Namespace: nitisa::standard
Include: Standard/Components/ISimpleXML.h