UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScopedCommand.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 class ScopedCommand {
6 private:
7  const std::string _scopeLeaveCommand;
8 public:
9  ScopedCommand (const std::string& scopeEnterCommand, const std::string& scopeLeaveCommand) :
10  _scopeLeaveCommand(scopeLeaveCommand)
11  {
12  Cmd_ExecuteString("%s", scopeEnterCommand.c_str());
13  }
14 
15  ScopedCommand (const std::string& command, const std::string& scopeEnterParameter, const std::string& scopeLeaveParameter) :
16  _scopeLeaveCommand(command + " " + scopeLeaveParameter)
17  {
18  const std::string enter = command + " " + scopeEnterParameter;
19  Cmd_ExecuteString("%s", enter.c_str());
20  }
21 
23  {
24  Cmd_ExecuteString("%s", _scopeLeaveCommand.c_str());
25  }
26 };
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
Definition: cmd.cpp:1007
const std::string _scopeLeaveCommand
Definition: ScopedCommand.h:7
ScopedCommand(const std::string &command, const std::string &scopeEnterParameter, const std::string &scopeLeaveParameter)
Definition: ScopedCommand.h:15
ScopedCommand(const std::string &scopeEnterCommand, const std::string &scopeLeaveCommand)
Definition: ScopedCommand.h:9