Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegisterPythonWithCommandInterpreter Class Reference

#include <command.h>

Public Member Functions

 RegisterPythonWithCommandInterpreter (commandI *cI)
 
void runPy (std::string &argsin)
 

Detailed Description

Definition at line 154 of file command.h.

Constructor & Destructor Documentation

RegisterPythonWithCommandInterpreter::RegisterPythonWithCommandInterpreter ( commandI cI)
explicit

Definition at line 1399 of file command.cpp.

References commandI::addCommand(), and runPy().

1400 {
1403  addTo->addCommand( l, "python" );
1404 }

Member Function Documentation

void RegisterPythonWithCommandInterpreter::runPy ( std::string &  argsin)

Definition at line 1407 of file command.cpp.

Referenced by RegisterPythonWithCommandInterpreter().

1408 {
1409  string pyRunString;
1410  pyRunString.append( argsin ); //append the arguments in to the string to run
1411  size_t x = pyRunString.find( "python " ); //strip out the name of the command
1412  //and the first space
1413  if (x == 0)
1414  pyRunString.replace( x, 7, "" ); //replace here
1415 //this method was copied from somewhere else in the vegastrike source
1416  //now replace <BR> with \r\n
1417  {
1418  size_t x = pyRunString.find( "<BR>" );
1419  while (x != string::npos) {
1420  pyRunString.replace( x, 4, "\r\n" );
1421  x = pyRunString.find( "<BR>" );
1422  }
1423  }
1424 
1425  char *temppython = strdup( pyRunString.c_str() ); //copy to a char *
1426  PyRun_SimpleString( temppython ); //run it
1427  Python::reseterrors();
1428  free( temppython ); //free the copy char *
1429 }

The documentation for this class was generated from the following files: