MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / ProcessCommand

Method ProcessCommand

PanzerChasm/commands_processor.cpp:25–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void CommandsProcessor::ProcessCommand( const char* const command_string )
26{
27 const std::pair< std::string, CommandsArguments > command_parsed= ParseCommad( command_string );
28 if( command_parsed.first.empty() )
29 return;
30
31 for( unsigned int m= 0u; m < commands_maps_.size(); )
32 {
33 const CommandsMapConstPtr commads_map= commands_maps_[m].lock();
34 if( commads_map != nullptr )
35 {
36 const auto it= commads_map->find( command_parsed.first );
37 if( it != commads_map->end() )
38 {
39 // Found it
40 it->second( command_parsed.second );
41 return;
42 }
43
44 m++;
45 }
46 else
47 {
48 // Remove expired weak pointers.
49 if( m != commands_maps_.size() - 1u )
50 commands_maps_[m]= commands_maps_.back();
51 commands_maps_.pop_back();
52 }
53 }
54
55 // Search settins variable.
56 if( settings_.IsValue( command_parsed.first.c_str() ) )
57 {
58 if( command_parsed.second.empty() )
59 Log::Info( "\"", command_parsed.first, "\" is \"", settings_.GetString( command_parsed.first.c_str() ), "\"" );
60 else
61 settings_.SetSetting( command_parsed.first.c_str(), command_parsed.second.front().c_str() );
62 }
63 else
64 Log::Info( command_parsed.first, ": command not found" );
65}
66
67std::string CommandsProcessor::TryCompleteCommand( const char* command_string ) const
68{

Callers 1

ProcessEventsMethod · 0.80

Calls 3

IsValueMethod · 0.80
GetStringMethod · 0.80
SetSettingMethod · 0.80

Tested by

no test coverage detected