1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_MMAP_IN_HH
4 #define SPECTMORPH_MMAP_IN_HH
5 
6 #include <string>
7 #include <glib.h>
8 #include "smgenericin.hh"
9 
10 namespace SpectMorph
11 {
12 
13 class MMapIn : public GenericIn
14 {
15   unsigned char *mapfile;
16   unsigned char *mapend;
17   unsigned char *pos;
18   GMappedFile   *g_mapped_file;
19 
20   MMapIn (unsigned char *mapfile, unsigned char *mapend, GMappedFile *g_mapped_file);
21   ~MMapIn();
22 public:
23   static GenericIn* open (const std::string& filename);
24   static GenericIn* open_mem (unsigned char *mem_start, unsigned char *mem_end);
25 
26   int get_byte();     // like fgetc
27   int read (void *ptr, size_t size);
28   bool skip (size_t size);
29   unsigned char *mmap_mem (size_t& remaining);
30   size_t get_pos();
31   GenericIn *open_subfile (size_t pos, size_t len);
32 };
33 
34 }
35 
36 #endif /* SPECTMORPH_MMAP_IN_HH */
37