AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
args.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 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 <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-cli-export.hpp"
23
24#include <string>
25#include <vector>
26#include <map>
27#include <ostream>
28#include <memory>
29
30#include "cli/app.hpp"
31#include "cli/arg.hpp"
32
33namespace anch::cli {
34
36 class RegisteredArg;
37
48 class ANCH_CLI_EXPORT ArgHandler {
49
50 // Attributes +
51 private:
53 std::string _exeName;
54
56 anch::cli::App _app;
57
59 std::vector<std::shared_ptr<anch::cli::RegisteredArg>> _options;
60
62 std::map<char, std::shared_ptr<anch::cli::RegisteredArg>> _sopts;
63
65 std::map<std::string, std::shared_ptr<anch::cli::RegisteredArg>> _lopts;
66
68 std::vector<std::shared_ptr<anch::cli::RegisteredArg>> _positionals;
69 // Attributes -
70
71 // Constructors +
72 public:
81 ArgHandler(const anch::cli::App& app, const std::vector<anch::cli::Arg>& options = {});
82
90 ArgHandler(const std::vector<anch::cli::Arg>& options);
91 // Constructors -
92
93 // Destructor +
94 public:
98 virtual ~ArgHandler();
99 // Destructor -
100
101 // Methods +
102 public:
113
122 void parse(int argc, char** argv);
123
129 void check();
130
139 void handle(int argc, char** argv);
140
146 void printHelp(std::ostream& out);
147
153 void printVersion(std::ostream& out);
154
160 void printBanner(std::ostream& out);
161
162 private:
171 void build(const std::string& arg0);
172
178 void printAppVersion(std::ostream& out);
179
187 bool printUsage(std::ostream& out);
188
194 void printOptions(std::ostream& out);
195 // Methods -
196
197 };
198
199}
CLI arguments handler.
Definition args.hpp:48
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)
AnCH command line interface library namespace.
Definition app.hpp:30
Application summary.
Definition app.hpp:41
Argument.
Definition arg.hpp:41