Bitstream Interpretation Library (BIL)  0.1
xdlcmpArgs.cpp
Go to the documentation of this file.
1 
9 
10 using namespace bil;
11 
12 std::string xdlRefFileName;
13 std::string xdlTestFileName;
14 std::string reportFileName;
15 std::string dataPathName;
16 
17 
18 void parseCommandLine(int argc, char** argv)
19 {
20  // set program parameters to standard values
21  xdlRefFileName.clear();
22  xdlTestFileName.clear();
23  reportFileName.clear();
24  dataPathName.clear();
25 
26  // examine all program parameters
27  std::string arg;
28  size_t positionalOptIndex = 0;
29  size_t argCount = static_cast<size_t>(argc);
30  for (size_t i = 1; i < argCount; ++i)
31  {
32  // copy parameter
33  arg.assign(argv[i]);
34  // process switches
35  if ('-' == arg[0])
36  {
37  if ("-dp" == arg)
38  {
39  if ((++i) >= argCount)
41  dataPathName.assign(argv[i]);
42  }
43  else
44  {
45  std::string msg = ERROR_UNKNOWN_OPTION_1_MSG;
46  msg.append(arg);
47  msg.append(ERROR_UNKNOWN_OPTION_2_MSG);
48  throw CommandLineException(msg);
49  }
50  }
51  // process positional arguments
52  else
53  {
54  switch (positionalOptIndex)
55  {
56  case 0: xdlRefFileName = arg; break;
57  case 1: xdlTestFileName = arg; break;
58  case 2: reportFileName = arg; break;
60  }
61  positionalOptIndex++;
62  }
63  }
64 
65  // first XDL file name must not be empty
67 
68  // second XDL file name must not be empty
70 
71  // output file must not be empty
73 
74  // if data path set, enforce that it ends with path separator
75  if (!dataPathName.empty())
76  {
77  char lastChar = dataPathName[dataPathName.size()-1];
78  if (('/' != lastChar) && ('\\' != lastChar)) dataPathName.push_back('/');
79  }
80 }