PhoenixMock  1.1.0
Tools to split/merge/print mock
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
9#include "phoenix_mock.h"
10
12
14OptionParser createOptionParser(){
15 OptionParser parser(true, __PROGRAM_VERSION__);
16 parser.setExampleLongOption("phoenix_mock_merge --input=file.pmock --output=merged.pmock");
17 parser.setExampleShortOption("phoenix_mock_merge -i file2.mock file2.pmock -o merged.pmock");
18
19 parser.addOption("input", "i", OptionType::FILENAME, true, "List of input mock to be merged");
20
21 PString defaultOutputFile("./merged.pmock");
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 std::vector<std::vector<char> > vecMessage;
33 bool b(true);
34 for(std::vector<PString>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end() && b; ++itFile){
35 std::vector<std::vector<char> > vecTmpFile;
36 if(data_load(*itFile, vecTmpFile)){
37 concatenateVecMessage(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 concatenateVecMessage(std::vector< std::vector< char > > &vecOutput, const std::vector< std::vector< char > > vecInput)
Concatenate vector of message into an other one.