From: malaterre Date: Mon, 13 Jun 2005 00:22:14 +0000 (+0000) Subject: ENH: adding a thin wrapper around fstream to deal with fragments X-Git-Tag: Version1.2.bp~520 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6573f31c3941bf0579e103e3bc8dd3aa6bb8608a;p=gdcm.git ENH: adding a thin wrapper around fstream to deal with fragments --- diff --git a/src/gdcmjpegls/Decoder/gdcmfstream.cxx b/src/gdcmjpegls/Decoder/gdcmfstream.cxx new file mode 100644 index 00000000..83cd2e53 --- /dev/null +++ b/src/gdcmjpegls/Decoder/gdcmfstream.cxx @@ -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 + +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 index 00000000..3a332a2d --- /dev/null +++ b/src/gdcmjpegls/Decoder/gdcmfstream.h @@ -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 +#include + +namespace gdcm { + +class ifstream : public std::ifstream +{ +// First the position of the fragment, then the fragment lenght +typedef std::pair 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 fragments; +}; + +} //end namespace gdcm + +#endif