File: argProcessor.cpp

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (61 lines) | stat: -rwxr-xr-x 954 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "argProcessor.hpp"
#include <stdlib.h>
// #include <cstdlib>

ArgProcessor::ArgProcessor(int argc, char* argv[]) {
  
  for (int i=1; i < argc; i++) {
	char* arg = argv[i];
	string myArg (arg);
	if (arg[0] == '-') { 
	
	  argSet[myArg] = true;
  	  	  
	  // see if next argument is another arg or value:
	  if (i != argc-1) {
		// value:
		string nextArg (argv[i+1]);
		argVal[myArg] = nextArg;
	  }
	}
  }
  
}


bool ArgProcessor::isArgSet(string arg) {
  
  map<string,bool>::const_iterator it;

  it = argSet.find(arg);
  if (it != argSet.end()) {
	return(true);
  }
  else {
	return(false);
  }
}

int ArgProcessor::getIntVal(string arg) {
  
  return(atoi(argVal[arg].c_str()));
  
}

long ArgProcessor::getLongVal(string arg) {
  return(atol(argVal[arg].c_str()));
}


float ArgProcessor::getFloatVal(string arg) {
  
  return(atof(argVal[arg].c_str()));
}


string ArgProcessor::getStringVal(string arg) {
  
  return(argVal[arg]);
}