PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
get_argument_list.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 "get_argument_list.h"
8 
9 
11 
15 std::list<PString> phoenix_getArgumentList(int argc, char** argv){
16  std::list<PString> argList;
17  for(int i(0); i < argc; ++i){
18  argList.push_back(PString(argv[i]));
19  }
20  return argList;
21 }
22 
24 
28 bool phoenix_isOptionExist(const std::list<PString> & listArg, const std::list<PString> & argCheckList){
29  bool isSearch(true);
30  std::list<PString>::const_iterator itArg(listArg.begin());
31  while(itArg != listArg.end() && isSearch){
32  std::list<PString>::const_iterator itCheck(argCheckList.begin());
33  while(itCheck != argCheckList.end() && isSearch){
34  isSearch = *itArg != *itCheck;
35  ++itCheck;
36  }
37  ++itArg;
38  }
39  return !isSearch;
40 }
41 
43 
47 bool phoenix_isOptionExist(const std::list<PString> & listArg, const PString & arg1){
48  std::list<PString> argCheckList;
49  argCheckList.push_back(arg1);
50  return phoenix_isOptionExist(listArg, argCheckList);
51 }
52 
54 
59 bool phoenix_isOptionExist(const std::list<PString> & listArg, const PString & arg1, const PString & arg2){
60  std::list<PString> argCheckList;
61  argCheckList.push_back(arg1);
62  argCheckList.push_back(arg2);
63  return phoenix_isOptionExist(listArg, argCheckList);
64 }
65 
67 
70 PString phoenix_listArgToString(const std::list<PString> & listArg){
71  PString body("");
72  for(std::list<PString>::const_iterator itArg(listArg.begin()); itArg != listArg.end(); ++itArg){
73  body += itArg->escapeStr(" '\"", "\\") + " ";
74  }
75  return body;
76 }
77 
79 
82 PString phoenix_getProgramCall(const std::list<PString> & listArg){
83  if(listArg.size() != 0lu){return listArg.front();}
84  else{return "";}
85 }
86 
88 
90 void phoenix_rmProgramCall(std::list<PString> & listArg){
91  if(listArg.size() != 0lu){
92  listArg.pop_front();
93  }
94 }
95 
96 
97 
Extends the std::string.
Definition: PString.h:16
PString escapeStr(const PString &strCharToEscape, const PString &escapeSeq) const
Escape given string with passed characters.
Definition: PString.cpp:689
void phoenix_rmProgramCall(std::list< PString > &listArg)
Remove the program call from the list of argument.
bool phoenix_isOptionExist(const std::list< PString > &listArg, const std::list< PString > &argCheckList)
Check if one of the two passed arguments are in the list of arguments.
PString phoenix_getProgramCall(const std::list< PString > &listArg)
Get the program call.
std::list< PString > phoenix_getArgumentList(int argc, char **argv)
Convert the list of given arguments to the program into a list of string.
PString phoenix_listArgToString(const std::list< PString > &listArg)
Convert the given list of arguement into a string.