hobbes
a language, embedded compiler, and runtime for efficient dynamic expression evaluation, data storage and analysis
Classes | Namespaces | Macros | Typedefs | Functions | Variables
file.C File Reference
#include <hobbes/hobbes.H>
#include <hobbes/db/file.H>
#include <hobbes/db/signals.H>
#include <hobbes/eval/cc.H>
#include <hobbes/util/str.H>
#include <hobbes/util/ptr.H>
#include <stdexcept>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
Include dependency graph for file.C:

Classes

struct  hobbes::filehead
 
struct  hobbes::pagetype
 
struct  hobbes::pagedata
 
struct  hobbes::binding
 
struct  hobbes::fregion
 
struct  hobbes::falloc
 
struct  hobbes::imagefile
 
struct  hobbes::mapFileRefs
 

Namespaces

 hobbes
 

Macros

#define CURRENT_FILE_FORMAT_VERSION   ((uint16_t)1)
 

Typedefs

typedef std::vector< pagedata > hobbes::pagetable
 
typedef uint64_t hobbes::file_pageindex_t
 
typedef std::map< std::string, binding > hobbes::bindingset
 
typedef std::map< file_pageindex_t, fregion > hobbes::fmappings
 
typedef std::map< char *, falloc > hobbes::fallocs
 
typedef std::vector< file_pageindex_t > hobbes::pageseq
 
typedef std::map< pagetype::code, pageseq > hobbes::ptyorder
 

Functions

void hobbes::dbglog (const std::string &)
 
static void hobbes::raiseSysError (const std::string &msg, const std::string &fname)
 
uint16_t hobbes::restInPage (const imagefile *f, size_t idx)
 
size_t hobbes::pageCount (const imagefile *f, size_t sz)
 
static void hobbes::closeFile (imagefile *f)
 
static bool hobbes::loadFileSize (imagefile *f)
 
static void hobbes::seekAbs (const imagefile *f, size_t pos)
 
static off_t hobbes::filePosition (const imagefile *f)
 
static void hobbes::allocPages (imagefile *f, size_t pages)
 
static void hobbes::allocPage (imagefile *f)
 
template<typename T >
void hobbes::write (imagefile *f, const T &x)
 
template<typename TIter >
void hobbes::writes (imagefile *f, TIter begin, TIter end)
 
void hobbes::write (imagefile *f, const std::string &x)
 
void hobbes::write (imagefile *f, const std::vector< unsigned char > &xs)
 
template<typename T >
void hobbes::read (const imagefile *f, T *x)
 
template<typename T >
void hobbes::reads (const imagefile *f, size_t sz, T *x)
 
void hobbes::read (imagefile *f, std::string *x)
 
void hobbes::read (imagefile *f, std::vector< unsigned char > *xs)
 
size_t hobbes::pageOffset (const imagefile *f, file_pageindex_t page)
 
file_pageindex_t hobbes::pageIndex (const imagefile *f, uint64_t fpos)
 
static size_t hobbes::position (const imagefile *f, file_pageindex_t page, uint16_t offset)
 
file_pageindex_t hobbes::tocPageToFilePage (const imagefile *f, uint64_t tpage)
 
static uint64_t hobbes::tocPosToFilePos (const imagefile *f, uint64_t spos)
 
static size_t hobbes::pageTOCPosition (const imagefile *f, file_pageindex_t page)
 
static void hobbes::updatePageSizeIndex (imagefile *f, file_pageindex_t page)
 
static void hobbes::insertPageSizeIndex (imagefile *f, file_pageindex_t page)
 
static bool hobbes::findPageWithSpace (imagefile *f, pagetype::code pt, size_t datalen, size_t alignment, file_pageindex_t *idx)
 
static void hobbes::updateTOCData (imagefile *f, file_pageindex_t page, const pagedata &pd)
 
static void hobbes::appendTOCData (imagefile *f, const pagetable &newpages)
 
size_t hobbes::findSpace (imagefile *f, pagetype::code pt, size_t datalen, size_t alignment)
 
static void hobbes::addBinding (imagefile *f, const std::string &vname, const MonoTypePtr &type, size_t offset)
 
fregion & hobbes::createFileRegionMap (imagefile *f, file_pageindex_t page, size_t pages)
 
void hobbes::releaseFileRegionMap (imagefile *f, const fregion &fr)
 
template<typename K , typename V >
std::map< K, V >::iterator hobbes::gleb (std::map< K, V > &m, const K &x)
 
fregion & hobbes::mappedFileRegion (imagefile *f, file_pageindex_t page, size_t pages)
 
static char * hobbes::mapFileData (imagefile *f, size_t fpos, size_t sz)
 
static void hobbes::unmapFileData (imagefile *f, void *p, size_t sz)
 
uint16_t hobbes::assertValidPageSize (const imagefile *f, size_t psize)
 
static void hobbes::createFile (imagefile *f)
 
void hobbes::readPageData (imagefile *f)
 
static void hobbes::readEnvironmentRecord (imagefile *f)
 
static size_t hobbes::readEnvironmentPage (imagefile *f, file_pageindex_t p)
 
static void hobbes::readFile (imagefile *f)
 
static imagefile * hobbes::openFile (const std::string &fname, bool readonly)
 
bool hobbes::isDBFile (const std::string &)
 
size_t hobbes::storageSizeOf (const MonoTypePtr &)
 
bool hobbes::storedAsArray (const MonoTypePtr &)
 
MonoTypePtr hobbes::mkFR (const MonoTypePtr &t)
 
std::string hobbes::showPageDesc (const pagedata &pd)
 
void hobbes::ensureDirExists (const std::string &)
 
std::string hobbes::withUniqueFilenameBy (const std::string &fprefix, const std::string &fsuffix, const std::function< bool(const std::string &)> &fileOp)
 
std::string hobbes::uniqueFilename (const std::string &prefix, const std::string &suffix)
 
std::string hobbes::moveToUniqueFilename (const std::string &oldpath, const std::string &fprefix, const std::string &fsuffix)
 

Variables

static const size_t hobbes::minPageSize = 256
 
static const size_t hobbes::maxPageSize = ((1 << 14) - 1)
 
static const uint32_t hobbes::filePrefixBytes = 0x10a1db0d
 
static const size_t hobbes::pageDataOffset = sizeof(filehead)
 

Macro Definition Documentation

◆ CURRENT_FILE_FORMAT_VERSION

#define CURRENT_FILE_FORMAT_VERSION   ((uint16_t)1)