PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main_merge.cpp File Reference
#include "string_utils.h"
#include "convertToString.h"
#include "OptionParser.h"
#include "phoenix_mock.h"
+ Include dependency graph for main_merge.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program. More...
 
int main (int argc, char **argv)
 
bool mergeMock (const std::vector< std::string > &vecInputFile, const std::string &outputFile)
 Merge mock files. More...
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 16 of file main_merge.cpp.

16  {
17  OptionParser parser(true, __PROGRAM_VERSION__);
18  parser.setExampleLongOption("phoenix_mock_merge --input=file.pmock --output=merged.pmock");
19  parser.setExampleShortOption("phoenix_mock_merge -i file2.mock file2.pmock -o merged.pmock");
20 
21  parser.addOption("input", "i", OptionType::FILENAME, true, "List of input mock to be merged");
22 
23  std::string defaultOutputFile("./merged.pmock");
24  parser.addOption("output", "o", defaultOutputFile, "Name of the output merged mock file");
25  return parser;
26 }

References OptionType::FILENAME, and createReleaseCurl::parser.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file main_merge.cpp.

50  {
52  parser.parseArgument(argc, argv);
53 
54  const OptionMode & defaultMode = parser.getDefaultMode();
55  std::vector<std::string> vecInputFile;
56  std::string outputFile("");
57  defaultMode.getValue(vecInputFile, "input");
58  defaultMode.getValue(outputFile, "output");
59  return mergeMock(vecInputFile, outputFile) - 1;
60 }

References createOptionParser(), OptionMode::getValue(), mergeMock(), and createReleaseCurl::parser.

+ Here is the call graph for this function:

◆ mergeMock()

bool mergeMock ( const std::vector< std::string > &  vecInputFile,
const std::string &  outputFile 
)

Merge mock files.

Parameters
vecInputFile: vector of input files to be merged
outputFile: output file name to be saved
Returns
true on success, false otherwise

Definition at line 33 of file main_merge.cpp.

33  {
34  std::vector<std::vector<char> > vecMessage;
35  bool b(true);
36  for(std::vector<std::string>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end() && b; ++itFile){
37  std::vector<std::vector<char> > vecTmpFile;
38  if(data_load(*itFile, vecTmpFile)){
39  concatenateVecMessage(vecMessage, vecTmpFile);
40  }else{
41  b = false;
42  }
43  }
44  if(b){
45  b &= data_save(outputFile, vecMessage);
46  }
47  return b;
48 }

References concatenateVecMessage(), data_load(), and data_save().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
concatenateVecMessage
void concatenateVecMessage(std::vector< std::vector< char > > &vecOutput, const std::vector< std::vector< char > > vecInput)
Concatenate vector of message into an other one.
Definition: phoenix_mock.cpp:13
OptionMode::getValue
bool getValue(T &value, const std::string &optionName) const
Get the value of the option.
Definition: OptionMode_impl.h:18
createOptionParser
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition: main_merge.cpp:16
createReleaseCurl.parser
parser
Definition: createReleaseCurl.py:123
OptionParser
Parse the options passed to a program.
Definition: OptionParser.h:15
mergeMock
bool mergeMock(const std::vector< std::string > &vecInputFile, const std::string &outputFile)
Merge mock files.
Definition: main_merge.cpp:33
data_save
bool data_save(FILE *iter, const T &data)
Save data in a message.
Definition: data_file.h:18
data_load
bool data_load(FILE *iter, T &data)
Load data from a message.
Definition: data_file.h:39
OptionMode
Describe a mode in the program arguments.
Definition: OptionMode.h:13
OptionType::FILENAME
@ FILENAME
Definition: OptionType.h:26