↰ Return to documentation for file (include/networkit/io/MemoryMappedFile.hpp
)
/*
* MemoryMappedFile.hpp
*
* Created on: 16.07.2018
* Author: Manuel Penschuck (networkit@manuel.jetzt)
*/
#ifndef NETWORKIT_IO_MEMORY_MAPPED_FILE_HPP_
#define NETWORKIT_IO_MEMORY_MAPPED_FILE_HPP_
#include <memory>
#include <string>
namespace NetworKit {
struct MemoryMappedFileState;
class MemoryMappedFile final {
public:
using value_type = char;
using const_iterator = const value_type *;
MemoryMappedFile();
explicit MemoryMappedFile(std::string_view path);
~MemoryMappedFile();
MemoryMappedFile(const MemoryMappedFile &) = delete;
MemoryMappedFile &operator=(const MemoryMappedFile &) = delete;
MemoryMappedFile(MemoryMappedFile &&o) noexcept;
MemoryMappedFile &operator=(MemoryMappedFile &&o) noexcept;
void open(std::string_view file);
void close() noexcept;
const_iterator cbegin() const { return beginIt; }
const_iterator cend() const { return endIt; }
size_t size() const { return std::distance(beginIt, endIt); }
private:
const_iterator beginIt{nullptr};
const_iterator endIt{nullptr};
std::unique_ptr<MemoryMappedFileState> state;
};
} // namespace NetworKit
#endif // NETWORKIT_IO_MEMORY_MAPPED_FILE_HPP_