MMU

README
Login

MMU is a small utility library that provides abstractions over memory mapped files.

Installation

To build MMU from source you will need a C++14 compiler and CMake.

Usage

MMU offers the following utilities:

Here's a simple usage example to get you started:

#include <cstdio>
#include <string>
#include <algorithm>
#include <MMU/MMU.hpp>

int main(int nargs, const char **args) {
  if (nargs > 0) MMU::set_program_name(args[0]);
# if defined(__EXCEPTIONS)
  try
# endif
  {
    auto array = MMU::file_array<const char>(__FILE__);
    MMU_ASSERT(array.contiguous());
    MMU_ASSERT(array.begin() != array.end());

    auto slice = array.slice(1, 7, 2);
    MMU_ASSERT(!slice.contiguous());
    MMU_ASSERT(std::equal(slice.begin(), slice.end(), "icue<sd"));

    typedef std::basic_string<
      char, std::char_traits<char>,
      MMU::Allocator<char>
    > mmu_string_t;
    auto pool = MMU::buffer_pool("buffer_pool.d");
    mmu_string_t hello("Hello world!", pool);
    MMU_ASSERT(hello[6] == 'w');

    return 0;
  }
# if defined(__EXCEPTIONS)
  catch (const std::exception &exn) {
    fprintf(stderr, "%s: Error: %s\n", MMU::program_name(), exn.what());
    return 1;
  }
# endif
}