Gareth,

Tried sending this on Friday & again on Monday. Not seen it appear though.

Martin.

-----Original Message-----
From: Ebourne, Martin 
Sent: 02 December 2002 14:37
To: '[EMAIL PROTECTED]'
Subject: Const-correctness in Xerces


Hi,

Currently Xerces is only const-correct for the current object, not
the whole DOM.

ie. you can do:

const DOMNode* constNode = ...;
DOMNode* nonConstChild = constNode->getFirstChild();
DOMNode* nonConstNode = nonConstChild->getParentNode();

which breaks the const correctness.

It would be nice if the const-correctness was carried through to the
whole DOM. This would prevent the above (maybe accidental) code.

To do that you'd need to change all of the navigation methods like
so:

Take 'virtual DOMNode* getParentNode() const' and change it to
'virtual DOMNode* getParentNode()', then add
'virtual const DOMNode* getParentNode() const' which simply
does 'return const_cast<DOMNode*>(this)->getParentNode();'

Alternatively you could get the non-const one to call the const
one, which would probably be better since then the compiler would be
able to check the constness of the internals of the function.

In order to not have any performance overhead you could make the
'const DOMNode* getParentNode() const' non-virtual and inline,
defined only in the base class. This prevents a derived class from
overriding it, but that may be a good thing - after all we need
to guarantee the const/non-const versions do the same thing!

Any thoughts on this? The main disadvantage I can see with it is
it wouldn't be much fun to implement (although I dare say Perl could
find a use in here somewhere). Oh, also it might break some broken
code.

Cheers,

Martin.

This message is for the named person's use only. It may contain sensitive and private 
proprietary or legally privileged information. No confidentiality or privilege is 
waived or lost by any mistransmission. If you are not the intended recipient, please 
immediately delete it and all copies of it from your system, destroy any hard copies 
of it and notify the sender. You must not, directly or indirectly, use, disclose, 
distribute, print, or copy any part of this message if you are not the intended 
recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON 
or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve 
the right to monitor all e-mail communications through its networks. Any views 
expressed in this message are those of the individual sender, except where the message 
states otherwise and the sender is authorized to state them to be the views of any 
such entity.
Unless otherwise stated, any pricing information given in this message is indicative 
only, is subject to change and does not constitute an offer to deal at any price 
quoted. Any reference to the terms of executed transactions should be treated as  
preliminary only and subject to our formal written confirmation.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to