PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
get_argument_list.h File Reference
#include <string>
#include <list>
+ Include dependency graph for get_argument_list.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::list< std::string > phoenix_getArgumentList (int argc, char **argv)
 Convert the list of given arguments to the program into a list of string. More...
 
std::string phoenix_getProgramCall (const std::list< std::string > &listArg)
 Get the program call. More...
 
bool phoenix_isOptionExist (const std::list< std::string > &listArg, const std::list< std::string > &argCheckList)
 Check if one of the two passed arguments are in the list of arguments. More...
 
bool phoenix_isOptionExist (const std::list< std::string > &listArg, const std::string &arg1)
 Check if one of the two passed arguments are in the list of arguments. More...
 
bool phoenix_isOptionExist (const std::list< std::string > &listArg, const std::string &arg1, const std::string &arg2)
 Check if one of the two passed arguments are in the list of arguments. More...
 
std::string phoenix_listArgToString (const std::list< std::string > &listArg)
 Convert the given list of arguement into a string. More...
 
void phoenix_rmProgramCall (std::list< std::string > &listArg)
 Remove the program call from the list of argument. More...
 

Function Documentation

◆ phoenix_getArgumentList()

std::list<std::string> phoenix_getArgumentList ( int  argc,
char **  argv 
)

Convert the list of given arguments to the program into a list of string.

Parameters
argc: number of arguments passed to the program
argv: table of arguments passed to the program
Returns
corresponding list of string

Definition at line 16 of file get_argument_list.cpp.

16  {
17  std::list<std::string> argList;
18  for(int i(0); i < argc; ++i){
19  argList.push_back(std::string(argv[i]));
20  }
21  return argList;
22 }

Referenced by main().

+ Here is the caller graph for this function:

◆ phoenix_getProgramCall()

std::string phoenix_getProgramCall ( const std::list< std::string > &  listArg)

Get the program call.

Parameters
listArg: list of argument passed to the program
Returns
program call, or empty string if list of argument is empty

Definition at line 83 of file get_argument_list.cpp.

83  {
84  if(listArg.size() != 0lu){return listArg.front();}
85  else{return "";}
86 }

Referenced by main().

+ Here is the caller graph for this function:

◆ phoenix_isOptionExist() [1/3]

bool phoenix_isOptionExist ( const std::list< std::string > &  listArg,
const std::list< std::string > &  argCheckList 
)

Check if one of the two passed arguments are in the list of arguments.

Parameters
listArg: list of arguments given to the program
argCheckList: list of argument to be searched
Returns
true if one element of argCheckList has been found in listArg, false otherwise

Definition at line 29 of file get_argument_list.cpp.

29  {
30  bool isSearch(true);
31  std::list<std::string>::const_iterator itArg(listArg.begin());
32  while(itArg != listArg.end() && isSearch){
33  std::list<std::string>::const_iterator itCheck(argCheckList.begin());
34  while(itCheck != argCheckList.end() && isSearch){
35  isSearch = *itArg != *itCheck;
36  ++itCheck;
37  }
38  ++itArg;
39  }
40  return !isSearch;
41 }

Referenced by main(), and phoenix_isOptionExist().

+ Here is the caller graph for this function:

◆ phoenix_isOptionExist() [2/3]

bool phoenix_isOptionExist ( const std::list< std::string > &  listArg,
const std::string &  arg1 
)

Check if one of the two passed arguments are in the list of arguments.

Parameters
listArg: list of arguments given to the program
arg1: argument to be searched
Returns
true if arg1 or arg2 is in listArg, false otherwise

Definition at line 48 of file get_argument_list.cpp.

48  {
49  std::list<std::string> argCheckList;
50  argCheckList.push_back(arg1);
51  return phoenix_isOptionExist(listArg, argCheckList);
52 }

References phoenix_isOptionExist().

+ Here is the call graph for this function:

◆ phoenix_isOptionExist() [3/3]

bool phoenix_isOptionExist ( const std::list< std::string > &  listArg,
const std::string &  arg1,
const std::string &  arg2 
)

Check if one of the two passed arguments are in the list of arguments.

Parameters
listArg: list of arguments given to the program
arg1: argument to be searched
arg2: argument to be searched
Returns
true if arg1 or arg2 is in listArg, false otherwise

Definition at line 60 of file get_argument_list.cpp.

60  {
61  std::list<std::string> argCheckList;
62  argCheckList.push_back(arg1);
63  argCheckList.push_back(arg2);
64  return phoenix_isOptionExist(listArg, argCheckList);
65 }

References phoenix_isOptionExist().

+ Here is the call graph for this function:

◆ phoenix_listArgToString()

std::string phoenix_listArgToString ( const std::list< std::string > &  listArg)

Convert the given list of arguement into a string.

Parameters
listArg: list of argument to be converted into a string
Returns
corresponding string

Definition at line 71 of file get_argument_list.cpp.

71  {
72  std::string body("");
73  for(std::list<std::string>::const_iterator itArg(listArg.begin()); itArg != listArg.end(); ++itArg){
74  body += phoenix_escapeStr(*itArg, " '\"", "\\") + " ";
75  }
76  return body;
77 }

References phoenix_escapeStr().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_rmProgramCall()

void phoenix_rmProgramCall ( std::list< std::string > &  listArg)

Remove the program call from the list of argument.

Parameters
[out]listArg: list or argument to be modified

Definition at line 91 of file get_argument_list.cpp.

91  {
92  if(listArg.size() != 0lu){
93  listArg.pop_front();
94  }
95 }

Referenced by main().

+ Here is the caller graph for this function:
phoenix_escapeStr
std::string phoenix_escapeStr(const std::string &src, const std::string &strCharToEscape, const std::string &escapeStr)
Escape given string with passed characters.
Definition: string_function.cpp:411
phoenix_isOptionExist
bool phoenix_isOptionExist(const std::list< std::string > &listArg, const std::list< std::string > &argCheckList)
Check if one of the two passed arguments are in the list of arguments.
Definition: get_argument_list.cpp:29