source: trunk/yat/utility/OptionHelp.cc @ 984

Last change on this file since 984 was 984, checked in by Peter, 14 years ago

implementing refs functions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: OptionHelp.cc 984 2007-10-22 16:10:35Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of the yat library, http://trac.thep.lu.se/trac/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 2 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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "OptionHelp.h"
25#include "CommandLine.h"
26
27#include <sstream>
28#include <string>
29
30namespace theplu {
31namespace yat {
32namespace utility {
33
34
35  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
36                         std::string desc)
37    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
38  {
39    usage_ = std::string("Usage: ")+cmd.program_name()+
40      std::string(" [OPTION]...\n");
41  }
42
43
44  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
45                               std::vector<std::string>::iterator last)
46  {
47    std::cout << usage_ << "\n" << 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.