AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
args.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <string>
23#include <vector>
24#include <map>
25#include <ostream>
26#include <memory>
27
28#include "cli/app.hpp"
29#include "cli/arg.hpp"
30
31namespace anch::cli {
32
34 class RegisteredArg;
35
46 class ArgHandler {
47
48 // Attributes +
49 private:
51 std::string _exeName;
52
54 anch::cli::App _app;
55
57 std::vector<std::shared_ptr<anch::cli::RegisteredArg>> _options;
58
60 std::map<char, std::shared_ptr<anch::cli::RegisteredArg>> _sopts;
61
63 std::map<std::string, std::shared_ptr<anch::cli::RegisteredArg>> _lopts;
64
66 std::vector<std::shared_ptr<anch::cli::RegisteredArg>> _positionals;
67 // Attributes -
68
69 // Constructors +
70 public:
79 ArgHandler(const anch::cli::App& app, const std::vector<anch::cli::Arg>& options = {});
80
88 ArgHandler(const std::vector<anch::cli::Arg>& options);
89 // Constructors -
90
91 // Destructor +
92 public:
96 virtual ~ArgHandler();
97 // Destructor -
98
99 // Methods +
100 public:
111
120 void parse(int argc, char** argv);
121
127 void check();
128
137 void handle(int argc, char** argv);
138
144 void printHelp(std::ostream& out);
145
151 void printVersion(std::ostream& out);
152
158 void printBanner(std::ostream& out);
159
160 private:
169 void build(const std::string& arg0);
170
176 void printAppVersion(std::ostream& out);
177
185 bool printUsage(std::ostream& out);
186
192 void printOptions(std::ostream& out);
193 // Methods -
194
195 };
196
197}
CLI arguments handler.
Definition args.hpp:46
ArgHandler(const std::vector< anch::cli::Arg > &options)
void handle(int argc, char **argv)
void parse(int argc, char **argv)
ArgHandler(const anch::cli::App &app, const std::vector< anch::cli::Arg > &options={})
void printBanner(std::ostream &out)
anch::cli::ArgHandler & arg(anch::cli::Arg &arg)
void printVersion(std::ostream &out)
void printHelp(std::ostream &out)
Application summary.
Definition app.hpp:39
Argument.
Definition arg.hpp:39