]> cygwin.com Git - cygwin-apps/setup.git/blob - libgetopt++/src/StringArrayOption.cc
Implement paired boolean options
[cygwin-apps/setup.git] / libgetopt++ / src / StringArrayOption.cc
1 /*
2 * Modified from StringOption.cc by Szavai Gyula in 2011
3 *
4 * Copyright (c) 2002 Robert Collins.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * A copy of the GNU General Public License can be found at
12 * http://www.gnu.org/
13 */
14
15 #include <getopt++/StringArrayOption.h>
16
17 StringArrayOption::StringArrayOption(char shortopt,
18 char const *longopt, std::string const &shorthelp,
19 OptionSet &owner) :
20 _optional(Required), _shortopt(shortopt),
21 _longopt (longopt), _shorthelp (shorthelp)
22 {
23 owner.Register (this);
24 };
25
26 StringArrayOption::~ StringArrayOption () {};
27
28 std::string const
29 StringArrayOption::shortOption () const
30 {
31 return std::string() + _shortopt + ":";
32 }
33
34 std::string const
35 StringArrayOption::longOption () const
36 {
37 return _longopt;
38 }
39
40 std::string const
41 StringArrayOption::shortHelp () const
42 {
43 return _shorthelp;
44 }
45
46 Option::Result
47 StringArrayOption::Process (char const *optarg, int prefixIndex)
48 {
49 if (optarg)
50 {
51 _value.push_back(optarg);
52 return Ok;
53 }
54 return Failed;
55 }
56
57 StringArrayOption::operator std::vector<std::string> () const
58 {
59 return _value;
60 }
61
62 Option::Argument
63 StringArrayOption::argument () const
64 {
65 return _optional;
66 }
This page took 0.038498 seconds and 5 git commands to generate.