XMLNode::findPosition explanation

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Marcel Baumann
Posts: 2
Joined: Mon, 2019-05-06, 18:09

XMLNode::findPosition explanation

#1 Post by Marcel Baumann »

Hello,

I have been tasked with documenting the toolkit, where it is not doxygen documented. Now i have come across the XMLNode::findPosition() function and i am a bit lost about how it works. Specifically, what "index" is used for. The function can be found inf ofxml.cc at line 1262, but i will post it here:

Code: Select all

XMLElementPosition XMLNode::findPosition(XMLNodeData *d, int index, XMLElementType xxtype)
{
    if (index<0) return -1;
    int i=0,j=OFstatic_cast(int, ((index<<2)+xxtype)),*o=d->pOrder; while (o[i]!=j) i++; return i;
}
Thanks for any help in advance.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: XMLNode::findPosition explanation

#2 Post by Jan Schlamelcher »

I believe the XML implementation originates from the separate XML parser library here: http://www.applied-mathematics.net/tools/xmlParser.html, therefore, I don't think we can answer this question, you should look up the new version upstream, whether the method is now documented, or send an email to the author Frank Vanden Berghen.

J. Riesmeier
DCMTK Developer
Posts: 2503
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: XMLNode::findPosition explanation

#3 Post by J. Riesmeier »

Marcel, did you read the corresponding comment in the header file "ofxml.h" (line 615):

Code: Select all

// these are functions and structures used internally by the XMLNode class (don't bother about them):
I would strongly recommend not to start with an "external implementation" like the XML parser (aka "ofxml"). Furthermore, I don't think that it makes sense to modify its source code apart from required fixes (bugs, compiler issues, etc.) because it makes it more difficult to update the code in the future.

Jan, the current DCMTK development version already contains the most recent XML parser (version 2.44): http://git.dcmtk.org/?p=dcmtk.git;a=com ... 10a4f770cc

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: XMLNode::findPosition explanation

#4 Post by Jan Schlamelcher »

J. Riesmeier wrote: Wed, 2019-05-08, 09:52 Jan, the current DCMTK development version already contains the most recent XML parser (version 2.44): http://git.dcmtk.org/?p=dcmtk.git;a=com ... 10a4f770cc
Awesome, I did not know we succeeded in keeping things up to date for once ;-).

Marcel Baumann
Posts: 2
Joined: Mon, 2019-05-06, 18:09

Re: XMLNode::findPosition explanation

#5 Post by Marcel Baumann »

J. Riesmeier wrote: Wed, 2019-05-08, 09:52 Marcel, did you read the corresponding comment in the header file "ofxml.h" (line 615):

Code: Select all

// these are functions and structures used internally by the XMLNode class (don't bother about them):
Hi,
I did not. However, i dont want to document the function itself (should have mentioned that :idea: ), but a function ("XMLNode::positionOfText" and other of the same kind (in ofxml.h)) that call that function. These are located above the comment you mentioned but have parameters that are passed as the index parameter to this function. So I tried to write an explanation of what this parameter does, but I dont know what exactly it is used for in this final function call.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest