findAndGetOFString() truncates backslashes in tag data?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
AlreadyGoogled
Posts: 17
Joined: Wed, 2005-01-26, 16:43

findAndGetOFString() truncates backslashes in tag data?

#1 Post by AlreadyGoogled »

Hi everyone,

I was using findAndGetOFString() to fetch ImagePosition/PixelSpacing tags, these tags have backslashes delimiting different portions of the data within the tag. But my returned OFString only contains the data up to the first backslash in the tag data!

If I use findAndGetString() it works fine. My question is, do I need to free the character pointer I pass to findAndGetString(), or is this done for me?

Code: Select all


void something()
{
    char *pszPixelSpacing;

    if (!(*imageDataSet)->findAndGetOFString(DCM_PixelSpacing, pszPixelSpacing).good()) {
        return;
    }

    // Must I delete [] pszPixelSpacing here when I'm done, or is this not necessary?            
}
Or maybe there is a flag I can turn on to tell findAndGetOFString() to please not truncate at the first backslash encountered?

Thanks!
________
Video Review
Last edited by AlreadyGoogled on Sun, 2011-02-13, 00:31, edited 1 time in total.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

Seems that you did not read the documentation ...

First of all, findAndGetOFString() fills a given OFString (C++ string) with the requested value, i.e. you do not pass a "char *". Furthermore, there is a parameter "pos" for findAndGetOFString() that allows to specify which value (in case of value multiplicity) should be copied to the resulting OFString.

The method findAndgetString() returns a reference to a C string, i.e. the memory is handled internally. You will not be able to delete the C string because the variable is declared "const". In case you need a copy of the complete element value you should try findAndGetOFStringArray().

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest