source: branches/0.4-stable/yat/utility/OptionHelp.cc @ 1743

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

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: OptionHelp.cc 1743 2009-01-23 14:20:30Z peter $
2
3/*
4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2008 Peter Johansson
6
7  This file is part of the yat library, http://dev.thep.lu.se/yat
8
9  The yat library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version.
13
14  The yat library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#include "OptionHelp.h"
26#include "CommandLine.h"
27
28#include <sstream>
29#include <string>
30
31namespace theplu {
32namespace yat {
33namespace utility {
34
35
36  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
37                         std::string desc)
38    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
39  {
40  }
41
42
43  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
44                               std::vector<std::string>::iterator last)
45  {
46    if (usage_.empty()) 
47      std::cout << "Usage: " << cmd().program_name() << " [OPTION]...\n\n";
48    else
49      std::cout << usage_ << "\n"; 
50    std::cout << synopsis_ << "\n";
51    std::cout << cmd() << "\n"; 
52    std::cout << post_cmd_;
53    exit(0);
54  }
55
56
57  std::string& OptionHelp::post_arguments(void)
58  {
59    return post_cmd_;
60  }
61
62
63  std::string& OptionHelp::synopsis(void)
64  {
65    return synopsis_;
66  }
67
68  std::string& OptionHelp::usage(void)
69  {
70    return usage_;
71  }
72
73}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.