Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
datagen
v5cfgmap_gen
v5cfgmap_genArgs.cpp
Go to the documentation of this file.
1
7
#include <
datagen/v5cfgmap_gen/v5cfgmap_genArgs.hpp
>
8
#include <
datagen/v5cfgmap_gen/v5cfgmap_genMsgs.hpp
>
9
#include <
exception/CommandLineException.hpp
>
10
11
using namespace
bil;
12
13
14
std::string
deviceFileName
;
15
std::string
dataPathName
;
16
std::string
mapFileName
;
17
18
19
void
parseCommandLine
(
int
argc,
char
** argv)
20
{
21
// test if there are enough parameters
22
if
(1 >= argc)
throw
CommandLineException
(
ERROR_TOO_FEW_PARAMETERS_MSG
);
23
24
// set program parameters to standard values
25
deviceFileName
.clear();
26
dataPathName
.clear();
27
mapFileName
.clear();
28
29
// examine all program parameters
30
std::string arg;
31
size_t
positionalOptIndex = 0;
32
for
(
size_t
i = 1; i < static_cast<size_t>(argc); ++i)
33
{
34
// copy parameter
35
arg.assign(argv[i]);
36
// no switches allowed
37
if
(
'-'
== arg[0])
38
{
39
std::string msg =
ERROR_UNKNOWN_OPTION_1_MSG
;
40
msg.append(arg);
41
msg.append(
ERROR_UNKNOWN_OPTION_2_MSG
);
42
throw
CommandLineException
(msg);
43
}
44
// process positional arguments
45
else
46
{
47
switch
(positionalOptIndex)
48
{
49
case
0:
deviceFileName
= arg;
break
;
50
case
1:
dataPathName
= arg;
break
;
51
case
2:
mapFileName
= arg;
break
;
52
default
:
throw
CommandLineException
(
ERROR_TOO_MANY_PARAMETERS_MSG
);
53
}
54
positionalOptIndex++;
55
}
56
}
57
58
// if data path set, enforce that it ends with path separator
59
if
(!
dataPathName
.empty())
60
{
61
char
lastChar =
dataPathName
[
dataPathName
.size()-1];
62
if
((
'/'
!= lastChar) && (
'\\'
!= lastChar))
dataPathName
.push_back(
'/'
);
63
}
64
65
// if mapFileName not set, set it
66
if
(
mapFileName
.empty())
67
{
68
size_t
pos =
deviceFileName
.find_last_of(
"."
);
69
std::string deviceFileNameWithoutExt =
deviceFileName
.substr(0, pos);
70
mapFileName
= deviceFileNameWithoutExt +
MAP_FILE_EXT
;
71
}
72
}
Generated on Wed Aug 8 2012 21:57:40 for Bitstream Interpretation Library (BIL) by
1.8.1.1