+2011-05-30 SZAVAI Gyula <szgyg@ludens.elte.hu>
+ * libgetopt++/src/StringArrayOption.cc: New file.
+ * libgetopt++/include/getopt++/StringArrayOption.h: New file.
+ * libgetopt++/Makefile.am: Add new files.
+
2008-06-16 Dave Korn <dave.korn.cygwin@gmail.com>
* libgetopt++/src/OptionSet.cc (OptionSet::doOption): Move value
libgetopt___la_SOURCES = src/GetOption.cc src/Option.cc src/BoolOption.cc \
src/OptionSet.cc \
- src/StringOption.cc
+ src/StringArrayOption.cc src/StringOption.cc
libgetopt___la_LDFLAGS = -version-info 1:1:0
include/getopt++/DefaultFormatter.h \
include/getopt++/GetOption.h \
include/getopt++/OptionSet.h \
+ include/getopt++/StringArrayOption.h \
include/getopt++/StringOption.h
tests_testoption_SOURCES = tests/testoption.cc
--- /dev/null
+/*
+ * Modified from StringOption.h by Szavai Gyula in 2011
+ *
+ * Copyright (c) 2002 Robert Collins.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ */
+
+#ifndef _STRINGARRAYOPTION_H_
+#define _STRINGARRAYOPTION_H_
+
+#include <getopt++/Option.h>
+#include <getopt++/GetOption.h>
+
+// Each registered option must implement this class.
+class StringArrayOption : public Option
+{
+public:
+ StringArrayOption(char shortopt, char const *longopt = 0,
+ std::string const &shorthelp = std::string(),
+ OptionSet &owner=GetOption::GetInstance());
+ virtual ~ StringArrayOption ();
+ virtual std::string const shortOption () const;
+ virtual std::string const longOption () const;
+ virtual std::string const shortHelp () const;
+ virtual Result Process (char const *);
+ virtual Argument argument () const;
+ operator std::vector<std::string> () const;
+
+private:
+ Argument _optional;
+ std::vector<std::string> _value;
+ char _shortopt;
+ char const *_longopt;
+ std::string _shorthelp;
+};
+
+#endif // _STRINGARRAYOPTION_H_
--- /dev/null
+/*
+ * Modified from StringOption.cc by Szavai Gyula in 2011
+ *
+ * Copyright (c) 2002 Robert Collins.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ */
+
+#include <getopt++/StringArrayOption.h>
+
+using namespace std;
+
+StringArrayOption::StringArrayOption(char shortopt,
+ char const *longopt, string const &shorthelp,
+ OptionSet &owner) :
+ _optional(Required), _shortopt(shortopt),
+ _longopt (longopt), _shorthelp (shorthelp)
+{
+ owner.Register (this);
+};
+
+StringArrayOption::~ StringArrayOption () {};
+
+string const
+StringArrayOption::shortOption () const
+{
+ return string() + _shortopt + ":";
+}
+
+string const
+StringArrayOption::longOption () const
+{
+ return _longopt;
+}
+
+string const
+StringArrayOption::shortHelp () const
+{
+ return _shorthelp;
+}
+
+Option::Result
+StringArrayOption::Process (char const *optarg)
+{
+ if (optarg)
+ {
+ _value.push_back(optarg);
+ return Ok;
+ }
+ return Failed;
+}
+
+StringArrayOption::operator vector<string> () const
+{
+ return _value;
+}
+
+Option::Argument
+StringArrayOption::argument () const
+{
+ return _optional;
+}