SpectMorph
smmmapin.hh
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 
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  int fd;
19 
20  MMapIn (unsigned char *mapfile, unsigned char *mapend, int fd);
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 */
bool skip(size_t size)
Definition: smmmapin.cc:92
Generic Input Stream.
Definition: smgenericin.hh:17
int get_byte()
Definition: smmmapin.cc:70
unsigned char * mmap_mem(size_t &remaining)
Definition: smmmapin.cc:106
Definition: smmmapin.hh:13
size_t get_pos()
Definition: smmmapin.cc:113
Definition: smalignedarray.cc:7
int read(void *ptr, size_t size)
Definition: smmmapin.cc:79
GenericIn * open_subfile(size_t pos, size_t len)
Definition: smmmapin.cc:119