qswiki/config.h

73 líneas
1.6 KiB
C++

#ifndef CONFIG_H
#define CONFIG_H
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include "permissions.h"
#include "utils.h"
class Config
{
private:
std::map<std::string, std::string> configmap;
std::string required(const std::string &key);
std::string optional(const std::string &key, std::string defaultvalue = "");
int optional(const std::string &key, int defaulvalue);
public:
Config(const std::map<std::string, std::string> &map);
// TODO: these could be references!?
std::string wikiname;
std::string wikipath;
std::string templatepath;
std::string templateprefix;
std::string logfile;
std::string anon_username;
std::string linkindex;
std::string linkrecent;
std::string linkallpages;
std::string linkallcats;
std::string linkshere;
std::string linkpage;
std::string linkrevision;
std::string linkhistory;
std::string linkedit;
std::string linksettings;
std::string linkdelete;
std::string linklogout;
std::string linkcategory;
std::string loginurl;
std::string linkrecentsort;
std::string actionurl;
std::string settingsurl;
std::string deletionurl;
std::string linkhistorysort;
std::string adminregisterurl;
std::string userchangepwurl;
std::string connectionstring;
int query_limit;
int session_max_lifetime;
int max_pagename_length;
int threadscount;
Permissions anon_permissions;
std::string getConfig(const std::string &key) const
{
return utils::getKeyOrEmpty(configmap, key);
}
};
class ConfigReader
{
private:
std::string path;
public:
ConfigReader(const std::string &file);
Config readConfig();
};
#endif // CONFIG_H