Here's the problem:

A DOMString object holds a pointer to a DOMStringHandle object, which holds
a pointer to a DOMStringData object, which holds the actual character array
of the string.  DOMString.hpp uses an opaque pointer/Cheshire Cat pattern
to hide the implementation of DOMString. This is good, old-fashioned
information hiding.  But in this case, it hides too much, information that
is crucial to debugging with DOM, namely the contents of the underlying
character array.  Perhaps other platforms are different, but with MSVC++,
you can't see the value of DOMString's in the debugger.  This sucks,
especially for programs like Xalan which use DOMString heavily.

Here's the simple fix:  Move the class declarations for DOMStringHandle and
DOMStringData into DOMString.hpp, from DOMString.cpp.  The diff is appended
below.

In addition, if you make the following changes to your local MSVC++
install, the hover hints will correctly show the value of the strings when
you mouse over it in the debugger:

Microsoft Visual Studio\Common\MSDev98\Bin\AutoExp.dat

;Xerces
DOMString=<fHandle->fDSData->fData,su>

In menu, Tools, Options, on the Debug tab, enable "Display unicode strings"

Try it out and let's see quick +1 on this.  I've been running like this
locally for a while now.

Of course, if we used a standard string class, none of this would be
necessary<g>

-Rob

===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOMString.cpp,v
retrieving revision 1.5
diff -r1.5 DOMString.cpp
105,115d104
< class   DOMStringData
< {
< public:
<     int                 fBufferLength;
<     int                 fRefCount;
<     XMLCh               fData[1];
<
<     static DOMStringData *allocateBuffer(int length);
<     inline void         addRef();
<     inline void         removeRef();
< };
158,178d146
<
< class  DOMStringHandle
< {
< public:
<             int              fLength;
<             int              fRefCount;
<             DOMStringData    *fDSData;
<
<     void    *operator new( size_t sizeToAlloc);
<     void    operator delete( void *pvMem );
< private:
<     static  void *freeListPtr;
< public:
<     static  DOMStringHandle  *createNewStringHandle(int bufLength);
<             DOMStringHandle  *cloneStringHandle();
<     inline  void             addRef();
<     inline  void             removeRef();
<                              ~DOMStringHandle() {};
< private:
<     inline                   DOMStringHandle() {};
< };
Index: DOMString.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DOMString.hpp,v
retrieving revision 1.3
diff -r1.3 DOMString.hpp
84d83
< class DOMStringHandle;
85a85,130
>
> //----------------------------------------------
> //
> //      DOMStringData
> //
> //----------------------------------------------
> class   DOMStringData
> {
> public:
>     int                 fBufferLength;
>     int                 fRefCount;
>     XMLCh               fData[1];
>
>     static DOMStringData *allocateBuffer(int length);
>     inline void         addRef();
>     inline void         removeRef();
> };
>
>
> //----------------------------------------------------
> //
> //      DOMStringHandle
> //
> //-----------------------------------------------------
>
> class  DOMStringHandle
> {
> public:
>             int              fLength;
>             int              fRefCount;
>             DOMStringData    *fDSData;
>
>     void    *operator new( size_t sizeToAlloc);
>     void    operator delete( void *pvMem );
> private:
>     static  void *freeListPtr;
> public:
>     static  DOMStringHandle  *createNewStringHandle(int bufLength);
>             DOMStringHandle  *cloneStringHandle();
>     inline  void             addRef();
>     inline  void             removeRef();
>                              ~DOMStringHandle() {};
> private:
>     inline                   DOMStringHandle() {};
> };
>





Reply via email to