source: trunk/lib/yat/OptionHelp.cc @ 795

Last change on this file since 795 was 795, checked in by Peter Johansson, 12 years ago

refs #388

Create a sub-directory 'lib/yat' in which files from yat are
placed. The files may be updated via 'make fetch', see file README for
more details on how to change which files are updated/copied through
this mechanism.

The reason we do not use subversion's external mechanism is that we
don't want the files to be synchronised with yat automatically. We
want the update to be moderated by some developer.

I chose to fetch files using the svn client rather than wget because
the svn allows us to get an Id string with information from the yat
repository. 'wget' would just download the file as it appears on the
server that is the string is not expanded.

The file 'config_public.h' is created by configure just as in
yat. This implies that automake adds $(top_builddir)/lib/yat to the
include path so unless in a VPATH build $(top_srcdir)/lib/yat is in
the include path. As we have already added $(top_srcdir)/lib to the
include path, and there are both a lib/utility.h and a
lib/yat/utility.h it is not obvious which file is included when having
'include "utility.h"'. For this reason, when being in bin/ and test/
it is needed to include "../lib/utility.h" rather than "utility.h"
when we want to include 'lib/utility.h'.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// $Id: OptionHelp.cc 1797 2009-02-12 18:07:10Z peter $
2
3/*
4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but 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 yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "OptionHelp.h"
23#include "CommandLine.h"
24
25#include <sstream>
26#include <string>
27
28namespace theplu {
29namespace yat {
30namespace utility {
31
32
33  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
34                         std::string desc)
35    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
36  {
37  }
38
39
40  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
41                               std::vector<std::string>::iterator last)
42  {
43    if (usage_.empty()) 
44      std::cout << "Usage: " << cmd().program_name() << " [OPTION]...\n\n";
45    else
46      std::cout << usage_ << "\n"; 
47    std::cout << synopsis_ << "\n";
48    std::cout << cmd() << "\n"; 
49    std::cout << post_cmd_;
50    exit(0);
51  }
52
53
54  std::string& OptionHelp::post_arguments(void)
55  {
56    return post_cmd_;
57  }
58
59
60  std::string& OptionHelp::synopsis(void)
61  {
62    return synopsis_;
63  }
64
65  std::string& OptionHelp::usage(void)
66  {
67    return usage_;
68  }
69
70}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.