]> Creatis software - gdcm.git/commitdiff
ENH: adding a thin wrapper around fstream to deal with fragments
authormalaterre <malaterre>
Mon, 13 Jun 2005 00:22:14 +0000 (00:22 +0000)
committermalaterre <malaterre>
Mon, 13 Jun 2005 00:22:14 +0000 (00:22 +0000)
src/gdcmjpegls/Decoder/gdcmfstream.cxx [new file with mode: 0644]
src/gdcmjpegls/Decoder/gdcmfstream.h [new file with mode: 0644]

diff --git a/src/gdcmjpegls/Decoder/gdcmfstream.cxx b/src/gdcmjpegls/Decoder/gdcmfstream.cxx
new file mode 100644 (file)
index 0000000..83cd2e5
--- /dev/null
@@ -0,0 +1,37 @@
+/*=========================================================================
+  
+  Program:   gdcm
+  Module:    $RCSfile: gdcmfstream.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/06/13 00:22:14 $
+  Version:   $Revision: 1.1 $
+  
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+  
+=========================================================================*/
+
+#include "gdcmfstream.h"
+#include <iostream>
+
+namespace gdcm {
+
+
+ifstream::ifstream(const char* filename,openmode mode)
+   :std::ifstream(filename,mode)
+{
+}
+
+std::istream& ifstream::read(char* s, std::streamsize n )
+{
+  std::cerr << "my read" << std::endl;
+  this->std::ifstream::read(s,n);
+}
+
+} //end namespace gdcm
+
diff --git a/src/gdcmjpegls/Decoder/gdcmfstream.h b/src/gdcmjpegls/Decoder/gdcmfstream.h
new file mode 100644 (file)
index 0000000..3a332a2
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+  
+  Program:   gdcm
+  Module:    $RCSfile: gdcmfstream.h,v $
+  Language:  C++
+  Date:      $Date: 2005/06/13 00:22:14 $
+  Version:   $Revision: 1.1 $
+  
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+  
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+  
+=========================================================================*/
+
+#ifndef __gdcmfstream_
+#define __gdcmfstream_
+
+#include <fstream>
+#include <list>
+
+namespace gdcm {
+
+class ifstream : public std::ifstream
+{
+// First the position of the fragment, then the fragment lenght
+typedef std::pair<std::streampos, std::streamsize> fragment;
+
+public:
+  explicit ifstream(const char* filename,
+    std::ios_base::openmode mode = std::ios_base::in);
+
+  std::istream&  read (char* s, std::streamsize n );
+  inline void add_fragment(fragment f) { fragments.push_back(f); }
+
+private:
+  std::list<fragment> fragments;
+};
+
+} //end namespace gdcm
+
+#endif