Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
datagen
xdlrc_convert
xdlrc_convertArgs.cpp
Go to the documentation of this file.
1
6
#include <
datagen/xdlrc_convert/xdlrc_convertArgs.hpp
>
7
#include <
datagen/xdlrc_convert/xdlrc_convertMsgs.hpp
>
8
#include <
exception/CommandLineException.hpp
>
9
10
using namespace
bil;
11
12
13
std::string
xdlrcFileName
;
14
std::string
outFileName
;
15
16
17
void
parseCommandLine
(
int
argc,
char
** argv)
18
{
19
// test if there are enough parameters
20
if
(1 >= argc)
throw
CommandLineException
(
ERROR_TOO_FEW_PARAMETERS_MSG
);
21
22
// set program parameters to standard values
23
xdlrcFileName
.clear();
24
outFileName
.clear();
25
26
// examine all program parameters
27
std::string arg;
28
size_t
positionalOptIndex = 0;
29
for
(
size_t
i = 1; i < static_cast<size_t>(argc); ++i)
30
{
31
// copy parameter
32
arg.assign(argv[i]);
33
// no switches allowed
34
if
(
'-'
== arg[0])
35
{
36
std::string msg =
ERROR_UNKNOWN_OPTION_1_MSG
;
37
msg.append(arg);
38
msg.append(
ERROR_UNKNOWN_OPTION_2_MSG
);
39
throw
CommandLineException
(msg);
40
}
41
// process positional arguments
42
else
43
{
44
switch
(positionalOptIndex)
45
{
46
case
0:
xdlrcFileName
= arg;
break
;
47
case
1:
outFileName
= arg;
break
;
48
default
:
throw
CommandLineException
(
ERROR_TOO_MANY_PARAMETERS_MSG
);
49
}
50
positionalOptIndex++;
51
}
52
}
53
54
// if out filename not set, set it
55
if
(
outFileName
.empty())
56
{
57
size_t
pos =
xdlrcFileName
.find_last_of(
"."
);
58
std::string xdlrcFileNameWithoutExt =
xdlrcFileName
.substr(0, pos);
59
outFileName
= xdlrcFileNameWithoutExt +
DEVICE_FILE_EXT
;
60
}
61
}
Generated on Wed Aug 8 2012 21:57:40 for Bitstream Interpretation Library (BIL) by
1.8.1.1