Unicorn XML Toolkit
Version 1.50.00

Namespace Sax
Class CAttributesImpl

class CAttributesImpl: public CAttributes {
public:
    CAttributesImpl();
    CAttributesImpl(CAttributes *pAtts);
    ~CAttributesImpl();
public:
    int GetLength();
    const WCHAR *GetUri(int nIndex);
    const WCHAR *GetLocalName(int nIndex);
    const WCHAR *GetQName(int nIndex);
    const WCHAR *GetType(int nIndex);
    const WCHAR *GetValue(int nIndex);
    int GetIndex(
        const WCHAR *pszUri, 
        const WCHAR *pszLocalName);
    int GetIndex(const WCHAR *pszQName);
    const WCHAR *GetType(
        const WCHAR *pszUri,
        const WCHAR *pszLocalName);
    const WCHAR *GetType(const WCHAR *pszQName);
    const WCHAR *GetValue(
        const WCHAR *pszUri,
        const WCHAR *pszLocalName);
    const WCHAR *GetValue(const WCHAR *pszQName);
public:
    void Clear();
    void SetAttributes(CAttributes *pAtts);
    void AddAttribute(
        const WCHAR *pszUri,
        const WCHAR *pszLocalName,
        const WCHAR *pszQName,
        const WCHAR *pszType,
        const WCHAR *pszValue);
    void SetAttribute(
        int nIndex,
        const WCHAR *pszUri,
        const WCHAR *pszLocalName,
        const WCHAR *pszQName,
        const WCHAR *pszType,
        const WCHAR *pszValue);
    void RemoveAttribute(int nIndex);
    void SetUri(int nIndex, const WCHAR *pszUri);
    void SetLocalName(int nIndex, const WCHAR *pszLocalName);
    void SetQName(int nIndex, const WCHAR *pszQName);
    void SetType(int nIndex, const WCHAR *pszType);
    void SetValue(int nIndex, const WCHAR *pszValue);
    };

The default implementation of lists of XML attributes.

This class provides the default implementation to the interface specified by the CAttributes class, with the addition of manipulators so that lists of attributes can be modified or reused.

There are two typical uses of this class:

Since:
1.00.00
Version:
1.50.00
Author:
C++ interfaces by Alexey Gokhberg; based on the original SAX2 specification by David Megginson
See Also:
CAttributes
Constructor/Destructor Summary
CAttributesImpl ();
����������Constructs the empty list of attributes.
CAttributesImpl (CAttributes *pAtts);
����������Constructs the list of attributes, copying an existing CAttributes object.
~CAttributesImpl ();
����������Destroys the list of attributes.

Function Summary
int GetLength ();
����������Gets the number of attributes in this list.
const�WCHAR�* GetUri (int nIndex);
����������Looks up an attribute's namespace URI by index.
const�WCHAR�* GetLocalName (int nIndex);
����������Looks up an attribute's local name by index.
const�WCHAR�* GetQName (int nIndex);
����������Looks up an attribute's XML 1.0 qualified name by index.
const�WCHAR�* GetType (int nIndex);
����������Looks up an attribute's type by index.
const�WCHAR�* GetValue (int nIndex);
����������Looks up an attribute's value by index.
int GetIndex (const WCHAR *pszUri, const WCHAR *pszLocalName);
����������Looks up the index of an attribute by namespace name.
int GetIndex (const WCHAR *pszQName);
����������Looks up the index of an attribute by XML 1.0 qualified name.
const�WCHAR�* GetType (const WCHAR *pszUri, const WCHAR *pszLocalName);
����������Looks up an attribute's type by namespace name.
const�WCHAR�* GetType (const WCHAR *pszQName);
����������Looks up an attribute's type by XML 1.0 qualified name.
const�WCHAR�* GetValue (const WCHAR *pszUri, const WCHAR *pszLocalName);
����������Looks up an attribute's value by namespace name.
const�WCHAR�* GetValue (const WCHAR *pszQName);
����������Looks up an attribute's value by XML 1.0 qualified name.
void Clear ();
����������Clears the attribute list for reuse.
void SetAttributes (CAttributes *pAtts);
����������Copies an entire attribute list.
void AddAttribute (const WCHAR *pszUri, const WCHAR *pszLocalName, const WCHAR *pszQName, const WCHAR *pszType, const WCHAR *pszValue);
����������Adds the attribute to the end of the list.
void SetAttribute (int nIndex, const WCHAR *pszUri, const WCHAR *pszLocalName, const WCHAR *pszQName, const WCHAR *pszType, const WCHAR *pszValue);
����������Sets an attribute in the list.
void RemoveAttribute (int nIndex);
����������Removes an attribute from this list.
void SetUri (int nIndex, const WCHAR *pszUri);
����������Sets the namespace URI of a specific attribute.
void SetLocalName (int nIndex, const WCHAR *pszLocalName);
����������Sets the local name of a specific attribute.
void SetQName (int nIndex, const WCHAR *pszQName);
����������Sets the qualified name of a specific attribute.
void SetType (int nIndex, const WCHAR *pszType);
����������Sets the type of a specific attribute.
void SetValue (int nIndex, const WCHAR *pszValue);
����������Sets the value of a specific attribute.

