AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
utils.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 <list>
25#include <vector>
26#include <set>
27#include <string>
28#include <optional>
29#include <functional>
30#include <memory>
31#include <filesystem>
32#include <fstream>
33
34namespace anch::cli {
35
37 using BindArg = std::function<void(const std::string&)>;
38
46 ANCH_CLI_EXPORT BindArg bindTrue(bool& dest);
47
55 ANCH_CLI_EXPORT BindArg bindFalse(bool& dest);
56
65 ANCH_CLI_EXPORT BindArg bindNum(uint16_t& dest);
66
75 ANCH_CLI_EXPORT BindArg bindNum(uint32_t& dest);
76
85 ANCH_CLI_EXPORT BindArg bindNum(uint64_t& dest);
86
95 ANCH_CLI_EXPORT BindArg bindNum(int16_t& dest);
96
105 ANCH_CLI_EXPORT BindArg bindNum(int32_t& dest);
106
115 ANCH_CLI_EXPORT BindArg bindNum(int64_t& dest);
116
125 ANCH_CLI_EXPORT BindArg bindNum(float& dest);
126
135 ANCH_CLI_EXPORT BindArg bindNum(double& dest);
136
144 ANCH_CLI_EXPORT BindArg bindStr(std::string& dest);
145
153 ANCH_CLI_EXPORT BindArg bindStr(std::optional<std::string>& dest);
154
162 ANCH_CLI_EXPORT BindArg bindCol(std::vector<std::string>& dest);
163
171 ANCH_CLI_EXPORT BindArg bindCol(std::list<std::string>& dest);
172
180 ANCH_CLI_EXPORT BindArg bindCol(std::set<std::string>& dest);
181
189 ANCH_CLI_EXPORT BindArg bindPath(std::filesystem::path& dest);
190
199 ANCH_CLI_EXPORT BindArg bindIFS(std::shared_ptr<std::istream>& dest);
200
208 ANCH_CLI_EXPORT BindArg bindOFS(std::shared_ptr<std::ostream>& dest);
209
218 ANCH_CLI_EXPORT BindArg bindOFS(std::shared_ptr<std::ofstream>& dest, std::ios_base::openmode mode = std::ios_base::out);
219
225 ANCH_CLI_EXPORT std::function<void(std::istream&)> bindPipe(std::shared_ptr<std::istream>& dest);
226
232 ANCH_CLI_EXPORT std::function<void(std::ostream&)> bindCout(std::shared_ptr<std::ostream>& dest);
233
237 ANCH_CLI_EXPORT void manageEnvNoFormat();
238
239} // anch::cli
AnCH command line interface library namespace.
Definition app.hpp:30
std::function< void(std::ostream &)> bindCout(std::shared_ptr< std::ostream > &dest)
BindArg bindIFS(std::shared_ptr< std::istream > &dest)
std::function< void(std::istream &)> bindPipe(std::shared_ptr< std::istream > &dest)
BindArg bindFalse(bool &dest)
BindArg bindTrue(bool &dest)
BindArg bindPath(std::filesystem::path &dest)
BindArg bindNum(uint16_t &dest)
std::function< void(const std::string &)> BindArg
Definition utils.hpp:37
BindArg bindCol(std::vector< std::string > &dest)
BindArg bindOFS(std::shared_ptr< std::ostream > &dest)
BindArg bindStr(std::string &dest)
void manageEnvNoFormat()