Joedb 10.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
main_wrapper.cpp
Go to the documentation of this file.
2
3#include <iostream>
4#include <cstdio>
5
6namespace joedb
7{
8 /// Process command-line arguments and catch exceptions from main
9 ///
10 /// This function is particularly necessary in Windows, because no
11 /// exception information is printed when main throws.
12 ///
13 /// @ingroup ui
15 (
16 int (*main)(Arguments &), int argc, char **argv
17 )
18 {
19 // necessary for fast console output in Windows
20 std::setvbuf(stdout, nullptr, _IOFBF, 8192);
21 std::setvbuf(stderr, nullptr, _IOFBF, 8192);
22 std::cerr.unsetf(std::ios_base::unitbuf);
23
24 try
25 {
26 Arguments arguments(argc, argv);
27 const int result = main(arguments);
28 return result;
29 }
30 catch (const std::exception &e)
31 {
32 std::cerr << "Exception caught: " << e.what() << '\n';
33 return 1;
34 }
35 }
36}
Class for conveniently parsing command-line arguments.
Definition Arguments.h:16
int main()
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.
int main(int argc, char **argv)
Definition joedbc.cpp:283