Constructor/Destructor Detail

CAttributesImpl

CAttributesImpl();

Constructs the empty list of attributes.

CAttributesImpl

CAttributesImpl(CAttributes *pAtts);

Constructs the list of attributes, copying an existing CAttributes object.

This constructor might be especially useful inside a CContentHandler::StartElement event.

Parameters:
pAtts - the existing list of attributes

~CAttributesImpl

~CAttributesImpl();

Destroys the list of attributes.

Function Detail

GetLength

int GetLength();

Gets the number of attributes in this list.

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

Returns:
the number of attributes in this list

GetUri

const WCHAR *GetUri(int nIndex);

Looks up an attribute's namespace URI by index.

Parameters:
nIndex - the attribute index (zero-based)
Returns:
the namespace URI, or the empty string if none is available or if the index is out of range

GetLocalName

const WCHAR *GetLocalName(int nIndex);

Looks up an attribute's local name by index.

Parameters:
nIndex - the attribute index (zero-based)
Returns:
the local name, or the empty string if namespace processing is not being performed or if the index is out of range

GetQName

const WCHAR *GetQName(int nIndex);

Looks up an attribute's XML 1.0 qualified name by index.

Parameters:
nIndex - the attribute index (zero-based)
Returns:
the XML 1.0 qualified name, or the empty string if none is available or if the index is out of range

GetType

const WCHAR *GetType(int nIndex);

Looks up an attribute's 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 reader has not read a declaration for the attribute, or if the reader does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommentation (clause 3.3.3, "Attribute-Value Normalization").

For an enumerated attribute that is not a notation, the reader will report the type as "NMTOKEN" .

Parameters:
nIndex - the attribute index (zero-based)
Returns:
the attribute's type as a string, or the empty string if the index is out of range

GetValue

const WCHAR *GetValue(int nIndex);

Looks up an attribute's 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.

Parameters:
nIndex - the attribute index (zero-based)
Returns:
the attribute's value as a string, or the empty string if the index is out of range

GetIndex

int GetIndex(
    const WCHAR *pszUri, 
    const WCHAR *pszLocalName);

Looks up the index of an attribute by namespace name.

Parameters:
pszUri - the namespace URI, or the empty string if the name has no namespace URI
pszLocalName - the attribute's local name
Returns:
the index of the attribute, or -1 if it does not appear in the list

GetIndex

int GetIndex(const WCHAR *pszQName);

Looks up the index of an attribute by XML 1.0 qualified name.

Parameters:
pszQName - the qualified (prefixed) name
Returns:
the index of the attribute, or -1 if it does not appear in the list

GetType

const WCHAR *GetType(
    const WCHAR *pszUri,
    const WCHAR *pszLocalName);

