xtd 0.2.0
startup1.cpp

Shows how to use xtd::startup class.

#include <xtd/console>
#include <xtd/environment>
#include <xtd/startup>
using namespace xtd;
namespace startup1_example {
class program {
public:
static void main() {
// Write arguments to the console output
// return 42
}
};
}
auto main() -> int {
return startup::safe_run(startup1_example::program::main);
}
// Is approximately the same as :
//
// auto main() -> int {
// try {
// startup1_example::program::main();
// return xtd::environment::exit_code();
// } catch(const std::exception& e) {
// if (dynamic_cast<const xtd::system_exception*>(&e)) xtd::console::write_line(static_cast<const xtd::system_exception&>(e).to_string());
// else xtd::console::write_line(e.what());
// } catch(...) {
// xtd::console::write_line("Unhandled exception: Unknown exception occurred");
// }
// }
// This code produces the following output if one two "three four" five are entered on command line:
//
// /!---OMITTED---!/startup1
// one
// two
// three four
// five
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static xtd::argument_collection get_command_line_args()
Returns a string array containing the command-line arguments for the current process.
static int32 exit_code() noexcept
Gets the exit code of the process.
static int safe_run(main_function_t main_function)
Safely call the specified application's main entry point.
Definition startup.hpp:47
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8