]> Creatis software - gdcm.git/commitdiff
Load returns now a bool (allow user not to call IsReadable() )
authorjpr <jpr>
Tue, 3 May 2005 09:43:04 +0000 (09:43 +0000)
committerjpr <jpr>
Tue, 3 May 2005 09:43:04 +0000 (09:43 +0000)
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDocument.cxx
src/gdcmDocument.h

index 27b840f24c2b20d3bcabb7935ba0f3812827fafb..d8e60efe966f7bc517b955ae8f8da74b01ab6d17 100644 (file)
@@ -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;
 }
 
 /**
index 81ebbbbf2ec4eeb885662931f17294189e9b6163..0875bcfedcd3541a16e3a6754db914a7447560af 100644 (file)
@@ -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; };
index 1a2bf961c7e5a3d2f4d1935053b6bd6f85e51b7c..d97f16bdabbf5c5e1ca91caad0af435c7cfe655e 100644 (file)
@@ -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;
 }
 
 /**
index 840410516f3f7d41de19f17f22da3cc8e3b7ab57..b5e44ad7adc6338f928e5c3e0e8688d6ba752ed1 100644 (file)
@@ -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<Element> ListElements;
 
 // Loading
-   virtual void Load( std::string const &filename ); 
+   virtual bool Load( std::string const &filename ); 
 
 // Dictionaries
    Dict *GetPubDict();