Skip to content

Instantly share code, notes, and snippets.

@isoiphone
Created July 28, 2012 05:41
Show Gist options
  • Save isoiphone/3191960 to your computer and use it in GitHub Desktop.
Save isoiphone/3191960 to your computer and use it in GitHub Desktop.
#include "Config.h"
const Config& Config::get() {
return getWriteable();
}
Config& Config::getWriteable() {
static Config inst;
return inst;
}
Config::Config() {
appPath = "";
docPath = "";
}
#pragma once
#include <string>
class Config {
public:
static const Config& get();
static Config& getWriteable();
std::string appPath;
std::string docPath;
private:
Config();
};
// to configure a setting
Config::getWriteable().appPath = "c:\myapp\";
// to access a setting
doStuff(Config::get().appPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment