1.1 --- a/epoc32/include/xmlengattr.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/xmlengattr.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,192 @@
1.4 -xmlengattr.h
1.5 +/*
1.6 +* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: Attribute node functions
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +
1.28 +#ifndef XMLENGINE_ATTR_H_INCLUDED
1.29 +#define XMLENGINE_ATTR_H_INCLUDED
1.30 +
1.31 +#include "xmlengnode.h"
1.32 +
1.33 +/**
1.34 + * Instance of TXmlEngAttr class represents an XML attribute in the DOM tree.
1.35 + *
1.36 + * Is a storage attributes properties. Implements DOM action for it.
1.37 + *
1.38 + * @lib XmlEngineDOM.lib
1.39 + * @since S60 v3.1
1.40 + */
1.41 +class TXmlEngAttr : public TXmlEngNode
1.42 +{
1.43 + public:
1.44 + /**
1.45 + * Default constructor
1.46 + *
1.47 + * @since S60 v3.1
1.48 + */
1.49 + inline TXmlEngAttr();
1.50 +
1.51 +
1.52 + /**
1.53 + * Clones attribute node
1.54 + *
1.55 + * @since S60 v3.1
1.56 + * @return A copy of the attribute with its value
1.57 + *
1.58 + * @note Namespace of the attribute is reset; use
1.59 + * TXmlEngNode::CopyToL(TXmlEngNode), which finds appropriate or creates
1.60 + * new namespace declaration on the new parent node (argument should be
1.61 + * an TXmlEngElement handle)
1.62 + *
1.63 + * @see CopyToL(TXmlEngNode)
1.64 + */
1.65 + IMPORT_C TXmlEngAttr CopyL() const;
1.66 +
1.67 + /**
1.68 + * Get owner element
1.69 + *
1.70 + * @since S60 v3.1
1.71 + * @return TXmlEngElement that contains the attribute
1.72 + *
1.73 + * Same as TXmlEngNode::ParentNode() but returns TXmlEngElement
1.74 + * instead of TXmlEngNode.
1.75 + *
1.76 + * @note Copies of attributes [TXmlEngAttr::CopyL()] and newly created
1.77 + * attribute nodes [RXmlEngDocument::CreateAttributeL(..)] do not have
1.78 + * parent element until they are attached to some element.
1.79 + */
1.80 + IMPORT_C const TXmlEngElement OwnerElement() const;
1.81 +
1.82 + /**
1.83 + * Check attribute name.
1.84 + *
1.85 + * @since S60 v3.1
1.86 + * @return Local name of the attribute
1.87 + *
1.88 + * @note Equal to TXmlEngNode::Name(), but works faster.
1.89 + *
1.90 + * Never call this on NULL object!
1.91 + * @see TXmlEngNode::Name()
1.92 + */
1.93 + IMPORT_C TPtrC8 Name() const;
1.94 +
1.95 + /**
1.96 + * Get element value.
1.97 + *
1.98 + * @since S60 v3.1
1.99 + * @return Attribute's contents
1.100 + *
1.101 + * @note For values consisting of more then one TXmlEngTextNode node
1.102 + * (as attribute's child) returns only the begining of the value;
1.103 + * this happens when the value is represented by list of TXmlEngTextNode
1.104 + * and TXmlEngEntityReference nodes.
1.105 + *
1.106 + * @see IsSimpleContents(), WholeValueCopyL()
1.107 + */
1.108 + IMPORT_C TPtrC8 Value() const;
1.109 +
1.110 + /**
1.111 + * Get copy of attribute content
1.112 + *
1.113 + * @since S60 v3.1
1.114 + * @return Complex value of the attribute,
1.115 + * probably consisting of text nodes and entity references
1.116 + *
1.117 + * Since the value may be composed from a set of TXmlEngTextNode
1.118 + * and EntityRefernce nodes, the returned result is newly allocated
1.119 + * string, which should be freed by caller.
1.120 + *
1.121 + * <B style="color: red">BE SURE TO FREE THE RESULT STRING!!!</B>
1.122 + *
1.123 + * Example usage of the API:
1.124 + * @code
1.125 + * RBuf8 value;
1.126 + * attr.WholeValueCopyL(value);
1.127 + * ...
1.128 + * value.Close();
1.129 + * @endcode
1.130 + *
1.131 + * @see TXmlEngAttr::Value(), TXmlEngNode::Value(),
1.132 + * TXmlEngNode::IsSimpleTextContents(),
1.133 + * TXmlEngNode::WholeTextContentsCopyL()
1.134 + *
1.135 + * @note In most cases using Value() is enough (and it needs no memory allocation).
1.136 + * Use IsSimpleTextContents() if there doubts can Value() be used or not safely.
1.137 + */
1.138 + IMPORT_C void WholeValueCopyL(RBuf8& aBuffer) const;
1.139 +
1.140 + /**
1.141 + * Sets new value of the attribute. Provided new value will be escaped
1.142 + * as needed.
1.143 + *
1.144 + * @ since S60 v3.1
1.145 + * @param aNewValue A string value for the attribute
1.146 + *
1.147 + * The new value should not contain entity references.
1.148 + * Entity references are not expanded, but used as text, because
1.149 + * the ampersand (&) character of reference is escaped.
1.150 + *
1.151 + * @see SetEscapedValueL(const TDesC8&)
1.152 + */
1.153 + IMPORT_C void SetValueL(const TDesC8& aNewValue);
1.154 +
1.155 + /**
1.156 + * Sets new value from escaped XML character data that may contain
1.157 + * entity references.
1.158 + *
1.159 + * The value as if it is an escaped contents from XML file.
1.160 + * If the value contains entity references, then the resulting
1.161 + * content of the attribute is a list of TXmlEngTextNode
1.162 + * and TXmlEngEntityRefeerence nodes.
1.163 + * Predefined entities are converted into characters they represent.
1.164 + *
1.165 + * @param aNewValue is a new attribute value
1.166 + * @since S60 v3.1
1.167 + *
1.168 + * @see TXmlEngAttr::SetValueL(const TDesC8&)
1.169 + */
1.170 + IMPORT_C void SetEscapedValueL(const TDesC8& aNewValue);
1.171 +
1.172 + /**
1.173 + * Sets new attribute value exactly as presented in the string.
1.174 + *
1.175 + * Predefined entities are not converted into characters they represent.
1.176 + *
1.177 + * @param aNewValue is a new attribute value
1.178 + * @since S60 v3.2
1.179 + *
1.180 + * @see TXmlEngAttr::SetValueL(const TDesC8&)
1.181 + */
1.182 + IMPORT_C void SetValueNoEncL(const TDesC8& aNewValue );
1.183 +
1.184 +protected:
1.185 + /**
1.186 + * Constructor
1.187 + *
1.188 + * @since S60 v3.1
1.189 + * @param aInternal attribute pointer
1.190 + */
1.191 + inline TXmlEngAttr(void* aInternal);
1.192 +};
1.193 +
1.194 +#include "xmlengattr.inl"
1.195 +
1.196 +#endif /* XMLENGINE_ATTR_H_INCLUDED */