From f26ff7a4f6b6cac83f3bf3740beadc5b21946dd8 Mon Sep 17 00:00:00 2001 From: malaterre Date: Thu, 23 Sep 2004 19:59:19 +0000 Subject: [PATCH] ENH: Initial pass at playing with regex in cmake, to parse dicomV3.dic to stick in gdcm --- Dicts/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/Dicts/CMakeLists.txt b/Dicts/CMakeLists.txt index aec4fa07..a2611547 100644 --- a/Dicts/CMakeLists.txt +++ b/Dicts/CMakeLists.txt @@ -3,8 +3,44 @@ INSTALL_FILES(${GDCM_DATA_DIR} FILES - dicomV3.dic - dicomVR.dic + dicomV3.dic + dicomVR.dic dicomTS.dic DicomDir.dic ) + +# Nice trick to avoid creating a .h file each time we compile gdcm +# Since CONFIGURE_FILE do a 'copy if different' +# We have to write the file here since is contains 'DICOM_DICTIONARY' +# Which is a variable afterward... +#FILE(WRITE "/tmp/output.h.in" "@DICOM_DICTIONARY@" ) + +# Following code contributing by Andy Cedilnik +SET(INFILE "dicomV3.dic") + +FILE(READ "${INFILE}" ENT) + +STRING(REGEX REPLACE "\n" ";" ENT "${ENT}") +SET(DICOM_DICTIONARY +"// +#include \"gdcmDicomDictionaryEntry.h\" + +static gdcmDicomDictionaryEntry[] = +{") + +FOREACH(line ${ENT}) + STRING(REGEX REPLACE + "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ([A-Z]+) ([A-Z]+) (.*)([ \(RET\)]*)$" + " { \\1, \\2, \"\\3\" , \"\\4\" , \"\\5\", \"\\6\"}," nline "${line}") + SET(DICOM_DICTIONARY "${DICOM_DICTIONARY}\n${nline}") +ENDFOREACH(line) + +SET(DICOM_DICTIONARY "${DICOM_DICTIONARY} + 0 +};") + +# See above +#CONFIGURE_FILE("/tmp/output.h.in" "/tmp/output.h") + +#MESSAGE("${DICOM_DICTIONARY}") + -- 2.46.2