class Poco::XML::AttributesImpl

Overview

This class provides a default implementation of the SAX2 Attributes interface, with the addition of manipulators so that the list can be modified or reused. More…

#include <AttributesImpl.h>

class AttributesImpl: public Poco::XML::Attributes
{
public:
    // typedefs

    typedef std::vector<Attribute> AttributeVec;
    typedef AttributeVec::const_iterator iterator;

    // structs

    struct Attribute;

    // construction

    AttributesImpl();
    AttributesImpl(const Attributes& attributes);
    AttributesImpl(const AttributesImpl& attributes);

    // methods

    AttributesImpl&
    operator=(const AttributesImpl& attributes);

    virtual
    int
    getIndex(const XMLString& name) const;

    virtual
    int
    getIndex(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const;

    virtual
    int
    getLength() const;

    virtual
    const XMLString&
    getLocalName(int i) const;

    virtual
    const XMLString&
    getQName(int i) const;

    virtual
    const XMLString&
    getType(int i) const;

    virtual
    const XMLString&
    getType(const XMLString& qname) const;

    virtual
    const XMLString&
    getType(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const;

    virtual
    const XMLString&
    getValue(int i) const;

    virtual
    const XMLString&
    getValue(const XMLString& qname) const;

    virtual
    const XMLString&
    getValue(
        const XMLString& uri,
        const XMLString& localName
        ) const;

    virtual
    const XMLString&
    getURI(int i) const;

    bool
    isSpecified(int i) const;

    bool
    isSpecified(const XMLString& qname) const;

    bool
    isSpecified(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const;

    void
    setValue(
        int i,
        const XMLString& value
        );

    void
    setValue(
        const XMLString& qname,
        const XMLString& value
        );

    void
    setValue(
        const XMLString& namespaceURI,
        const XMLString& localName,
        const XMLString& value
        );

    void
    setAttributes(const Attributes& attributes);

    void
    setAttribute(
        int i,
        const XMLString& namespaceURI,
        const XMLString& localName,
        const XMLString& qname,
        const XMLString& type,
        const XMLString& value
        );

    void
    addAttribute(
        const XMLString& namespaceURI,
        const XMLString& localName,
        const XMLString& qname,
        const XMLString& type,
        const XMLString& value
        );

    void
    addAttribute(
        const XMLString& namespaceURI,
        const XMLString& localName,
        const XMLString& qname,
        const XMLString& type,
        const XMLString& value,
        bool specified
        );

    void
    addAttribute(
        const XMLChar* namespaceURI,
        const XMLChar* localName,
        const XMLChar* qname,
        const XMLChar* type,
        const XMLChar* value,
        bool specified
        );

    Attribute&
    addAttribute();

    void
    removeAttribute(int i);

    void
    removeAttribute(const XMLString& qname);

    void
    removeAttribute(
        const XMLString& namespaceURI,
        const XMLString& localName
        );

    void
    clear();

    void
    reserve(std::size_t capacity);

    void
    setLocalName(
        int i,
        const XMLString& localName
        );

    void
    setQName(
        int i,
        const XMLString& qname
        );

    void
    setType(
        int i,
        const XMLString& type
        );

    void
    setURI(
        int i,
        const XMLString& namespaceURI
        );

    iterator
    begin() const;

    iterator
    end() const;

protected:
    // methods

    Attribute*
    find(const XMLString& qname) const;

    Attribute*
    find(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const;
};

Inherited Members

public:
    // methods

    virtual
    int
    getIndex(const XMLString& name) const = 0;

    virtual
    int
    getIndex(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const = 0;

    virtual
    int
    getLength() const = 0;

    virtual
    const XMLString&
    getLocalName(int i) const = 0;

    virtual
    const XMLString&
    getQName(int i) const = 0;

    virtual
    const XMLString&
    getType(int i) const = 0;

    virtual
    const XMLString&
    getType(const XMLString& qname) const = 0;

    virtual
    const XMLString&
    getType(
        const XMLString& namespaceURI,
        const XMLString& localName
        ) const = 0;

    virtual
    const XMLString&
    getValue(int i) const = 0;

    virtual
    const XMLString&
    getValue(const XMLString& qname) const = 0;

    virtual
    const XMLString&
    getValue(
        const XMLString& uri,
        const XMLString& localName
        ) const = 0;

    virtual
    const XMLString&
    getURI(int i) const = 0;

Detailed Documentation

This class provides a default implementation of the SAX2 Attributes interface, with the addition of manipulators so that the list can be modified or reused.

There are two typical uses of this class:

1. to take a persistent snapshot of an Attributes object in a startElement event; or
2. to construct or modify an Attributes object in a SAX2 driver or filter.

Construction

AttributesImpl()

Creates the AttributesImpl.

AttributesImpl(const Attributes& attributes)

Creates the AttributesImpl by copying another one.

AttributesImpl(const AttributesImpl& attributes)

Creates the AttributesImpl by copying another one.

Methods

AttributesImpl&
operator=(const AttributesImpl& attributes)

Assignment operator.

virtual
int
getIndex(const XMLString& name) const

Look up the index of an attribute by a qualified name.

virtual
int
getIndex(
    const XMLString& namespaceURI,
    const XMLString& localName
    ) const

Look up the index of an attribute by a namspace name.

virtual
int
getLength() const

Return the number of attributes in the list.

Once you know the number of attributes, you can iterate through the list.

virtual
const XMLString&
getLocalName(int i) const

Look up a local attribute name by index.

virtual
const XMLString&
getQName(int i) const

Look up a qualified attribute name by index.

virtual
const XMLString&
getType(int i) const

Look up an attribute type by index.

The attribute type is one of the strings “CDATA”, “ID”, “IDREF”, “IDREFS”, “NMTOKEN”, “NMTOKENS”, “ENTITY”, “ENTITIES”, or “NOTATION” (always in upper case).

If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value “CDATA” as stated in the XML 1.0 Recommendation (clause 3.3.3, “Attribute-Value Normalization”).

For an enumerated attribute that is not a notation, the parser will report the type as “NMTOKEN”.

virtual
const XMLString&
getType(const XMLString& qname) const

Look up an attribute type by a qualified name.

See getType(int) for a description of the possible types.

virtual
const XMLString&
getType(
    const XMLString& namespaceURI,
    const XMLString& localName
    ) const

Look up an attribute type by a namespace name.

See getType(int) for a description of the possible types.

virtual
const XMLString&
getValue(int i) const

Look up an attribute value by index.

If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single string with each token separated by a single space.

virtual
const XMLString&
getValue(const XMLString& qname) const

Look up an attribute value by a qualified name.

See getValue(int) for a description of the possible values.

virtual
const XMLString&
getValue(
    const XMLString& uri,
    const XMLString& localName
    ) const

Look up an attribute value by a namespace name.

See getValue(int) for a description of the possible values.

virtual
const XMLString&
getURI(int i) const

Look up a namespace URI by index.

bool
isSpecified(int i) const

Returns true unless the attribute value was provided by DTD defaulting.

Extension from Attributes2 interface.

bool
isSpecified(const XMLString& qname) const

Returns true unless the attribute value was provided by DTD defaulting.

Extension from Attributes2 interface.

bool
isSpecified(
    const XMLString& namespaceURI,
    const XMLString& localName
    ) const

Returns true unless the attribute value was provided by DTD defaulting.

Extension from Attributes2 interface.

void
setValue(
    int i,
    const XMLString& value
    )

Sets the value of an attribute.

void
setValue(
    const XMLString& qname,
    const XMLString& value
    )

Sets the value of an attribute.

void
setValue(
    const XMLString& namespaceURI,
    const XMLString& localName,
    const XMLString& value
    )

Sets the value of an attribute.

void
setAttributes(const Attributes& attributes)

Copies the attributes from another Attributes object.

void
setAttribute(
    int i,
    const XMLString& namespaceURI,
    const XMLString& localName,
    const XMLString& qname,
    const XMLString& type,
    const XMLString& value
    )

Sets an attribute.

void
addAttribute(
    const XMLString& namespaceURI,
    const XMLString& localName,
    const XMLString& qname,
    const XMLString& type,
    const XMLString& value
    )

Adds an attribute to the end of the list.

void
addAttribute(
    const XMLString& namespaceURI,
    const XMLString& localName,
    const XMLString& qname,
    const XMLString& type,
    const XMLString& value,
    bool specified
    )

Adds an attribute to the end of the list.

void
addAttribute(
    const XMLChar* namespaceURI,
    const XMLChar* localName,
    const XMLChar* qname,
    const XMLChar* type,
    const XMLChar* value,
    bool specified
    )

Adds an attribute to the end of the list.

Attribute&
addAttribute()

Add an (empty) attribute to the end of the list.

For internal use only. The returned Attribute element must be filled by the caller.

void
removeAttribute(int i)

Removes an attribute.

void
removeAttribute(const XMLString& qname)

Removes an attribute.

void
removeAttribute(
    const XMLString& namespaceURI,
    const XMLString& localName
    )

Removes an attribute.

void
clear()

Removes all attributes.

void
reserve(std::size_t capacity)

Reserves capacity in the internal vector.

void
setLocalName(
    int i,
    const XMLString& localName
    )

Sets the local name of an attribute.

void
setQName(
    int i,
    const XMLString& qname
    )

Sets the qualified name of an attribute.

void
setType(
    int i,
    const XMLString& type
    )

Sets the type of an attribute.

void
setURI(
    int i,
    const XMLString& namespaceURI
    )

Sets the namespace URI of an attribute.

iterator
begin() const

Iterator support.

iterator
end() const

Iterator support.