mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Console.cpp
Go to the documentation of this file.
1 
6 #include "Console.h"
7 
8 using namespace std;
9 
11 
18 string Console::getCommand( string commandString ) {
19  size_t space = commandString.find( ' ' );
20  if( space == string::npos )
21  return commandString;
22  else
23  return commandString.substr( 0, space );
24 }
25 
27 
36 char Console::getSingleCharacterOption( string commandString ) {
37  size_t space = commandString.find( ' ' );
38  if( commandString.length() > space+1 && space != string::npos )
39  return commandString[++space];
40  return 0;
41 }
42 
44 
51 string Console::getOption( string commandString ) {
52  size_t firstSpace = commandString.find( ' ' );
53  if( firstSpace == string::npos )// if no space return nothing
54  return "";
55 
56  size_t secondSpace = commandString.find( ' ', ++firstSpace );
57  if( secondSpace == string::npos)
58  return commandString.substr( firstSpace );
59  else
60  return commandString.substr( firstSpace, secondSpace - firstSpace );
61 }