epoc32/include/xml/dom/xmlengattr.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/xmlengattr.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:       Attribute node functions
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
#ifndef XMLENGINE_ATTR_H_INCLUDED
williamr@2
    25
#define XMLENGINE_ATTR_H_INCLUDED
williamr@2
    26
williamr@2
    27
#include "xmlengnode.h"
williamr@2
    28
williamr@2
    29
/**
williamr@2
    30
 * Instance of TXmlEngAttr class represents an XML attribute in the DOM tree.
williamr@2
    31
 * 
williamr@2
    32
 * Is a storage attributes properties. Implements DOM action for it.
williamr@2
    33
 * 
williamr@2
    34
 * @lib XmlEngineDOM.lib
williamr@2
    35
 * @since S60 v3.1
williamr@2
    36
 */
williamr@2
    37
class TXmlEngAttr : public TXmlEngNode
williamr@2
    38
{
williamr@2
    39
  public:
williamr@2
    40
    /**
williamr@2
    41
     * Default constructor
williamr@2
    42
     *
williamr@2
    43
     * @since S60 v3.1
williamr@2
    44
     */
williamr@2
    45
    inline TXmlEngAttr();
williamr@2
    46
williamr@2
    47
williamr@2
    48
    /**
williamr@2
    49
     * Clones attribute node
williamr@2
    50
     *
williamr@2
    51
     * @since S60 v3.1
williamr@2
    52
     * @return A copy of the attribute with its value
williamr@2
    53
     *
williamr@2
    54
     * @note Namespace of the attribute is reset; use 
williamr@2
    55
     * TXmlEngNode::CopyToL(TXmlEngNode), which finds appropriate or creates
williamr@2
    56
     * new namespace declaration on the new parent node (argument should be
williamr@2
    57
     * an TXmlEngElement handle)
williamr@2
    58
     *
williamr@2
    59
     * @see CopyToL(TXmlEngNode)
williamr@2
    60
     */
williamr@2
    61
    IMPORT_C TXmlEngAttr CopyL() const;
williamr@2
    62
williamr@2
    63
    /**
williamr@2
    64
     * Get owner element
williamr@2
    65
     *
williamr@2
    66
     * @since S60 v3.1
williamr@2
    67
     * @return TXmlEngElement that contains the attribute
williamr@2
    68
     *
williamr@2
    69
     * Same as TXmlEngNode::ParentNode() but returns TXmlEngElement 
williamr@2
    70
     * instead of TXmlEngNode.
williamr@2
    71
     *
williamr@2
    72
     * @note Copies of attributes [TXmlEngAttr::CopyL()] and newly created 
williamr@2
    73
     * attribute nodes [RXmlEngDocument::CreateAttributeL(..)] do not have 
williamr@2
    74
     * parent element until they are attached to some element.
williamr@2
    75
     */
williamr@2
    76
    IMPORT_C const TXmlEngElement OwnerElement() const;
williamr@2
    77
williamr@2
    78
    /**
williamr@2
    79
     * Check attribute name.
williamr@2
    80
     *
williamr@2
    81
     * @since S60 v3.1
williamr@2
    82
     * @return Local name of the attribute
williamr@2
    83
     *
williamr@2
    84
     * @note Equal to TXmlEngNode::Name(), but works faster.
williamr@2
    85
     *
williamr@2
    86
     * Never call this on NULL object!
williamr@2
    87
     * @see TXmlEngNode::Name()
williamr@2
    88
     */
williamr@2
    89
    IMPORT_C TPtrC8 Name() const;
williamr@2
    90
williamr@2
    91
    /**
williamr@2
    92
     * Get element value.
williamr@2
    93
     *
williamr@2
    94
     * @since S60 v3.1
williamr@2
    95
     * @return Attribute's contents
williamr@2
    96
     *
williamr@2
    97
     * @note For values consisting of more then one TXmlEngTextNode node 
williamr@2
    98
     * (as attribute's child) returns only the begining of the value; 
williamr@2
    99
     * this happens when the value is represented by list of TXmlEngTextNode
williamr@2
   100
     * and TXmlEngEntityReference nodes.
williamr@2
   101
     * 
williamr@2
   102
     * @see IsSimpleContents(), WholeValueCopyL()
williamr@2
   103
     */
williamr@2
   104
    IMPORT_C TPtrC8 Value() const; 
williamr@2
   105
williamr@2
   106
    /**
williamr@2
   107
     * Get copy of attribute content
williamr@2
   108
     *
williamr@2
   109
     * @since S60 v3.1
williamr@2
   110
     * @return Complex value of the attribute,
williamr@2
   111
     *     probably consisting of text nodes and entity references
williamr@2
   112
     *
williamr@2
   113
     * Since the value may be composed from a set of TXmlEngTextNode
williamr@2
   114
     * and EntityRefernce nodes, the returned result is newly allocated 
williamr@2
   115
     * string, which should be freed by caller.
williamr@2
   116
     * 
williamr@2
   117
     * <B style="color: red">BE SURE TO FREE THE RESULT STRING!!!</B>
williamr@2
   118
     *
williamr@2
   119
     * Example usage of the API:
williamr@2
   120
     * @code
williamr@2
   121
     *    RBuf8 value;
williamr@2
   122
	 *    attr.WholeValueCopyL(value);
williamr@2
   123
     *    ...
williamr@2
   124
     *    value.Close();
williamr@2
   125
     * @endcode
williamr@2
   126
     *
williamr@2
   127
     * @see TXmlEngAttr::Value(), TXmlEngNode::Value(),
williamr@2
   128
     * TXmlEngNode::IsSimpleTextContents(), 
williamr@2
   129
     * TXmlEngNode::WholeTextContentsCopyL()
williamr@2
   130
     *
williamr@2
   131
     * @note In most cases using Value() is enough (and it needs no memory allocation).
williamr@2
   132
     *     Use IsSimpleTextContents() if there doubts can Value() be used or not safely.
williamr@2
   133
     */
williamr@2
   134
    IMPORT_C void WholeValueCopyL(RBuf8& aBuffer) const;
williamr@2
   135
williamr@2
   136
    /**
williamr@2
   137
     * Sets new value of the attribute. Provided new value will be escaped 
williamr@2
   138
     * as needed.
williamr@2
   139
     *
williamr@2
   140
	 * @ since S60 v3.1
williamr@2
   141
     * @param aNewValue A string value for the attribute
williamr@2
   142
     *
williamr@2
   143
     * The new value should not contain entity references. 
williamr@2
   144
     * Entity references are not expanded, but used as text, because 
williamr@2
   145
     * the ampersand (&) character of reference is escaped.
williamr@2
   146
     *
williamr@2
   147
     * @see SetEscapedValueL(const TDesC8&)
williamr@2
   148
     */
williamr@2
   149
    IMPORT_C void SetValueL(const TDesC8& aNewValue);
williamr@2
   150
williamr@2
   151
    /**
williamr@2
   152
     * Sets new value from escaped XML character data that may contain 
williamr@2
   153
     * entity references.
williamr@2
   154
     *
williamr@2
   155
     * The value as if it is an escaped contents from XML file.
williamr@2
   156
     * If the value contains entity references, then the resulting
williamr@2
   157
     * content of the attribute is a list of TXmlEngTextNode 
williamr@2
   158
     * and TXmlEngEntityRefeerence nodes.
williamr@2
   159
     * Predefined entities are converted into characters they represent.
williamr@2
   160
     * 
williamr@2
   161
     * @param aNewValue is a new attribute value
williamr@2
   162
     * @since S60 v3.1
williamr@2
   163
     *
williamr@2
   164
     * @see TXmlEngAttr::SetValueL(const TDesC8&)
williamr@2
   165
     */
williamr@2
   166
    IMPORT_C void SetEscapedValueL(const TDesC8& aNewValue);
williamr@2
   167
williamr@2
   168
	/**
williamr@2
   169
	 * Sets new attribute value exactly as presented in the string.
williamr@2
   170
	 *
williamr@2
   171
	 * Predefined entities are not converted into characters they represent.
williamr@2
   172
	 *
williamr@2
   173
     * @param aNewValue is a new attribute value 
williamr@2
   174
     * @since S60 v3.2
williamr@2
   175
     *
williamr@2
   176
     * @see TXmlEngAttr::SetValueL(const TDesC8&)
williamr@2
   177
     */
williamr@2
   178
	IMPORT_C void SetValueNoEncL(const TDesC8& aNewValue );
williamr@2
   179
williamr@2
   180
protected:
williamr@2
   181
    /**
williamr@2
   182
     * Constructor
williamr@2
   183
     *
williamr@2
   184
     * @since S60 v3.1
williamr@2
   185
     * @param aInternal attribute pointer
williamr@2
   186
     */
williamr@2
   187
    inline TXmlEngAttr(void* aInternal);
williamr@2
   188
};
williamr@2
   189
williamr@2
   190
#include "xmlengattr.inl"
williamr@2
   191
williamr@2
   192
#endif /* XMLENGINE_ATTR_H_INCLUDED */