1.1 --- a/epoc32/include/cnode.inl Wed Mar 31 12:27:01 2010 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,576 +0,0 @@
1.4 -/// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -/// All rights reserved.
1.6 -/// This component and the accompanying materials are made available
1.7 -/// 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.8 -/// which accompanies this distribution, and is available
1.9 -/// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -///
1.11 -/// Initial Contributors:
1.12 -/// Nokia Corporation - initial contribution.
1.13 -///
1.14 -/// Contributors:
1.15 -///
1.16 -/// Description:
1.17 -/// All rights reserved.
1.18 -/// This component and the accompanying materials are made available
1.19 -/// 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.20 -/// which accompanies this distribution, and is available
1.21 -/// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.22 -/// Initial Contributors:
1.23 -/// Nokia Corporation - initial contribution.
1.24 -/// Contributors:
1.25 -///
1.26 -
1.27 -_LIT(KWapBaseNodePanic,"Node-Panic");
1.28 -
1.29 -#ifndef __WAP_MONOLITHIC__
1.30 -
1.31 -void Panic(TNodePanic aPanic)
1.32 -//
1.33 -// Panic the client program.
1.34 -//
1.35 - {
1.36 - User::Panic(KWapBaseNodePanic,aPanic);
1.37 - }
1.38 -#endif
1.39 -
1.40 -//
1.41 -// INLINED Node implementation
1.42 -// for description of templated api's see CNODE.H
1.43 -//
1.44 -
1.45 -//CTOR of non-deletable data
1.46 -/** Constructor.
1.47 -
1.48 -@param aData Buffer to wrap
1.49 -*/
1.50 -inline CDataNoDelete::CDataNoDelete(HBufC16* aData)
1.51 - : iData(aData)
1.52 - {
1.53 - }
1.54 -
1.55 -//DTOR doesn't delete the data member
1.56 -/** Destructor.
1.57 -
1.58 -The wrapped buffer is not deleted.
1.59 -*/
1.60 -inline CDataNoDelete::~CDataNoDelete()
1.61 - {
1.62 - }
1.63 -
1.64 -//Accessor method to set the iData pointer to the parameter passed in
1.65 -//Ownership is taken here
1.66 -// Returns the previous value
1.67 -/** Changes the buffer that is wrapped.
1.68 -
1.69 -@return The previous wrapped buffer
1.70 -@param aData Buffer to wrap
1.71 -*/
1.72 -inline HBufC16* CDataNoDelete::SetData(HBufC16* aData)
1.73 - {
1.74 - HBufC16* prevVal = iData;
1.75 - iData = aData;
1.76 - return prevVal;
1.77 - }
1.78 -
1.79 -//Resets data pointer to point to aData, data is not deleted
1.80 -/** Sets the buffer that is wrapped.
1.81 -
1.82 -The existing value is forgotten.
1.83 -
1.84 -@param aData Buffer to wrap
1.85 -*/
1.86 -inline void CDataNoDelete::ResetDataPointer(HBufC16 *aData)
1.87 - {
1.88 - iData = aData;
1.89 - }
1.90 -
1.91 -//Accessor method to get the data
1.92 -/** Gets the wrapped buffer.
1.93 -
1.94 -@return The wrapped buffer
1.95 -*/
1.96 -inline HBufC16* CDataNoDelete::Data()
1.97 - {
1.98 - return iData;
1.99 - }
1.100 -
1.101 -//CTOR of deletable data
1.102 -/** Constructor.
1.103 -
1.104 -@param aData Buffer to wrap
1.105 -*/
1.106 -inline CDataDelete::CDataDelete(HBufC16* aData)
1.107 - : CDataNoDelete(aData)
1.108 - {
1.109 - }
1.110 -
1.111 -//DTOR of deletable data...DELETES THE DATA
1.112 -/** Destructor.
1.113 -
1.114 -The wrapped buffer is deleted.
1.115 -*/
1.116 -inline CDataDelete::~CDataDelete()
1.117 - {
1.118 - delete iData;
1.119 - }
1.120 -
1.121 -/** Sets the buffer that is wrapped.
1.122 -
1.123 -The existing value is deleted.
1.124 -
1.125 -@param aData Buffer to wrap
1.126 -*/
1.127 -inline void CDataDelete::ResetDataPointer(HBufC16* aData)
1.128 - {
1.129 - delete iData;
1.130 - iData = aData;
1.131 - }
1.132 -
1.133 -//CTOR of deletable file data
1.134 -/** Constructor.
1.135 -
1.136 -@param aData Buffer to wrap
1.137 -*/
1.138 -inline CFileDataDelete::CFileDataDelete(HBufC16* aData)
1.139 - : CDataNoDelete(aData)
1.140 - {
1.141 - }
1.142 -
1.143 -// DTOR of deletable file data...
1.144 -// DELETES THE DATA AFTER REMOVING THE REFERENCED FILE
1.145 -/** Destructor.
1.146 -
1.147 -It deletes the filename buffer and the file itself.
1.148 -*/
1.149 -inline CFileDataDelete::~CFileDataDelete()
1.150 - {
1.151 - RemoveFile();
1.152 - delete iData;
1.153 - }
1.154 -
1.155 -/** Sets the filename that is wrapped.
1.156 -
1.157 -The existing filename buffer and the file itself are deleted.
1.158 -
1.159 -@param aData Buffer to wrap
1.160 -*/
1.161 -inline void CFileDataDelete::ResetDataPointer(HBufC16* aData)
1.162 - {
1.163 - RemoveFile();
1.164 - delete iData;
1.165 - iData = aData;
1.166 - }
1.167 -
1.168 -inline void CFileDataDelete::RemoveFile()
1.169 - {
1.170 - // When this panics
1.171 - // Someone somewhere has incorrectly reset this node's data
1.172 - __ASSERT_DEBUG(iData,Panic(ENoData));
1.173 - RFs fs;
1.174 - // If connect fails we can sadly do nothing to remove the file
1.175 - // it will be left lying around :-<
1.176 - if(fs.Connect() == KErrNone)
1.177 - {
1.178 - fs.Delete(iData->Des());
1.179 - fs.Close();
1.180 - }
1.181 - }
1.182 -
1.183 -//CTOR of wrapper for integer attributes
1.184 -/** Constructor.
1.185 -
1.186 -@param aInteger Integer to wrap
1.187 -*/
1.188 -inline CIntAttribute::CIntAttribute(TInt aInteger)
1.189 - : iInteger(aInteger)
1.190 - {
1.191 - }
1.192 -
1.193 -//Accessor method
1.194 -/** Gets the wrapped integer.
1.195 -
1.196 -@return The wrapped integer
1.197 -*/
1.198 -inline TInt CIntAttribute::Int() const
1.199 - {
1.200 - return iInteger;
1.201 - }
1.202 -
1.203 -
1.204 -//
1.205 -//
1.206 -//TEMPLATED FUNCTIONS SEE CNODE.H FOR DESCRIPTIONS OF API'S
1.207 -//
1.208 -//
1.209 -/** Allocates and constructs a new node.
1.210 -
1.211 -@return New node
1.212 -@param aType The type of the node
1.213 -@param aParent The parent of this node
1.214 -*/
1.215 -template <class TNodeType, class TAttributeType>
1.216 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::NewL(TNodeType aType, CNode* aParent)
1.217 - {
1.218 - return (STATIC_CAST(CTypedNode*,CNode::NewL(CONST_CAST(TAny*,REINTERPRET_CAST(const TAny*,aType)),aParent)));
1.219 - }
1.220 -
1.221 -
1.222 -template <class TNodeType, class TAttributeType>
1.223 -inline CTypedNode<TNodeType, TAttributeType>::CTypedNode(TNodeType aType, CNode* aParent)
1.224 - : CNode(CONST_CAST(TAny*,REINTERPRET_CAST(const TAny*,aType)),aParent)
1.225 - {}
1.226 -
1.227 -/** Deletes a specified child node.
1.228 -
1.229 -@param aNode Node to delete
1.230 -*/
1.231 -template <class TNodeType, class TAttributeType>
1.232 -inline void CTypedNode<TNodeType, TAttributeType>::DeleteChildNode(CNode* aNode)
1.233 - {
1.234 - CNode::DeleteChildNode(aNode);
1.235 - }
1.236 -
1.237 -/** Deletes all the child nodes of this node.
1.238 -*/
1.239 -template <class TNodeType, class TAttributeType>
1.240 -inline void CTypedNode<TNodeType, TAttributeType>::DeleteAllChildNodes()
1.241 - {
1.242 - CNode::DeleteAllChildNodes();
1.243 - }
1.244 -
1.245 -/** Creates a new child node.
1.246 -
1.247 -@return The new child node
1.248 -@param aType Node type
1.249 -*/
1.250 -template <class TNodeType, class TAttributeType>
1.251 -inline CTypedNode<TNodeType, TAttributeType>& CTypedNode<TNodeType, TAttributeType>::AppendNodeL(TNodeType aType)
1.252 - {
1.253 - return (STATIC_CAST(CTypedNode& , CNode::AppendNodeL(CONST_CAST(TAny*,REINTERPRET_CAST(TAny*,aType)))));
1.254 - }
1.255 -
1.256 -/** Adds an existing node as a child.
1.257 -
1.258 -@param aNode Node to make a child
1.259 -*/
1.260 -template <class TNodeType, class TAttributeType>
1.261 -inline void CTypedNode<TNodeType, TAttributeType>::AppendNodeToThisNodeL(CNode* aNode)
1.262 - {
1.263 - CNode::AppendNodeToThisNodeL(aNode);
1.264 - }
1.265 -
1.266 -/** Gets the first child or the next child after a specified child.
1.267 -
1.268 -@return First or next child node
1.269 -@param aNode Child node or NULL to get the first child
1.270 -*/
1.271 -template <class TNodeType, class TAttributeType>
1.272 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::NextChild(const CNode* aNode) const
1.273 - {
1.274 - return (STATIC_CAST(CTypedNode*,CNode::NextChild(aNode)));
1.275 - }
1.276 -
1.277 -/** Gets the previous child before a specified child.
1.278 -
1.279 -@return Previous child node
1.280 -@param aNode Child node
1.281 -*/
1.282 -template <class TNodeType, class TAttributeType>
1.283 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::PrevChild(const CNode& aNode) const
1.284 - {
1.285 - return (STATIC_CAST(CTypedNode*,CNode::PrevChild(aNode)));
1.286 - }
1.287 -
1.288 -/** Gets the parent of this node.
1.289 -
1.290 -@return Parent
1.291 -*/
1.292 -template <class TNodeType, class TAttributeType>
1.293 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::Parent() const
1.294 - {
1.295 - return (STATIC_CAST(CTypedNode*,CNode::Parent()));
1.296 - }
1.297 -
1.298 -/** Changes the parent of the node.
1.299 -
1.300 -The node is removed from the childlist of its current parent.
1.301 -
1.302 -@param aParent New parent
1.303 -*/
1.304 -template <class TNodeType, class TAttributeType>
1.305 -inline void CTypedNode<TNodeType, TAttributeType>::ReparentL(CNode* aParent)
1.306 - {
1.307 - CNode::ReparentL(aParent);
1.308 - }
1.309 -
1.310 -/** Gets the next sibling node.
1.311 -
1.312 -This asks for the next child of its parent.
1.313 -
1.314 -@return Next sibling node
1.315 -*/
1.316 -template <class TNodeType, class TAttributeType>
1.317 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::NextSibling() const
1.318 - {
1.319 - return (STATIC_CAST(CTypedNode*,CNode::NextSibling()));
1.320 - }
1.321 -
1.322 -/** Gets the previous sibling node.
1.323 -
1.324 -This asks for the previous child of its parent.
1.325 -
1.326 -@return Previous sibling node
1.327 -*/
1.328 -template <class TNodeType, class TAttributeType>
1.329 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::PrevSibling() const
1.330 - {
1.331 - return (STATIC_CAST(CTypedNode*,CNode::PrevSibling()));
1.332 - }
1.333 -
1.334 -/** Gets the number of children of this node.
1.335 -
1.336 -@return Number of children of this node
1.337 -*/
1.338 -template <class TNodeType, class TAttributeType>
1.339 -inline TInt CTypedNode<TNodeType, TAttributeType>::NumberImmediateChildren() const
1.340 - {
1.341 - return (CNode::NumberImmediateChildren());
1.342 - }
1.343 -
1.344 -/** Gets the absolute root node of the tree.
1.345 -
1.346 -@return Root node
1.347 -*/
1.348 -template <class TNodeType, class TAttributeType>
1.349 -inline const CTypedNode<TNodeType, TAttributeType>& CTypedNode<TNodeType, TAttributeType>::Root() const
1.350 - {
1.351 - return (STATIC_CAST(const CTypedNode&,CNode::Root()));
1.352 - }
1.353 -
1.354 -/** Sets the node data.
1.355 -
1.356 -The object will delete the data in its destructor.
1.357 -
1.358 -@param aData Node data
1.359 -*/
1.360 -template <class TNodeType, class TAttributeType>
1.361 -inline void CTypedNode<TNodeType, TAttributeType>::SetDataL(HBufC16 *aData)
1.362 - {
1.363 - CNode::SetDataL(aData);
1.364 - }
1.365 -
1.366 -/** Sets the object not to delete the node data in its destructor.
1.367 -
1.368 -Note that the function internally reallocates memory. If it leaves, the data is lost.
1.369 - */
1.370 -template <class TNodeType, class TAttributeType>
1.371 -inline void CTypedNode<TNodeType, TAttributeType>::SetDataNoDeleteL()
1.372 - {
1.373 - CNode::SetDataNoDeleteL();
1.374 - }
1.375 -
1.376 -/** Sets the object to delete the node data in its destructor.
1.377 -
1.378 -Note that the function internally reallocates memory. If it leaves, the data is lost. */
1.379 -template <class TNodeType, class TAttributeType>
1.380 -inline void CTypedNode<TNodeType, TAttributeType>::ClearSetDataNoDeleteL()
1.381 - {
1.382 - CNode::ClearSetDataNoDeleteL();
1.383 - }
1.384 -
1.385 -/** Sets the node data to be taken from a specified file.
1.386 -
1.387 -If the data is deleted, the referenced file is also deleted.
1.388 -
1.389 -@param aData Name of the file containing the data
1.390 -*/
1.391 -template <class TNodeType, class TAttributeType>
1.392 -inline void CTypedNode<TNodeType, TAttributeType>::SetFileDataL(HBufC16 *aData)
1.393 - {
1.394 - CNode::SetFileDataL(aData);
1.395 - }
1.396 -
1.397 -/** Resets the node data to a specified pointer.
1.398 -
1.399 -Existing data owned by the node is deleted.
1.400 -
1.401 -@param aData Root node
1.402 -*/
1.403 -template <class TNodeType, class TAttributeType>
1.404 -inline void CTypedNode<TNodeType, TAttributeType>::ResetDataPointer(HBufC16* aData)
1.405 - {
1.406 - CNode::ResetDataPointer(aData);
1.407 - }
1.408 -
1.409 -/** Gets the node data.
1.410 -
1.411 -@return Node data or NULL if no data is set
1.412 -*/
1.413 -template <class TNodeType, class TAttributeType>
1.414 -inline HBufC16* CTypedNode<TNodeType, TAttributeType>::Data() const
1.415 - {
1.416 - return (CNode::Data());
1.417 - }
1.418 -
1.419 -/** Deletes an attribute of a specified type.
1.420 -
1.421 -Note that the attribute value will be deleted.
1.422 -
1.423 -@param aAttributeType Attribute type
1.424 -*/
1.425 -template <class TNodeType, class TAttributeType>
1.426 -inline void CTypedNode<TNodeType, TAttributeType>::DeleteAttribute(TAttributeType aAttributeType)
1.427 - {
1.428 - CNode::DeleteAttribute(CONST_CAST(TAny*, REINTERPRET_CAST(const TAny*,aAttributeType)));
1.429 - }
1.430 -
1.431 -/** Delete all node attributes.
1.432 -
1.433 -Note that attribute values will be deleted.
1.434 -*/
1.435 -template <class TNodeType, class TAttributeType>
1.436 -inline void CTypedNode<TNodeType, TAttributeType>::DeleteAllAttributes()
1.437 - {
1.438 - CNode::DeleteAllAttributes();
1.439 - }
1.440 -
1.441 -/** Removes an attribute of a specified type, but does not delete it.
1.442 -
1.443 -The caller is now responsible for the destruction of the attribute value.
1.444 -
1.445 -@param aAttributeType Attribute type
1.446 -*/
1.447 -template <class TNodeType, class TAttributeType>
1.448 -inline void CTypedNode<TNodeType, TAttributeType>::RemoveAttributeNoDelete(TAttributeType aAttributeType)
1.449 - {
1.450 - CNode::RemoveAttributeNoDelete(CONST_CAST(TAny*,REINTERPRET_CAST(const TAny*,aAttributeType)));
1.451 - }
1.452 -
1.453 -/** Gets the number of attributes of this node.
1.454 -
1.455 -@return Number of attributes of this node
1.456 -*/
1.457 -template <class TNodeType, class TAttributeType>
1.458 -inline TInt CTypedNode<TNodeType, TAttributeType>::AttributeCount() const
1.459 - {
1.460 - return(CNode::AttributeCount());
1.461 - }
1.462 -
1.463 -/** Gets the attribute value of an attribute at a specified index
1.464 -
1.465 -@return Attribute value
1.466 -@param aIndex Attribute index
1.467 -*/
1.468 -template <class TNodeType, class TAttributeType>
1.469 -inline TAttributeType CTypedNode<TNodeType, TAttributeType>::AttributeTypeByIndex(TInt aIndex) const
1.470 - {
1.471 - return(REINTERPRET_CAST(TAttributeType, CNode::AttributeTypeByIndex(aIndex)));
1.472 - }
1.473 -
1.474 -/** Gets the attribute value of an attribute at a specified index
1.475 -
1.476 -@return Attribute value
1.477 -@param aIndex Attribute index
1.478 -*/
1.479 -template <class TNodeType, class TAttributeType>
1.480 -inline CBase* CTypedNode<TNodeType, TAttributeType>::AttributeByIndex(TInt aIndex) const
1.481 - {
1.482 - return(CNode::AttributeByIndex(aIndex));
1.483 - }
1.484 -
1.485 -/** Gets the attribute value and type of an attribute at a specified index..
1.486 -
1.487 -@return Attribute value
1.488 -@param aIndex Attribute index
1.489 -@param aType On return, the attribute type
1.490 -*/
1.491 -template <class TNodeType, class TAttributeType>
1.492 -inline CBase* CTypedNode<TNodeType, TAttributeType>::AttributeByIndex(TInt aIndex,TAttributeType& aType) const
1.493 - {
1.494 - TAny* type;
1.495 - CBase* ret=CNode::AttributeByIndex(aIndex,type);
1.496 - aType=REINTERPRET_CAST(TAttributeType, type);
1.497 - return ret;
1.498 - }
1.499 -
1.500 -/** Adds an attribute.
1.501 -
1.502 -The node takes ownership of aAttributeValue.
1.503 -
1.504 -@param aAttributeType Attribute type
1.505 -@param aAttributeValue Attribute value
1.506 -*/
1.507 -template <class TNodeType, class TAttributeType>
1.508 -inline void CTypedNode<TNodeType, TAttributeType>::AddAttributeL(TAttributeType aAttributeType, CBase* aAttributeValue)
1.509 - {
1.510 - CNode::AddAttributeL(CONST_CAST(TAny*, REINTERPRET_CAST(const TAny*,aAttributeType)),aAttributeValue);
1.511 - }
1.512 -
1.513 -/** Sets node data and adds an attribute.
1.514 -
1.515 -The node takes ownership of aDataand aAttributeValue.
1.516 -Existing node data owned by the node is deleted.
1.517 -
1.518 -@param aData Node data
1.519 -@param aAttributeType Attribute type
1.520 -@param aAttributeValue Attribute value
1.521 -*/
1.522 -template <class TNodeType, class TAttributeType>
1.523 -inline void CTypedNode<TNodeType, TAttributeType>::AddDataAndAttributeL(HBufC16 *aData, TAttributeType aAttributeType, CBase* aAttributeValue)
1.524 - {
1.525 - CNode::AddDataAndAttributeL(aData,CONST_CAST(TAny*, REINTERPRET_CAST(const TAny*,aAttributeType)),aAttributeValue);
1.526 - }
1.527 -
1.528 -/** Gets a child node by index.
1.529 -
1.530 -@return Child node
1.531 -@param aByIndex Index of the child node
1.532 -*/
1.533 -template <class TNodeType, class TAttributeType>
1.534 -inline CTypedNode<TNodeType, TAttributeType>* CTypedNode<TNodeType, TAttributeType>::Child(TInt aByIndex) const
1.535 - {
1.536 - return (REINTERPRET_CAST(CTypedNode*,CNode::Child(aByIndex)));
1.537 - }
1.538 -
1.539 -/** Gets an attribute value for a specified attribute type.
1.540 -
1.541 -@return Attribute value
1.542 -@param aAttributeType Attribute type
1.543 -*/
1.544 -template <class TNodeType, class TAttributeType>
1.545 -inline CBase* CTypedNode<TNodeType, TAttributeType>::Attribute(TAttributeType aAttributeType) const
1.546 - {
1.547 - return (CNode::Attribute(CONST_CAST(TAny*, REINTERPRET_CAST(const TAny*,aAttributeType))));
1.548 - }
1.549 -
1.550 -/** Tests if an attribute of a specified type exists.
1.551 -
1.552 -@return True if the attribute exists, otherwise false
1.553 -@param aAttributeType Attribute type
1.554 -*/
1.555 -template <class TNodeType, class TAttributeType>
1.556 -inline TBool CTypedNode<TNodeType, TAttributeType>::AttributeExists(TAttributeType aAttributeType) const
1.557 - {
1.558 - return (CNode::AttributeExists(CONST_CAST(TAny*, REINTERPRET_CAST(const TAny*,aAttributeType))));
1.559 - }
1.560 -
1.561 -/** Gets the node type.
1.562 -
1.563 -@return Node type
1.564 -*/
1.565 -template <class TNodeType, class TAttributeType>
1.566 -inline TNodeType CTypedNode<TNodeType, TAttributeType>::Type() const
1.567 - {
1.568 - return (REINTERPRET_CAST(TNodeType,CNode::Type()));
1.569 - }
1.570 -
1.571 -/** Sets the node type.
1.572 -
1.573 -@param aType Node type
1.574 -*/
1.575 -template <class TNodeType, class TAttributeType>
1.576 -inline void CTypedNode<TNodeType, TAttributeType>::SetType(TNodeType aType)
1.577 - {
1.578 - CNode::SetType(CONST_CAST(TAny*,REINTERPRET_CAST(const TAny* ,aType)));
1.579 - }