Key function: dcmobject * dcmitem: nextincontainer (const dcmobject * OBJ), which is a virtual function in dcmobject and implemented by the dcmitem class. Because the dcmdataset class inherits from dcmitem, therefore, the dcmdataset object can use this method to traverse the tag between 0008-7fe0.
The original code of this function is
Dcmobject * dcmitem: nextincontainer (const dcmobject * OBJ) {If (! OBJ) return elementlist-> get (elp_first); // elementlist is dcmlist *, and else {If (elementlist-> get () in dcmitem ()! = OBJ) {for (dcmobject * search_obj = elementlist-> seek (elp_first); search_obj & search_obj! = OBJ; search_obj = elementlist-> seek (elp_next) {/* do nothing, just keep iterating */} return elementlist-> seek (elp_next );}}
The analysis code shows that:
(1) When nextincontainer (null) is used, a dcmobject pointer is returned. Using the gettag () method of this pointer, A tag1 can be obtained, this tag1 is the first tag with the group number 0008 in the image. (A returned object of nextincontainer (null) is defined here: dcmobject * pobject_tg)
(2) When nextincontainer (pobject_tg) is used, a dcmobject pointer is returned. Similarly, the gettag () method of this pointer can obtain a tag2, this tag2 is the second tag with the group number 0008 in the image. That is, the tag following tag1.
In this way, we can design a simple loop to traverse all the tags between 0008-7fe0.