Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
datagen
v5data_gen
v5data_genArgs.cpp
Go to the documentation of this file.
1
7
#include <
datagen/v5data_gen/v5data_genArgs.hpp
>
8
#include <
datagen/v5data_gen/v5data_genMsgs.hpp
>
9
#include <
exception/CommandLineException.hpp
>
10
11
using namespace
bil;
12
13
14
std::string
outputPath
;
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
outputPath
.clear();
24
25
// examine all program parameters
26
std::string arg;
27
size_t
positionalOptIndex = 0;
28
for
(
size_t
i = 1; i < static_cast<size_t>(argc); ++i)
29
{
30
// copy parameter
31
arg.assign(argv[i]);
32
// no switches allowed
33
if
(
'-'
== arg[0])
34
{
35
std::string msg =
ERROR_UNKNOWN_OPTION_1_MSG
;
36
msg.append(arg);
37
msg.append(
ERROR_UNKNOWN_OPTION_2_MSG
);
38
throw
CommandLineException
(msg);
39
}
40
// process positional arguments
41
else
42
{
43
if
(0 == positionalOptIndex)
outputPath
= arg;
44
else
throw
CommandLineException
(
ERROR_TOO_MANY_PARAMETERS_MSG
);
45
positionalOptIndex++;
46
}
47
}
48
49
// enforce that output path ends with path separator
50
if
(
outputPath
.empty())
return
;
51
char
lastChar =
outputPath
[
outputPath
.size()-1];
52
if
(
'/'
== lastChar)
return
;
53
if
(
'\\'
== lastChar)
return
;
54
outputPath
.push_back(
'/'
);
55
}
Generated on Wed Aug 8 2012 21:57:40 for Bitstream Interpretation Library (BIL) by
1.8.1.1