You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.2 KiB

// ©2008-2017 despair <despair@netrunner.cc>
#ifndef __CFGFILEPARSER_H__
#define __CFGFILEPARSER_H__
#include "netrunner.h"
#include <sys/stat.h>
#include <cstdint>
// Class which holds the parsed configuration options after
// being processed by CFGFileParser. No longer a "trivial class"
// just select by cfg->GlobalSettings....
struct BrowserConfiguration{
ntr::stringmap Settings;
// fast allocation!
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)) {
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p) {
tlsf_free(p);
}
void clear();
};
class CFGFileParser {
public:
CFGFileParser(const char* filename);
~CFGFileParser();
void ParseText();
void WriteConfig(BrowserConfiguration &config);
static void* operator new(std::size_t n) {
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p) {
tlsf_free(p);
}
private:
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo = reinterpret_cast<struct stat*>(tlsf_malloc(sizeof(struct stat)));
BrowserConfiguration *cfg = new BrowserConfiguration();
size_t bytesRead;
};
#endif // __CFGFILEPARSER_H__