]> cygwin.com Git - cygwin-apps/setup.git/blob - libgetopt++/src/StringArrayOption.cc
Add infrastructure for handling string options which are repeated
[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 using namespace std;
18
19 StringArrayOption::StringArrayOption(char shortopt,
20 char const *longopt, string const &shorthelp,
21 OptionSet &owner) :
22 _optional(Required), _shortopt(shortopt),
23 _longopt (longopt), _shorthelp (shorthelp)
24 {
25 owner.Register (this);
26 };
27
28 StringArrayOption::~ StringArrayOption () {};
29
30 string const
31 StringArrayOption::shortOption () const
32 {
33 return string() + _shortopt + ":";
34 }
35
36 string const
37 StringArrayOption::longOption () const
38 {
39 return _longopt;
40 }
41
42 string const
43 StringArrayOption::shortHelp () const
44 {
45 return _shorthelp;
46 }
47
48 Option::Result
49 StringArrayOption::Process (char const *optarg)
50 {
51 if (optarg)
52 {
53 _value.push_back(optarg);
54 return Ok;
55 }
56 return Failed;
57 }
58
59 StringArrayOption::operator vector<string> () const
60 {
61 return _value;
62 }
63
64 Option::Argument
65 StringArrayOption::argument () const
66 {
67 return _optional;
68 }
This page took 0.039179 seconds and 6 git commands to generate.