From b746b4a0b5182b37104616c263f381d78e1af10f Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 3 May 2005 09:43:04 +0000 Subject: [PATCH] Load returns now a bool (allow user not to call IsReadable() ) --- src/gdcmDicomDir.cxx | 12 +++++++----- src/gdcmDicomDir.h | 6 +++--- src/gdcmDocument.cxx | 20 ++++++++++++-------- src/gdcmDocument.h | 6 +++--- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 27b840f2..d8e60efe 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/04/14 14:26:19 $ - Version: $Revision: 1.137 $ + Date: $Date: 2005/05/03 09:43:04 $ + Version: $Revision: 1.138 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -161,7 +161,7 @@ DicomDir::~DicomDir() //----------------------------------------------------------------------------- // Public -void DicomDir::Load(std::string const &fileName ) +bool DicomDir::Load(std::string const &fileName ) { Filename = fileName; // We should clean out anything that already exists. @@ -175,13 +175,13 @@ void DicomDir::Load(std::string const &fileName ) Fp = 0; if ( !OpenFile() ) { - return; + return false; } Document::Load(fileName); if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse { gdcmWarningMacro( "Entry HT empty for file: "<< fileName); - return; + return false; } // Directory record sequence DocEntry *e = GetDocEntry(0x0004, 0x1220); @@ -189,6 +189,7 @@ void DicomDir::Load(std::string const &fileName ) { gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)" << " in file " << fileName); + return false; } else CreateDicomDir(); @@ -209,6 +210,7 @@ void DicomDir::Load(std::string const &fileName ) gdcmWarningMacro( "Parse directory and create the DicomDir : " << Filename ); ParseDirectory(); } + return true; } /** diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 81ebbbbf..0875bcfe 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.h,v $ Language: C++ - Date: $Date: 2005/04/14 14:26:19 $ - Version: $Revision: 1.59 $ + Date: $Date: 2005/05/03 09:43:04 $ + Version: $Revision: 1.60 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -56,7 +56,7 @@ public: ~DicomDir(); - void Load( std::string const &filename ); + bool Load( std::string const &filename ); void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void SetParseDir(bool parseDir) { ParseDir = parseDir; }; diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 1a2bf961..d97f16bd 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/04/29 15:10:55 $ - Version: $Revision: 1.238 $ + Date: $Date: 2005/05/03 09:43:04 $ + Version: $Revision: 1.239 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -101,15 +101,17 @@ Document::~Document () /** * \brief Loader * @param filename 'Document' (File or DicomDir) to be opened for parsing + * @return false if file cannot be open or no swap info was found, + * or no tag was found. */ -void Document::Load( std::string const &fileName ) +bool Document::Load( std::string const &fileName ) { // We should clean out anything that already exists. // Check IsDocumentAlreadyLoaded to be sure. if( IsDocumentAlreadyLoaded ) { - gdcmWarningMacro( "A file was already parsed inside this " << - "gdcm::Document (previous name was: " + gdcmWarningMacro( "A file was already parsed inside this " + << "gdcm::Document (previous name was: " << Filename.c_str() << ". New name is :" << fileName ); // todo : clean out the 'Document' @@ -125,7 +127,7 @@ void Document::Load( std::string const &fileName ) //gdcmWarningMacro( "Unable to open as an ACR/DICOM file: " // << Filename.c_str() ); Filetype = Unknown; - return; + return false; } Group0002Parsed = false; @@ -144,7 +146,7 @@ void Document::Load( std::string const &fileName ) gdcmWarningMacro( "Neither a DICOM V3 nor an ACR-NEMA file: " << Filename.c_str()); CloseFile(); - return ; + return false; } long beg = Fp->tellg(); // just after DICOM preamble (if any) @@ -158,7 +160,7 @@ void Document::Load( std::string const &fileName ) gdcmWarningMacro( "No tag in internal hash table for: " << Filename.c_str()); CloseFile(); - return ; + return false; } IsDocumentAlreadyLoaded = true; @@ -224,6 +226,8 @@ void Document::Load( std::string const &fileName ) SetValEntry(rows , 0x0028, 0x0011); } // --- End of ACR-LibIDO kludge --- + + return true; } /** diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 84041051..b5e44ad7 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2005/04/26 16:18:23 $ - Version: $Revision: 1.109 $ + Date: $Date: 2005/05/03 09:43:04 $ + Version: $Revision: 1.110 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -49,7 +49,7 @@ public: typedef std::list ListElements; // Loading - virtual void Load( std::string const &filename ); + virtual bool Load( std::string const &filename ); // Dictionaries Dict *GetPubDict(); -- 2.45.1