Looks up an attribute's type by namespace name.

Parameters:
pszUri - the namespace URI, or the empty string if the name has no namespace URI
pszLocalName - the attribute's local name
Returns:
the attribute type as a string, or the empty string if the attribute is not in the list or if namespace processing is not being performed

GetType

const WCHAR *GetType(const WCHAR *pszQName);

Looks up an attribute's type by XML 1.0 qualified name.

Parameters:
pszQName - the qualified (prefixed) name
Returns:
the attribute type as a string, or the empty string if the attribute is not in the list or if qualified names are not available

GetValue

const WCHAR *GetValue(
    const WCHAR *pszUri,
    const WCHAR *pszLocalName);

Looks up an attribute's value by namespace name.

Parameters:
pszUri - the namespace URI, or the empty string if the name has no namespace URI
pszLocalName - the attribute's local name
Returns:
the attribute value as a string, or the empty string if the attribute is not in the list

GetValue

const WCHAR *GetValue(const WCHAR *pszQName);

Looks up an attribute's value by XML 1.0 qualified name.

Parameters:
pszQName - the qualified (prefixed) name
Returns:
the attribute value as a string, or the empty string if the attribute is not in the list or if qualified names are not available

Clear

void Clear();

Clears the attribute list for reuse.

SetAttributes

void SetAttributes(CAttributes *pAtts);

Copies an entire attribute list.

Parameters:
pAtts - the attribute list to copy

AddAttribute

void AddAttribute(
    const WCHAR *pszUri,
    const WCHAR *pszLocalName,
    const WCHAR *pszQName,
    const WCHAR *pszType,
    const WCHAR *pszValue);

Adds the attribute to the end of the list.

Parameters:
pszUri - the namespace URI, or the empty string if none is available or namespace processing is not being performed
pszLocalName - the local name, or the empty string if namespace processing is not being performed
pszQName - the qualified (prefixed) name, or the empty string if qualified names are not available
pszType - the attribute type as a string
pszValue - the attribute value

SetAttribute

void SetAttribute(
    int nIndex,
    const WCHAR *pszUri,
    const WCHAR *pszLocalName,
    const WCHAR *pszQName,
    const WCHAR *pszType,
    const WCHAR *pszValue);

Sets an attribute in the list.

Parameters:
nIndex - the index of the attribute (zero-based)
pszUri - the namespace URI, or the empty string if none is available or namespace processing is not being performed
pszLocalName - the local name, or the empty string if namespace processing is not being performed
pszQName - the qualified name, or the empty string if qualified names are not available
pszType - the attribute type as a string
pszValue - the attribute value

RemoveAttribute

void RemoveAttribute(int nIndex);

Removes an attribute from this list.

Parameters:
nIndex - the index of the attribute (zero-based)

SetUri

void SetUri(int nIndex, const WCHAR *pszUri);

Sets the namespace URI of a specific attribute.

Parameters:
nIndex - the index of the attribute (zero-based)
pszUri - the attribute's namespace URI, or the empty string for none

SetLocalName

void SetLocalName(int nIndex, const WCHAR *pszLocalName);

Sets the local name of a specific attribute.

Parameters:
nIndex - the index of the attribute (zero-based)
pszLocalName - the attribute's local name, or the empty string for none

SetQName

void SetQName(int nIndex, const WCHAR *pszQName);

Sets the qualified name of a specific attribute.

Parameters:
nIndex - the index of the attribute (zero-based)
pszLocalName - the attribute's qualified name, or the empty string for none

SetType

void SetType(int nIndex, const WCHAR *pszType);

Sets the type of a specific attribute.

Parameters:
nIndex - the index of the attribute (zero-based)
pszType - the attribute's type

SetValue

void SetValue(int nIndex, const WCHAR *pszValue);

Sets the value of a specific attribute.

Parameters:
nIndex - the index of the attribute (zero-based)
pszType - the attribute's value

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.