Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
standalone/main.C File Reference
#include <iostream>
#include <vector>
#include <list>
#include <sstream>
#include "clop.H"
Include dependency graph for standalone/main.C:

Go to the source code of this file.

Functions

void RFLUMP (const char *, int *, long int)
 
void Usage (const string &pn)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 48 of file standalone/main.C.

References AddOp(), GetOp(), RFLUMP(), stripdir(), Usage(), and Vectize().

49 {
50  // Get the commandline into a string vector - it's easier
51  // to deal with that way.
52  vector<string> args = Vectize((const char **)argv,argc);
53 
54  // Get the name of the executable by stripping off any leading
55  // directory names
56  string program_name(stripdir(args[0]));
57 
58  // Specify the allowable options to the program
59  AddOp("casename",'c');
60  AddOp("verbosity",'v');
61  AddOp("help",'h');
62 
63  // Declare some variables for command line argument handling
64  string casename;
65  string sverb;
66  int verbosity;
67  bool help;
68  bool isset;
69 
70  // See if the help option is specified, if so give'm the usage text
71  if(help = GetOp("help",args)){
72  Usage(program_name);
73  exit(0);
74  }
75 
76  // Process casename option, if it's not set then fail
77  if(GetOp("casename",casename,args)){
78  if(casename.empty()){ // casename was empty
79  cerr << program_name
80  << ": Expected casename after casename option."
81  << " Use -h for usage instructions."
82  << endl;
83  exit(1);
84  }
85  }
86  else{ // option not specified (but it's required!)
87  cerr << program_name
88  << ": Missing required casename option."
89  << " Use -h for usage instructions."
90  << endl;
91  exit(1);
92  }
93 
94  // Process verbosity option
95  if(GetOp("verbosity",sverb,args)){
96  if(sverb.empty()){
97  cerr << program_name
98  << ": Expected verbosity level. "
99  << "Use -h for usage instructions." << endl;
100  exit(1);
101  }
102  istringstream Istr(sverb);
103  Istr >> verbosity;
104  if(verbosity < 0 || verbosity > 2){ // Some jerk specified a non numeric or negative
105  cerr << program_name
106  << ": Invalid verbosity value. Use -h for usage "
107  << "instructions." << endl;
108  exit(1);
109  }
110  }
111  else{ // Default verbosity
112  verbosity = 1;
113  }
114 
115  RFLUMP(casename.c_str(),&verbosity,casename.length());
116 }
const string stripdir(const string &)
bool GetOp(const string &ops, const vector< string > &args)
void AddOp(const string &lo, const char &so)
void Usage(const string &pn)
void RFLUMP(const char *, int *, long int)
vector< string > Vectize(const char **)
Definition: clop.C:182

Here is the call graph for this function:

void RFLUMP ( const char *  ,
int *  ,
long  int 
)

Referenced by main().

Here is the caller graph for this function:

void Usage ( const string &  pn)

Definition at line 37 of file standalone/main.C.

Referenced by main().

38 {
39  cout << endl << "Usage: " << pn << " -c <casename> [-v 0-2]" << endl << endl
40  << " -c | --casename : Specifies the casename." << endl
41  << " -v | --verbosity : 0 - Quiet" << endl
42  << " 1 - Moderately verbose" << endl
43  << " 2 - Ridiculously verbose" << endl
44  << endl;
45 }

Here is the caller graph for this function: