GeNN  2.2.3
GPU enhanced Neuronal Networks (GeNN)
command_line_processing.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------
2  Author: Thomas Nowotny
3 
4  Institute: Center for Computational Neuroscience and Robotics
5  University of Sussex
6  Falmer, Brighton BN1 9QJ, UK
7 
8  email to: T.Nowotny@sussex.ac.uk
9 
10  initial version: 2015-09-12
11 
12 --------------------------------------------------------------------------*/
13 
14 //--------------------------------------------------------------------------
19 //--------------------------------------------------------------------------
20 
21 #ifndef COMMAND_LINE_PROCESSING
22 #define COMMAND_LINE_PROCESSING
23 
24 #include <string>
25 
26 using namespace std;
27 
28 
29 string toUpper(string s)
30 {
31  for (unsigned int i= 0; i < s.length(); i++) {
32  s[i]= toupper(s[i]);
33  }
34  return s;
35 }
36 
37 string toLower(string s)
38 {
39  for (unsigned int i= 0; i < s.length(); i++) {
40  s[i]= tolower(s[i]);
41  }
42  return s;
43 }
44 
45 int extract_option(char *op, string &option)
46 {
47  string sop= op;
48  size_t pos= sop.find("=");
49  if (pos == string::npos) {
50  return -1;
51  }
52  option= sop.substr(0,pos);
53 
54  return 0;
55 }
56 
57 int extract_bool_value(char *op, unsigned int &val)
58 {
59  string sop= op;
60  size_t pos= sop.find("=");
61  if (pos == string::npos) {
62  return -1;
63  }
64  string sval= sop.substr(pos+1);
65  int tmpval= atoi(sval.c_str());
66  if ((tmpval != 0) && (tmpval != 1)) {
67  return -1;
68  }
69  val= tmpval;
70 
71  return 0;
72 }
73 
74 int extract_string_value(char *op, string &val)
75 {
76  string sop= op;
77  size_t pos= sop.find("=");
78  if (pos == string::npos) {
79  return -1;
80  }
81  val= sop.substr(pos+1);
82 
83  return 0;
84 }
85 
86 #endif
int extract_string_value(char *op, string &val)
Definition: command_line_processing.h:74
int extract_option(char *op, string &option)
Definition: command_line_processing.h:45
string toUpper(string s)
Definition: command_line_processing.h:29
int extract_bool_value(char *op, unsigned int &val)
Definition: command_line_processing.h:57
string toLower(string s)
Definition: command_line_processing.h:37
string option
Definition: parse_options.h:6