MCPcopy Create free account
hub / github.com/Clarionos/clarion / initialize_impl

Method initialize_impl

libraries/appbase/application.cpp:218–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218bool application::initialize_impl(int argc, char** argv, vector<abstract_plugin*> autostart_plugins) {
219 set_program_options();
220
221 bpo::variables_map& options = my->_options;
222 try {
223 bpo::parsed_options parsed = bpo::command_line_parser(argc, argv).options(my->_app_options).run();
224 bpo::store(parsed, options);
225 vector<string> positionals = bpo::collect_unrecognized(parsed.options, bpo::include_positional);
226 if(!positionals.empty())
227 BOOST_THROW_EXCEPTION(std::runtime_error("Unknown option '" + positionals[0] + "' passed as command line argument"));
228 } catch( const boost::program_options::unknown_option& e ) {
229 BOOST_THROW_EXCEPTION(std::runtime_error("Unknown option '" + e.get_option_name() + "' passed as command line argument"));
230 }
231
232 if( options.count( "help" ) ) {
233 cout << my->_app_options << std::endl;
234 return false;
235 }
236
237 if( options.count( "version" ) ) {
238 cout << version_string() << std::endl;
239 return false;
240 }
241
242 if( options.count( "full-version" ) ) {
243 cout << full_version_string() << std::endl;
244 return false;
245 }
246
247 if( options.count( "print-default-config" ) ) {
248 print_default_config(cout);
249 return false;
250 }
251
252 if( options.count( "data-dir" ) ) {
253 // Workaround for 10+ year old Boost defect
254 // See https://svn.boost.org/trac10/ticket/8535
255 // Should be .as<bfs::path>() but paths with escaped spaces break bpo e.g.
256 // std::exception::what: the argument ('/path/with/white\ space') for option '--data-dir' is invalid
257 auto workaround = options["data-dir"].as<std::string>();
258 bfs::path data_dir = workaround;
259 if( data_dir.is_relative() )
260 data_dir = bfs::current_path() / data_dir;
261 my->_data_dir = data_dir;
262 }
263
264 if( options.count( "config-dir" ) ) {
265 auto workaround = options["config-dir"].as<std::string>();
266 bfs::path config_dir = workaround;
267 if( config_dir.is_relative() )
268 config_dir = bfs::current_path() / config_dir;
269 my->_config_dir = config_dir;
270 }
271
272 auto workaround = options["logconf"].as<std::string>();
273 bfs::path logconf = workaround;
274 if( logconf.is_relative() )
275 logconf = my->_config_dir / logconf;

Callers

nothing calls this directly

Calls 13

existsFunction · 0.85
is_relativeMethod · 0.80
parseMethod · 0.80
get_stateMethod · 0.80
runMethod · 0.45
countMethod · 0.45
c_strMethod · 0.45
stringMethod · 0.45
findMethod · 0.45
endMethod · 0.45
nameMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected