#ifndef WC3RE_UTIL_HH__ #define WC3RE_UTIL_HH__ #include #include #include "common.hh" class MmapFile { public: MmapFile(std::string fileName); MmapFile(MmapFile const& copy) = delete; MmapFile(MmapFile && move); ~MmapFile(); MmapFile& operator=(MmapFile const& copy) = delete; MmapFile& operator=(MmapFile && move); std::string const& name() const; size_t size() const; char const* data() const; operator bool() const; private: std::string name_; FILEUPtr fd_; size_t size_; void *base_; }; // Helper functions to read big endian numbers uint16_t readU16BE(char const* data); uint32_t readU24BE(char const* data); uint32_t readU32BE(char const* data); // Helper functions to read little endian numbers uint16_t readU16LE(char const* data); uint32_t readU24LE(char const* data); uint32_t readU32LE(char const* data); // Sign-extend b starting at msb int sextend(unsigned b, unsigned msb); #endif