source: trunk/lib/main_utility.cc @ 1067

Last change on this file since 1067 was 1067, checked in by Peter Johansson, 11 years ago

refs #307. Lift out load of configuration file to common place

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.3 KB
RevLine 
[1067]1// $Id: main_utility.cc 1067 2010-06-06 02:40:30Z peter $
2
3/*
4  Copyright (C) 2010 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "main_utility.h"
23
24#include "Configuration.h"
25#include "utility.h"
26
27#include <fstream>
28#include <string>
29#include <stdexcept>
30
31namespace theplu {
32namespace svndigest {
33
34  void load_config(const std::string& file)
35  {
36    // Reading configuration file
37    Configuration& config = Configuration::instance();
38    if (node_exist(file)) {
39      std::ifstream is(file.c_str());
40      assert(is.good());
41      try { 
42        config.load(is);
43      }
44      catch (std::runtime_error& e) {
45        std::string msg = "invalid config file\n";
46        msg += e.what();
47        throw std::runtime_error(msg);
48      }
49      is.close();
50    }
51  }
52
53
54
55}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.