summaryrefslogtreecommitdiff
path: root/config.cpp
blob: 9376f10d8ca9a6a10a0a3ef9605bf529ed2a4db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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")
		("audist.database", po::value<std::string>(), "database string")
	;
	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 must be specified in audist.conf");
	}

	if(!vm.count("audist.database")) {
		throw std::runtime_error("audist.database must be specified in audist.conf");
	}
}