ModErn Text Analysis
META Enumerates Textual Applications
mmap_file.h
Go to the documentation of this file.
1 
10 #ifndef META_MMAP_FILE_H_
11 #define META_MMAP_FILE_H_
12 
13 #include <stdexcept>
14 #include <string>
15 
16 namespace meta
17 {
18 namespace io
19 {
20 
24 class mmap_file
25 {
26  public:
31  mmap_file(const std::string& path);
32 
37 
42 
47  ~mmap_file();
48 
54  char operator[](uint64_t index) const;
55 
59  uint64_t size() const;
60 
65  std::string path() const;
66 
70  char* begin() const;
71 
72  private:
74  std::string path_;
75 
77  char* start_;
78 
80  uint64_t size_;
81 
84 
86  mmap_file(const mmap_file& other) = delete;
87 
89  const mmap_file& operator=(const mmap_file& other) = delete;
90 
91  public:
95  class mmap_file_exception : public std::runtime_error
96  {
97  public:
98  using std::runtime_error::runtime_error;
99  };
100 };
101 }
102 }
103 
104 #endif
char * begin() const
Definition: mmap_file.cpp:53
std::string path_
Filename of the text file.
Definition: mmap_file.h:74
uint64_t size() const
Definition: mmap_file.cpp:76
Memory maps a text file readonly.
Definition: mmap_file.h:24
int file_descriptor_
File descriptor for the open text file.
Definition: mmap_file.h:83
mmap_file & operator=(mmap_file &&)
Move assignment operator.
Definition: mmap_file.cpp:58
~mmap_file()
Destructor; deallocates memory used to store this object, closing the text file.
Definition: mmap_file.cpp:86
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
std::string path() const
Definition: mmap_file.cpp:81
mmap_file(const std::string &path)
Constructor.
Definition: mmap_file.cpp:19
char * start_
Pointer to the beginning of the text file.
Definition: mmap_file.h:77
uint64_t size_
Size of the current text file.
Definition: mmap_file.h:80
char operator[](uint64_t index) const
Definition: mmap_file.cpp:45
Basic exception for mmap_file interactions.
Definition: mmap_file.h:95