convert OFString into string

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

convert OFString into string

#1 Post by juan_7_89 »

Hello! I don't know how to do it. Can anyone help me?
This is my code:
//NOMBRE DEL PACIENTE!
OFString Nombre_P;

//tratamos de recuperar el nombre del paciente
if (FileFormat.getDataset()->findAndGetOFString(DCM_PatientName, Nombre_P).good())
{
cout << "Nombre del paciente: " << Nombre_P << endl;
} else
cerr << "Error: No se puede acceder al nombre del paciente!" << endl;

string nombre=Nombre_P;
//or
//string nombre(Nombre_P);
Thanks

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

Re: convert OFString into string

#2 Post by J. Riesmeier »

Are you talking about std::string? Compile with HAVE_STD_STRING and OFString is identical to this class. See macros.txt for details.

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: convert OFString into string

#3 Post by juan_7_89 »

Yes i'm talking about that!

But if a use that i get errors with this funcion:
FileFormat.getDataset()->findAndGetOFString(DCM_PatientID,ID_P)
undefined reference to 'DcmItem::findAndGetOFString(DcmTagKey const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long, bool)'

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

Re: convert OFString into string

#4 Post by J. Riesmeier »

Did you recompile the entire DCMTK (after "make clean")?

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: convert OFString into string

#5 Post by juan_7_89 »

What do you mean with recompile the entire DCMTK?

I have only add -DHAVE_STD_STRING to the flags.

This is my makefile:
GPP=g++
GCC=gcc
FLAGS= -fshow-column -g2 -Wall -O0 -Wall -pedantic-errors -DHAVE_CONFIG_H -DHAVE_STD_STRING -O0 -D_DEBUG
LIBS= -L/usr/local/lib -L/usr/local/include -ldcmjpeg -lijg8 -lijg12 -lijg16 -ldcmimgle -ldcmimage -ldcmjpls -ldcmdata -loflog -lofstd -lz -lpthread -lm -lX11
OBJS=Debug/main.o

all: Debug Debug/ImgDicom.bin

clean:
rm -rf ${OBJS} Debug/ImgDicom.bin

Debug/ImgDicom.bin: ${OBJS}
${GPP} ${OBJS} ${LIBS} -o $@

Debug:
mkdir Debug

Debug/main.o: main.cpp imgDicom.cpp imgDicom.h
${GPP} ${FLAGS} -c main.cpp -o $@

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

Re: convert OFString into string

#6 Post by J. Riesmeier »

With "recompile" I mean: Specify the additonal compiler flag and compile the entire DCMTK from scratch, i.e. create all the DCMTK libraries from source code.

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: convert OFString into string

#7 Post by juan_7_89 »

Thanks, I understand now.

I'm new in this. How do i specify the aditional compiler flag? I don't know where i have to do it.

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

Re: convert OFString into string

#8 Post by J. Riesmeier »

After running ./configure, you should add "-DHAVE_STD_STRING" to the file "config/Makefile.def" and then recompile.

juan_7_89
Posts: 15
Joined: Sat, 2013-06-15, 05:52

Re: convert OFString into string

#9 Post by juan_7_89 »

I know it's a bit late but thanks.
Do you mean CPPFLAGS =-DHAVE_STD_STRING?

Thank you again.

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

Re: convert OFString into string

#10 Post by J. Riesmeier »

No, I meant you should add the define to "GLOBALDEFS =" in the "dcmtk/config/Makefile.def".

Post Reply

Who is online

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