4153 |
09 Mar 22 |
peter |
1 |
#ifndef _theplu_yat_utility_option_version_ |
4153 |
09 Mar 22 |
peter |
2 |
#define _theplu_yat_utility_option_version_ |
4153 |
09 Mar 22 |
peter |
3 |
|
4153 |
09 Mar 22 |
peter |
// $Id$ |
4153 |
09 Mar 22 |
peter |
5 |
|
4153 |
09 Mar 22 |
peter |
6 |
/* |
4153 |
09 Mar 22 |
peter |
Copyright (C) 2022 Peter Johansson |
4153 |
09 Mar 22 |
peter |
8 |
|
4153 |
09 Mar 22 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
4153 |
09 Mar 22 |
peter |
10 |
|
4153 |
09 Mar 22 |
peter |
The yat library is free software; you can redistribute it and/or |
4153 |
09 Mar 22 |
peter |
modify it under the terms of the GNU General Public License as |
4153 |
09 Mar 22 |
peter |
published by the Free Software Foundation; either version 3 of the |
4153 |
09 Mar 22 |
peter |
License, or (at your option) any later version. |
4153 |
09 Mar 22 |
peter |
15 |
|
4153 |
09 Mar 22 |
peter |
The yat library is distributed in the hope that it will be useful, |
4153 |
09 Mar 22 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4153 |
09 Mar 22 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4153 |
09 Mar 22 |
peter |
General Public License for more details. |
4153 |
09 Mar 22 |
peter |
20 |
|
4153 |
09 Mar 22 |
peter |
You should have received a copy of the GNU General Public License |
4153 |
09 Mar 22 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
4153 |
09 Mar 22 |
peter |
23 |
*/ |
4153 |
09 Mar 22 |
peter |
24 |
|
4153 |
09 Mar 22 |
peter |
25 |
#include "OptionSwitch.h" |
4153 |
09 Mar 22 |
peter |
26 |
|
4153 |
09 Mar 22 |
peter |
27 |
#include <string> |
4153 |
09 Mar 22 |
peter |
28 |
#include <vector> |
4153 |
09 Mar 22 |
peter |
29 |
|
4153 |
09 Mar 22 |
peter |
30 |
namespace theplu { |
4153 |
09 Mar 22 |
peter |
31 |
namespace yat { |
4153 |
09 Mar 22 |
peter |
32 |
namespace utility { |
4153 |
09 Mar 22 |
peter |
33 |
|
4153 |
09 Mar 22 |
peter |
34 |
class CommandLine; |
4153 |
09 Mar 22 |
peter |
35 |
/** |
4153 |
09 Mar 22 |
peter |
\brief Class for version option |
4153 |
09 Mar 22 |
peter |
37 |
|
4153 |
09 Mar 22 |
peter |
When this option is found in parsing of commandline, it displays |
4153 |
09 Mar 22 |
peter |
a version output and exits. A typical output looks like: |
4153 |
09 Mar 22 |
peter |
40 |
|
4153 |
09 Mar 22 |
peter |
\verbatim |
4153 |
09 Mar 22 |
peter |
<prog> (<package>) <version> |
4153 |
09 Mar 22 |
peter |
Copyright (C) 2022 John Doe and Jane Doe |
4153 |
09 Mar 22 |
peter |
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
4153 |
09 Mar 22 |
peter |
This is free software: you are free to change and redistribute it. |
4153 |
09 Mar 22 |
peter |
There is NO WARRANTY, to the extent permitted by law. |
4153 |
09 Mar 22 |
peter |
\endverbatim |
4153 |
09 Mar 22 |
peter |
48 |
|
4153 |
09 Mar 22 |
peter |
\since New in yat 0.20 |
4153 |
09 Mar 22 |
peter |
50 |
*/ |
4153 |
09 Mar 22 |
peter |
51 |
class OptionVersion : public OptionSwitch |
4153 |
09 Mar 22 |
peter |
52 |
{ |
4153 |
09 Mar 22 |
peter |
53 |
public: |
4153 |
09 Mar 22 |
peter |
54 |
/** |
4153 |
09 Mar 22 |
peter |
\brief Constructor |
4153 |
09 Mar 22 |
peter |
56 |
|
4153 |
09 Mar 22 |
peter |
\param cmd Commandline object |
4153 |
09 Mar 22 |
peter |
\param prog name of the program |
4153 |
09 Mar 22 |
peter |
\param version string typically taken from PACKAGE_VERSION or |
4153 |
09 Mar 22 |
peter |
VERSION defined in config.h |
4153 |
09 Mar 22 |
peter |
\param copyright_year Year in 'Copyright (C) Year...' |
4153 |
09 Mar 22 |
peter |
\param authors authors |
4153 |
09 Mar 22 |
peter |
\param package if not empty, '(package) ' is added between program |
4153 |
09 Mar 22 |
peter |
name and version |
4153 |
09 Mar 22 |
peter |
\param name default "v,version" implies object is associated |
4153 |
09 Mar 22 |
peter |
with switches -v and --version |
4153 |
09 Mar 22 |
peter |
\param desc string output in help output (OptionHelp) |
4153 |
09 Mar 22 |
peter |
68 |
*/ |
4153 |
09 Mar 22 |
peter |
69 |
OptionVersion(CommandLine& cmd, |
4153 |
09 Mar 22 |
peter |
70 |
const std::string& prog, |
4153 |
09 Mar 22 |
peter |
71 |
const std::string& version, |
4153 |
09 Mar 22 |
peter |
72 |
const std::string& copyright_year, |
4182 |
16 Jun 22 |
peter |
73 |
const std::vector<std::string>& authors, |
4153 |
09 Mar 22 |
peter |
74 |
const std::string& package="", |
4183 |
30 Jun 22 |
peter |
75 |
const std::string& name="v,version", |
4183 |
30 Jun 22 |
peter |
76 |
const std::string& desc="output version information and exit"); |
4153 |
09 Mar 22 |
peter |
77 |
|
4153 |
09 Mar 22 |
peter |
78 |
/** |
4153 |
09 Mar 22 |
peter |
Function to change the copyright holder. The default behaviour |
4153 |
09 Mar 22 |
peter |
is to set copyright holder from authors passed in |
4153 |
09 Mar 22 |
peter |
constructor. If the copyright holder is altered and additional |
4153 |
09 Mar 22 |
peter |
line is added at the bottom: |
4153 |
09 Mar 22 |
peter |
\verbatim |
4153 |
09 Mar 22 |
peter |
84 |
|
4153 |
09 Mar 22 |
peter |
Written by <authors> |
4153 |
09 Mar 22 |
peter |
\endverbatim |
4153 |
09 Mar 22 |
peter |
87 |
*/ |
4153 |
09 Mar 22 |
peter |
88 |
std::string& copyright_holder(void); |
4153 |
09 Mar 22 |
peter |
89 |
|
4153 |
09 Mar 22 |
peter |
90 |
/** |
4153 |
09 Mar 22 |
peter |
Change the license information from the default |
4153 |
09 Mar 22 |
peter |
\verbatim |
4153 |
09 Mar 22 |
peter |
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
4153 |
09 Mar 22 |
peter |
This is free software: you are free to change and redistribute it. |
4153 |
09 Mar 22 |
peter |
There is NO WARRANTY, to the extent permitted by law. |
4153 |
09 Mar 22 |
peter |
\endverbatim |
4153 |
09 Mar 22 |
peter |
97 |
*/ |
4153 |
09 Mar 22 |
peter |
98 |
std::string& license(void); |
4153 |
09 Mar 22 |
peter |
99 |
private: |
4153 |
09 Mar 22 |
peter |
100 |
void do_parse2(std::vector<std::string>::iterator first, |
4153 |
09 Mar 22 |
peter |
101 |
std::vector<std::string>::iterator last); |
4153 |
09 Mar 22 |
peter |
102 |
std::string prog_; |
4153 |
09 Mar 22 |
peter |
103 |
std::string version_; |
4153 |
09 Mar 22 |
peter |
104 |
std::string copyright_year_; |
4153 |
09 Mar 22 |
peter |
105 |
std::vector<std::string> authors_; |
4153 |
09 Mar 22 |
peter |
106 |
std::string package_; |
4153 |
09 Mar 22 |
peter |
107 |
std::string copyright_holder_; |
4153 |
09 Mar 22 |
peter |
108 |
std::string license_; |
4182 |
16 Jun 22 |
peter |
109 |
void print(std::ostream& os, const std::vector<std::string>&, |
4182 |
16 Jun 22 |
peter |
110 |
size_t offset) const; |
4182 |
16 Jun 22 |
peter |
111 |
void print(std::ostream& os, const std::string&, size_t& offset) const; |
4153 |
09 Mar 22 |
peter |
112 |
}; |
4153 |
09 Mar 22 |
peter |
113 |
|
4153 |
09 Mar 22 |
peter |
114 |
}}} // of namespace utility, yat, and theplu |
4153 |
09 Mar 22 |
peter |
115 |
|
4153 |
09 Mar 22 |
peter |
116 |
#endif |