7#ifndef ARGS__HELP_HPP__INCLUDED
8#define ARGS__HELP_HPP__INCLUDED
23#ifndef ARGS_QSTRING_BUILD
33#ifdef ARGS_WSTRING_BUILD
34extern std::wstringstream g_argsOutStream;
35#elif defined(ARGS_QSTRING_BUILD)
38extern std::stringstream g_argsOutStream;
52 explicit Help(
bool throwExceptionOnPrint =
true);
86 std::unique_ptr<HelpPrinterIface> m_printer;
88 bool m_throwExceptionOnPrint;
115 m_printer.reset(p.release());
121 if (!context.
atEnd()) {
125 if (details::isArgument(arg) || details::isFlag(arg)) {
126 m_printer->print(arg, g_argsOutStream);
129 auto *tmp = m_printer->findArgument(arg);
133 bool printed =
false;
135 auto *cmd =
static_cast<Command *
>(tmp);
137 while (!context.
atEnd()) {
138 arg = *context.
next();
141 cmd =
static_cast<Command *
>(tmp);
144 if (details::isArgument(arg) || details::isFlag(arg)) {
145 m_printer->print(arg, g_argsOutStream, cmd);
153 tmp = cmd->findChild(arg);
162 m_printer->print(tmp->name(), g_argsOutStream, (cmd != tmp ? cmd :
nullptr));
164 m_printer->print(g_argsOutStream);
168 m_printer->print(g_argsOutStream);
172 m_printer->print(g_argsOutStream);
177 if (m_throwExceptionOnPrint) {
Arg & setDefined(bool on=true)
Set defined.
Arg(Char flag, T &&name, bool isWithValue=false, bool isRequired=false)
Construct argument with flag and name.
virtual void setCmdLine(CmdLine *cmdLine)
Set command line parser.
CmdLine * cmdLine() const
CmdLine is class that holds all rguments and parse command line arguments in the correspondence with ...
Command in the command line interface.
Context is a list of words in the command line that user presented with interface for interacting wit...
ContextInternal::iterator next()
This exception notifies about that help has been printed.
Help & setAppDescription(const String &desc)
Set description for the application.
void process(Context &context) override
Process argument's staff, for example take values from context.
Help & setPrinter(std::unique_ptr< HelpPrinterIface > p)
Set printer.
Help(bool throwExceptionOnPrint=true)
Help & setExecutable(const String &exe)
Set executable name.
void setCmdLine(CmdLine *cmdLine) override
Set command line parser.
Help & setLineLength(String::size_type length)
Set line length for the help.
std::ostream OutStreamType
Out stream type.
std::string String
String type.