preCICE
v3.2.0
Loading...
Searching...
No Matches
src
drivers
main.cpp
Go to the documentation of this file.
1
#include <
iostream
>
2
#include <
precice/Exceptions.hpp
>
3
#include <
precice/Tooling.hpp
>
4
#include <
stdexcept
>
5
#include <
string
>
6
7
void
printUsage
()
8
{
9
std::cerr
<<
"Usage:\n\n"
;
10
std::cerr
<<
"Print XML reference : precice-tools xml\n"
;
11
std::cerr
<<
"Print DTD for XML config : precice-tools dtd\n"
;
12
std::cerr
<<
"Print Markdown reference : precice-tools md\n"
;
13
std::cerr
<<
"Print preCICE version : precice-tools version\n"
;
14
std::cerr
<<
" precice-tools --version\n"
;
15
std::cerr
<<
"Check configuration file : precice-tools check FILE [ PARTICIPANT [ COMMSIZE ] ]\n"
;
16
}
17
18
int
main
(
int
argc,
char
**argv)
19
{
20
if
(argc < 2) {
21
printUsage
();
22
return
1;
23
}
24
25
const
std::string
action(argv[1]);
26
const
int
args = argc - 2;
27
28
using namespace
precice::tooling
;
29
30
if
(
action
==
"dtd"
&& args == 0) {
31
printConfigReference
(
std::cout
,
ConfigReferenceType::DTD
);
32
return
0;
33
}
34
if
(
action
==
"md"
&& args == 0) {
35
printConfigReference
(
std::cout
,
ConfigReferenceType::MD
);
36
return
0;
37
}
38
if
(
action
==
"xml"
&& args == 0) {
39
printConfigReference
(
std::cout
,
ConfigReferenceType::XML
);
40
return
0;
41
}
42
if
((
action
==
"version"
||
action
==
"--version"
) && args == 0) {
43
std::cout
<<
precice::getVersionInformation
() <<
'\n'
;
44
return
0;
45
}
46
if
(
action
==
"check"
&& args >= 1 && args <= 3) {
47
std::string
file(argv[2]);
48
std::string
participant = (args > 1) ?
std::string
(argv[3]) :
""
;
49
50
int
size = 1;
51
if
(args == 3) {
52
try
{
53
size =
std::stoi
(argv[4]);
54
}
catch
(
std::invalid_argument
&e) {
55
std::cerr
<<
"ERROR: passed COMMSIZE is not a valid number\n"
;
56
printUsage
();
57
return
1;
58
}
59
}
60
try
{
61
precice::tooling::checkConfiguration
(file, participant, size);
62
}
catch
(const ::precice::Error &) {
63
}
64
return
0;
65
}
66
67
printUsage
();
68
return
1;
69
}
Exceptions.hpp
Tooling.hpp
std::string
std::cerr
std::cout
main
int main(int argc, char **argv)
Definition
main.cpp:18
printUsage
void printUsage()
Definition
main.cpp:7
std::invalid_argument
iostream
precice::action
contains actions to modify exchanged data.
Definition
Action.hpp:6
precice::tooling
Contains the preCICE tooling API.
Definition
Tooling.cpp:13
precice::tooling::printConfigReference
void printConfigReference(std::ostream &out, ConfigReferenceType reftype)
Generates a configuration reference.
Definition
Tooling.cpp:15
precice::tooling::checkConfiguration
void checkConfiguration(const std::string &filename, const std::string &participant, int size)
Checks a given configuration.
Definition
Tooling.cpp:32
precice::tooling::ConfigReferenceType::XML
@ XML
XML with inlined help.
Definition
Tooling.hpp:25
precice::tooling::ConfigReferenceType::DTD
@ DTD
DTD to check an XML.
Definition
Tooling.hpp:27
precice::tooling::ConfigReferenceType::MD
@ MD
Markdown version used for the website.
Definition
Tooling.hpp:29
precice::getVersionInformation
std::string getVersionInformation()
Returns information on the version of preCICE.
Definition
Tooling.cpp:70
stdexcept
std::stoi
T stoi(T... args)
string