This file is indexed.

/usr/include/wibble/commandline/parser.h is in libwibble-dev 1.1-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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef WIBBLE_COMMANDLINE_PARSER_H
#define WIBBLE_COMMANDLINE_PARSER_H

#include <wibble/commandline/engine.h>
#include <iosfwd>

namespace wibble {
namespace commandline {

/**
 * Generic parser for commandline arguments.
 */
class Parser : public Engine
{
protected:
	ArgList m_args;

	MemoryManager m_manager;

public:
	Parser(const std::string& name,
		   const std::string& usage = std::string(),
		   const std::string& description = std::string(),
		   const std::string& longDescription = std::string())
		: Engine(&m_manager, name, usage, description, longDescription) {}

	/**
	 * Parse the commandline
	 *
	 * @returns true if it also took care of performing the action requested by
	 *   the user, or false if the caller should do it instead.
	 */
	bool parse(int argc, const char* argv[])
	{
		m_args.clear();
		for (int i = 1; i < argc; i++)
			m_args.push_back(argv[i]);
		parseList(m_args);
		return false;
	}

	bool hasNext() const { return !m_args.empty(); }

	std::string next()
	{
		if (m_args.empty())
			return std::string();
		std::string res(*m_args.begin());
		m_args.erase(m_args.begin());
		return res;
	}
};

/**
 * Parser for commandline arguments, with builting help functions.
 */
class StandardParser : public Parser
{
protected:
	std::string m_version;

public:
	StandardParser(const std::string& appname, const std::string& version) :
		Parser(appname), m_version(version)
	{
		helpGroup = addGroup("Help options");
		help = helpGroup->add<BoolOption>("help", 'h', "help", "",
				"print commandline help and exit");
		help->addAlias('?');
		this->version = helpGroup->add<BoolOption>("version", 0, "version", "",
				"print the program version and exit");
	}

	void outputHelp(std::ostream& out);

	bool parse(int argc, const char* argv[]);

	OptionGroup* helpGroup;
	BoolOption* help;
	BoolOption* version;
};

/**
 * Parser for commandline arguments, with builting help functions and manpage
 * generation.
 */
class StandardParserWithManpage : public StandardParser
{
protected:
	int m_section;
	std::string m_author;

public:
	StandardParserWithManpage(
			const std::string& appname,
			const std::string& version,
			int section,
			const std::string& author) :
		StandardParser(appname, version),
		m_section(section), m_author(author)
	{
		manpage = helpGroup->add<StringOption>("manpage", 0, "manpage", "[hooks]",
				"output the " + name() + " manpage and exit");
	}

	bool parse(int argc, const char* argv[]);

	StringOption* manpage;
};

/**
 * Parser for commandline arguments, with builting help functions and manpage
 * generation, and requiring a mandatory command.
 */
class StandardParserWithMandatoryCommand : public StandardParserWithManpage
{
public:
	StandardParserWithMandatoryCommand(
			const std::string& appname,
			const std::string& version,
			int section,
			const std::string& author) :
		StandardParserWithManpage(appname, version, section, author)
	{
		helpCommand = addEngine("help", "[command]", "print help information",
				"With no arguments, print a summary of available commands.  "
				"If given a command name as argument, print detailed informations "
				"about that command.");
	}

	bool parse(int argc, const char* argv[]);

	Engine* helpCommand;
};

}
}

// vim:set ts=4 sw=4:
#endif