EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Commands.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EVEToolCommand
 

Functions

const EVEToolCommandFindCommand (const char *name)
 Finds a command. More...
 
const EVEToolCommandFindCommand (const std::string &name)
 Finds a command. More...
 
void ProcessCommand (const Seperator &cmd)
 Processed given command. More...
 
void ProcessString (const char *str)
 Processes given string as command. More...
 
void ProcessString (const std::string &str)
 Processes given string as command. More...
 
void ProcessFile (FILE *file)
 Loads commands from given file. More...
 
void ProcessFile (const char *filename)
 Loads commands from given file. More...
 
void ProcessFile (const std::string &filename)
 Loads commands from given file. More...
 

Variables

const EVEToolCommand EVETOOL_COMMANDS []
 
const size_t EVETOOL_COMMAND_COUNT
 
const char *const CACHE_DIR
 
const char *const LOG_SETTINGS_FILE
 
const char *const LOG_FILE
 

Function Documentation

const EVEToolCommand* FindCommand ( const char *  name)

Finds a command.

Parameters
[in]nameName of command.
Returns
Found command; NULL if not found.

Definition at line 64 of file Commands.cpp.

References FindCommand().

Referenced by FindCommand(), PrintHelp(), and ProcessCommand().

65 {
66  return FindCommand( std::string( name ) );
67 }
const EVEToolCommand * FindCommand(const char *name)
Finds a command.
Definition: Commands.cpp:64

Here is the call graph for this function:

Here is the caller graph for this function:

const EVEToolCommand* FindCommand ( const std::string &  name)

Finds a command.

Parameters
[in]nameName of command.
Returns
Found command; NULL if not found.

Definition at line 69 of file Commands.cpp.

References EVETOOL_COMMAND_COUNT, and EVEToolCommand::name.

70 {
71  for( size_t i = 0; i < EVETOOL_COMMAND_COUNT; ++i )
72  {
73  const EVEToolCommand* c = &EVETOOL_COMMANDS[i];
74 
75  if( c->name == name )
76  return c;
77  }
78 
79  return NULL;
80 }
const char * name
Definition: Commands.h:33
const EVEToolCommand EVETOOL_COMMANDS[]
Definition: Commands.cpp:48
const size_t EVETOOL_COMMAND_COUNT
Definition: Commands.cpp:62
void ProcessCommand ( const Seperator cmd)

Processed given command.

Parameters
[in]cmdCommand to be processed.

Definition at line 82 of file Commands.cpp.

References Seperator::arg(), EVEToolCommand::callback, FindCommand(), and sLog.

Referenced by ProcessString().

83 {
84  const char* cmdName = cmd.arg( 0 ).c_str();
85  const EVEToolCommand* c = FindCommand( cmdName );
86 
87  if( NULL == c )
88  sLog.Error( "input", "Unknown command '%s'.", cmdName );
89  else
90  ( *c->callback )( cmd );
91 }
const std::string & arg(size_t index) const
Definition: Seperator.h:43
void(* callback)(const Seperator &cmd)
Definition: Commands.h:35
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
const EVEToolCommand * FindCommand(const char *name)
Finds a command.
Definition: Commands.cpp:64

Here is the call graph for this function:

Here is the caller graph for this function:

void ProcessFile ( FILE *  file)

Loads commands from given file.

Parameters
[in]fileFile to load commands from.

Definition at line 76 of file eve-tool.cpp.

References ProcessString().

Referenced by LoadScript(), main(), and ProcessFile().

77 {
78  std::string cmd;
79 
80  while( true )
81  {
82  char input = fgetc( file );
83 
84  if( '\n' == input || EOF == input )
85  {
86  if( !cmd.empty() )
87  {
88  ProcessString( cmd );
89  cmd.clear();
90  }
91 
92  if( EOF == input )
93  break;
94  }
95  else
96  cmd += input;
97  }
98 }
void ProcessString(const char *str)
Processes given string as command.
Definition: eve-tool.cpp:66

Here is the call graph for this function:

Here is the caller graph for this function:

void ProcessFile ( const char *  filename)

Loads commands from given file.

Parameters
[in]filenameName of file to load commands from.

Definition at line 100 of file eve-tool.cpp.

References ProcessFile().

101 {
102  ProcessFile( std::string( filename ) );
103 }
void ProcessFile(FILE *file)
Loads commands from given file.
Definition: eve-tool.cpp:76

Here is the call graph for this function:

void ProcessFile ( const std::string &  filename)

Loads commands from given file.

Parameters
[in]filenameName of file to load commands from.

Definition at line 105 of file eve-tool.cpp.

References ProcessFile(), and sLog.

106 {
107  FILE* file = fopen( filename.c_str(), "r" );
108  if( NULL == file )
109  {
110  sLog.Error( "input", "Unable to open script '%s'.", filename.c_str() );
111  return;
112  }
113 
114  sLog.Log( "input", "Queuing commands from script '%s'.", filename.c_str() );
115  ProcessFile( file );
116 
117  if( feof( file ) )
118  sLog.Success( "input", "Load of script '%s' successfully completed.", filename.c_str() );
119  else
120  sLog.Error( "input", "Error occured while reading script '%s'.", filename.c_str() );
121 
122  fclose( file );
123 }
void ProcessFile(FILE *file)
Loads commands from given file.
Definition: eve-tool.cpp:76
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Here is the call graph for this function:

void ProcessString ( const char *  str)

Processes given string as command.

Parameters
[in]strString to be processed.

Definition at line 66 of file eve-tool.cpp.

References ProcessCommand().

Referenced by ProcessFile(), and ProcessString().

67 {
68  ProcessCommand( Seperator( str ) );
69 }
Separates string to arguments.
Definition: Seperator.h:36
void ProcessCommand(const Seperator &cmd)
Processed given command.
Definition: Commands.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

void ProcessString ( const std::string &  str)

Processes given string as command.

Parameters
[in]strString to be processed.

Definition at line 71 of file eve-tool.cpp.

References ProcessString().

72 {
73  ProcessString( str.c_str() );
74 }
void ProcessString(const char *str)
Processes given string as command.
Definition: eve-tool.cpp:66

Here is the call graph for this function:

Variable Documentation

const char* const CACHE_DIR

Cache directory to be used.

Definition at line 30 of file eve-tool.cpp.

const size_t EVETOOL_COMMAND_COUNT

Number of available commands.

Definition at line 62 of file Commands.cpp.

Referenced by FindCommand(), and PrintHelp().

const EVEToolCommand EVETOOL_COMMANDS[]

Array of all available commands in eve-tool.

Definition at line 48 of file Commands.cpp.

const char* const LOG_FILE

Log file to be used.

Definition at line 31 of file eve-tool.cpp.

Referenced by main().

const char* const LOG_SETTINGS_FILE

Log settings file to be used.

Definition at line 32 of file eve-tool.cpp.

Referenced by main().