/usr/include/getopt++/StringCollector.h is in libgetopt++-dev 0.0.2-p22-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | /*
* 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/
*
* Written by Robert Collins <robertc@hotmail.com>
*
*/
#ifndef _STRINGCOLLECTOR_H_
#define _STRINGCOLLECTOR_H_
#include <getopt++/Option.h>
#include <vector>
// Each registered option must implement this class.
class StringCollector : public Option
{
public:
StringCollector (int _maxStrings = 0, bool const &_stopAfterMax = false) : maxStrings(_maxStrings), stopAfterMax(_stopAfterMax)
{}
virtual const std::string shortOption() const
{
return "";
}
virtual const std::string longOption() const
{
return "";
}
virtual const std::string shortHelp() const
{
return "";
}
virtual Option::Argument argument() const
{
return Required;
}
virtual Option::Result Process(const char * value)
{
if (maxStrings != 0 && strings.size() >= maxStrings)
return Failed;
strings.push_back(value);
return (maxStrings != 0 && strings.size() >= maxStrings && stopAfterMax) ? Stop : Ok;
}
std::string operator () (int offset)
{
return strings[offset - 1];
}
size_t size() const
{
return strings.size();
}
std::vector<std::string> const &theVector() const
{
return strings;
}
private:
std::vector<std::string> strings;
int maxStrings;
bool const stopAfterMax;
}
;
#endif // _STRINGCOLLECTOR_H_
|