ezp
lightweight C++ wrapper for selected distributed solvers for linear systems
Loading...
Searching...
No Matches
parser.hpp
1
/*******************************************************************************
2
* Copyright (C) 2025-2026 Theodore Chang
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
******************************************************************************/
17
18
#ifndef PARSER_HPP
19
#define PARSER_HPP
20
21
#include <iterator>
22
#include <sstream>
23
#include <vector>
24
25
namespace
ezp::detail {
26
struct
cli_arg
{
27
std::string token;
28
int
value;
29
};
30
31
inline
auto
parse(
const
std::string&
command
) {
32
std::istringstream
iss
(
command
);
33
auto
current
= std::istream_iterator<std::string>(
iss
);
34
const
auto
end = std::istream_iterator<std::string>();
35
36
std::vector<cli_arg>
args
;
37
38
while
(
current
!= end) {
39
cli_arg
arg
{*
current
++, 0};
40
if
(!
arg
.token.starts_with(
"--"
))
continue
;
41
if
(
current
== end)
break
;
42
try
{
43
arg
.value = std::stoi(*
current
);
44
args
.push_back(
arg
);
45
++
current
;
46
}
47
catch
(...) {
48
}
49
}
50
51
return
args
;
52
}
53
}
// namespace ezp::detail
54
55
#endif
56
pardiso
Solver for general sparse matrices.
ezp::detail::cli_arg
Definition
parser.hpp:26
ezp
parser.hpp
Generated by
1.9.8