PhoenixClockMock  1.0.0
Tool to manipulate mock of clock
Loading...
Searching...
No Matches
main_merge.cpp
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#include "OptionParser.h"
8
10
12
14OptionParser createOptionParser(){
15 OptionParser parser(true, __PROGRAM_VERSION__);
16 parser.setExampleLongOption("phoenix_clock_mock_merge --input=file.clockmock --output=merged.clockmock");
17 parser.setExampleShortOption("phoenix_clock_mock_merge -i file2.clockmock file2.clockmock -o merged.clockmock");
18
19 parser.addOption("input", "i", OptionType::FILENAME, true, "List of input mock to be merged");
20
21 PString defaultOutputFile("./merged.clockmock");
22 parser.addOption("output", "o", defaultOutputFile, "Name of the output merged mock file");
23 return parser;
24}
25
27
31bool mergeMock(const std::vector<PString> & vecInputFile, const PString & outputFile){
32 VecTime vecMessage;
33 bool b(true);
34 for(std::vector<PString>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end() && b; ++itFile){
35 VecTime vecTmpFile;
36 if(data_load(*itFile, vecTmpFile)){
37 concatenateVecTime(vecMessage, vecTmpFile);
38 }else{
39 b = false;
40 }
41 }
42 if(b){
43 b &= data_save(outputFile, vecMessage);
44 }
45 return b;
46}
47
48int main(int argc, char** argv){
49 OptionParser parser = createOptionParser();
50 parser.parseArgument(argc, argv);
51
52 const OptionMode & defaultMode = parser.getDefaultMode();
53 std::vector<PString> vecInputFile;
54 PString outputFile("");
55 defaultMode.getValue(vecInputFile, "input");
56 defaultMode.getValue(outputFile, "output");
57 return mergeMock(vecInputFile, outputFile) - 1;
58}
59
60
int main(int argc, char **argv)
bool mergeMock(const std::vector< PString > &vecInputFile, const PString &outputFile)
Merge mock files.
OptionParser createOptionParser()
Create the OptionParser of this program.
void concatenateVecTime(VecTime &vecOutput, const VecTime vecInput)
Concatenate vector of message into an other one.