schroot-base-run.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SCHROOT_BASE_RUN_H
00020 #define SCHROOT_BASE_RUN_H
00021
00022 #include <schroot-base/schroot-base-options.h>
00023
00024 #include <sbuild/sbuild-config.h>
00025
00026 #include <cstdlib>
00027 #include <iostream>
00028 #include <string>
00029
00030 namespace schroot_base
00031 {
00032
00042 template<class O, class M>
00043 static int
00044 run (int argc,
00045 char *argv[])
00046 {
00047 typedef O options_type;
00048 typedef M main_type;
00049
00050 try
00051 {
00052
00053 try
00054 {
00055 std::locale::global(std::locale(""));
00056 }
00057 catch (std::runtime_error const& e)
00058 {
00059 std::locale::global(std::locale::classic());
00060 }
00061 std::cout.imbue(std::locale());
00062 std::cerr.imbue(std::locale());
00063
00064 bindtextdomain (SBUILD_MESSAGE_CATALOGUE, LOCALEDIR);
00065 textdomain (SBUILD_MESSAGE_CATALOGUE);
00066
00067 typename options_type::ptr opts(new options_type);
00068 main_type kit(opts);
00069 exit (kit.run(argc, argv));
00070 }
00071 catch (std::exception const& e)
00072 {
00073 sbuild::log_exception_error(e);
00074 exit(EXIT_FAILURE);
00075 }
00076 catch (...)
00077 {
00078 sbuild::log_unknown_exception_error();
00079 exit(EXIT_FAILURE);
00080 }
00081 }
00082
00083 }
00084
00085 #endif
00086
00087
00088
00089
00090
00091