diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-29 23:27:06 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-29 23:27:06 +0100 |
commit | 757edd54cca1d3bc19617284bba5d008a976f704 (patch) | |
tree | 53b1c4b0293e3fa91e642b5e4d6d404f9d05827b /config.cpp | |
parent | 5d94fe647e59aaec7775f1e1bd4a4982b677af01 (diff) |
Read music root and httpd port from audist.conf.
Diffstat (limited to 'config.cpp')
-rw-r--r-- | config.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/config.cpp b/config.cpp new file mode 100644 index 0000000..1fbcde5 --- /dev/null +++ b/config.cpp @@ -0,0 +1,22 @@ +#include "config.h" + +#include <string> +#include <fstream> +#include <stdexcept> + +po::variables_map config::vm; + +void config::init() { + po::options_description desc("foo"); + desc.add_options() + ("audist.music_root", po::value<std::string>(), "music root") + ("audist.httpd_port", po::value<int>()->default_value(8000), "httpd port") + ; + std::ifstream is("audist.conf", std::ios::in); + po::store(po::parse_config_file(is, desc, true), vm); + po::notify(vm); + + if(!vm.count("audist.music_root")) { + throw std::runtime_error("audist.music_root music be specified in audist.conf"); + } +} |