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