Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
test
xdlcmp
xdlcmpArgs.cpp
Go to the documentation of this file.
1
6
#include <
test/xdlcmp/xdlcmpArgs.hpp
>
7
#include <
test/xdlcmp/xdlcmpMsgs.hpp
>
8
#include <
exception/CommandLineException.hpp
>
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)
40
throw
CommandLineException
(
ERROR_NO_DATAPATH_MSG
);
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
;
59
default
:
throw
CommandLineException
(
ERROR_TOO_MANY_PARAMETERS_MSG
);
60
}
61
positionalOptIndex++;
62
}
63
}
64
65
// first XDL file name must not be empty
66
if
(
xdlRefFileName
.empty())
throw
CommandLineException
(
ERROR_NO_REFXDL_FILE_MSG
);
67
68
// second XDL file name must not be empty
69
if
(
xdlTestFileName
.empty())
throw
CommandLineException
(
ERROR_NO_TESTXDL_FILE_MSG
);
70
71
// output file must not be empty
72
if
(
reportFileName
.empty())
throw
CommandLineException
(
ERROR_NO_REPORT_FILE_MSG
);
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
}
Generated on Wed Aug 8 2012 21:57:41 for Bitstream Interpretation Library (BIL) by
1.8.1.1