1 |
|
|
/*************************************** |
2 |
|
|
Auteur : Pierre Aubert |
3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
4 |
|
|
Licence : CeCILL-C |
5 |
|
|
****************************************/ |
6 |
|
|
|
7 |
|
|
#include "string_utils.h" |
8 |
|
|
#include "convertToString.h" |
9 |
|
|
#include "OptionParser.h" |
10 |
|
|
|
11 |
|
|
#include "phoenix_mock.h" |
12 |
|
|
|
13 |
|
|
///Create the OptionParser of this program |
14 |
|
|
/** @return OptionParser of this program |
15 |
|
|
*/ |
16 |
|
2 |
OptionParser createOptionParser(){ |
17 |
✓✓ |
4 |
OptionParser parser(true, __PROGRAM_VERSION__); |
18 |
✓✓ |
2 |
parser.setExampleLongOption("phoenix_mock_info --input=file.pmock"); |
19 |
✓✓ |
2 |
parser.setExampleShortOption("phoenix_mock_info -i file2.mock file2.pmock"); |
20 |
|
|
|
21 |
✓✓✓✓
|
2 |
parser.addOption("input", "i", OptionType::FILENAME, true, "List of input mock to get the info"); |
22 |
|
2 |
return parser; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
///Merge mock files |
26 |
|
|
/** @param vecInputFile : vector of input files to print the info |
27 |
|
|
* @return true on success, false otherwise |
28 |
|
|
*/ |
29 |
|
2 |
bool infoMock(const std::vector<std::string> & vecInputFile){ |
30 |
|
2 |
bool b(true); |
31 |
✓✓✓✗ ✓✓ |
4 |
for(std::vector<std::string>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end() && b; ++itFile){ |
32 |
|
4 |
std::vector<std::vector<char> > vecTmpFile; |
33 |
✓✓✓ |
2 |
if(data_load(*itFile, vecTmpFile)){ |
34 |
|
1 |
size_t nbMessageIn(vecTmpFile.size()); |
35 |
✓✓✓✓ ✓ |
1 |
std::cout << "Mock '"<<(*itFile)<<"' : nbMessage = " << nbMessageIn << std::endl; |
36 |
|
|
}else{ |
37 |
|
1 |
b = false; |
38 |
|
|
} |
39 |
|
|
} |
40 |
|
2 |
return b; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
2 |
int main(int argc, char** argv){ |
44 |
✓ |
4 |
OptionParser parser = createOptionParser(); |
45 |
✓ |
2 |
parser.parseArgument(argc, argv); |
46 |
✓ |
2 |
const OptionMode & defaultMode = parser.getDefaultMode(); |
47 |
|
2 |
std::vector<std::string> vecInputFile; |
48 |
✓✓ |
2 |
defaultMode.getValue(vecInputFile, "input"); |
49 |
✓ |
2 |
return infoMock(vecInputFile) - 1; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
|