42 class ProgramArg :
public std::map<std::string, std::string> {
45 for(
unsigned int i=0;i<sz;i++) insert(pair(defaults[i][0], defaults[i][1]));
48 void parse(
int argc,
char* argv[], std::string
usage,
int offset = 1) {
49 for(
int i = offset; i < argc; i++) {
51 unsigned int equal = flag.find(
'=');
52 if(equal == string::npos) {
53 cerr <<
"Command line error: " << argv[i] << endl << usage << endl;
56 string name = flag.substr(0, equal);
57 string value = flag.substr(equal + 1);
58 if(find(name) == end()) {
59 cerr << name << endl << usage << endl;
62 operator[](name) = value;
66 void print(std::ostream& out = std::cout) {
67 out <<
"Argument values:" << endl;
68 for(iterator it = begin(); it != end(); it++)
69 out << (*it).first <<
" = " << (*it).second << endl;
77 {
"-o",
"ansys2pml-output.pml" },
81 "ansys2pml -n=nodes1.txt,..,nodesN.txt [-e=elem1.txt,..elemN.txt] [-t=ELEM_TYPE] [-o=output]\n"
82 "Transform nodes and elements ANSYS files to a PML\n"
83 "To produce a correct PML, the file are to be ordered the same way they were exported in ANSYS\n"
84 "(Note no space around '=')\n"
85 "Where the flags can be any of: \n"
86 " -n input node files separated by a comma\n"
87 " -e input element files separated by a comma\n"
88 " -t element type (see below)\n"
89 " -o output PML file name\n"
91 "Element type defines the element geometry:\n"
92 "- TETRAHEDRON elements are tetrahedron, node index are integer #1, #2, #3 and #5 for each element file line\n"
93 "- QUAD elements are 2D quads, node index are integer #1, #2, #3 and #4 (I,J,K,L) for each element file line\n"
ProgramArg(std::string defaults[][2], unsigned int sz)
Definition: programarg.h:44
ProgramArg argVal(defaultsArg, sizeof defaultsArg/sizeof *defaultsArg)
void print(std::ostream &out=std::cout)
Definition: programarg.h:66
string defaultsArg[][2]
Definition: programarg.h:73
TODO Comment class here.
Definition: programarg.h:42
void parse(int argc, char *argv[], std::string usage, int offset=1)
Definition: programarg.h:48
const char * usage
Definition: programarg.h:80