source: trunk/lib/main_utility.cc @ 1086

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

first working version of svncopyright. refs #307. linking snvcopyright against plplot unfortunately.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: main_utility.cc 1086 2010-06-12 05:06:27Z 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 "Node.h"
26#include "utility.h"
27
28#include <cctype>
29#include <cassert>
30#include <fstream>
31#include <iostream>
32#include <string>
33#include <stdexcept>
34
35namespace theplu {
36namespace svndigest {
37
38  void load_config(const std::string& file)
39  {
40    // Reading configuration file
41    Configuration& config = Configuration::instance();
42    if (node_exist(file)) {
43      std::ifstream is(file.c_str());
44      assert(is.good());
45      try { 
46        config.load(is);
47      }
48      catch (std::runtime_error& e) {
49        std::string msg = "invalid config file\n";
50        msg += e.what();
51        throw std::runtime_error(msg);
52      }
53      is.close();
54    }
55  }
56
57
58  void update_copyright(const Node& tree, bool verbose)
59  {
60    if (verbose)
61      std::cout << "Updating copyright statements" << std::endl;
62    const Configuration& config = Configuration::instance();
63    std::map<std::string, Alias> alias(config.copyright_alias());
64    tree.print_copyright(alias, verbose);
65  }
66
67}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.