PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
OptionValue.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 "path_completion.h"
8 #include "OptionValue.h"
9 
11 
14  VecValue vecValue, vecDefaultValue, vecPossibleValue;
15  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
16 }
17 
19 
23  VecValue vecValue, vecDefaultValue, vecPossibleValue;
24  vecValue.push_back(value);
25  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
26 }
27 
29 
33  VecValue vecDefaultValue, vecPossibleValue;
34  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
35 }
36 
38 
42 OptionValue::OptionValue(const std::string & value, OptionType::OptionType type, const VecValue & vecDefaultValue){
43  VecValue vecValue, vecPossibleValue;
44  vecValue.push_back(value);
45  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
46 }
47 
49 
53 OptionValue::OptionValue(const VecValue & vecValue, OptionType::OptionType type, const VecValue & vecDefaultValue){
54  VecValue vecPossibleValue;
55  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
56 }
57 
59 
64 OptionValue::OptionValue(const std::string & value, OptionType::OptionType type, const VecValue & vecDefaultValue, const VecValue & vecPossibleValue){
65  VecValue vecValue;
66  vecValue.push_back(value);
67  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
68 }
69 
71 
76 OptionValue::OptionValue(const VecValue & vecValue, OptionType::OptionType type, const VecValue & vecDefaultValue, const VecValue & vecPossibleValue){
77  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
78 }
79 
80 
82 
85  copyOptionValue(other);
86 }
87 
90 
91 }
92 
94 
98  copyOptionValue(other);
99  return *this;
100 }
101 
103 
106  p_type = type;
107 }
108 
110 
112 void OptionValue::setValue(const std::string & value){
113  VecValue vecValue;
114  vecValue.push_back(value);
115  setValue(vecValue);
116 }
117 
119 
121 void OptionValue::setValue(const VecValue & value){p_vecValue = value;}
122 
124 
126 void OptionValue::addValue(const std::string & value){p_vecValue.push_back(value);}
127 
129 
131 const VecValue & OptionValue::getValue() const{return p_vecValue;}
132 
134 
137 
139 
142 
144 
147 
149 
152 
154 
157 
159 
162 
164 
167 
169 
172 void OptionValue::bashCompletionValue(std::string & strBashCompletion, const std::string & cursorOption) const{
173 // std::cerr << "OptionValue::bashCompletionValue : cursorOption = '"<<cursorOption<<"'" << std::endl;
174  if(p_vecPossibleValue.size() != 0lu){ //If there is some possible values, we print them
175  for(VecValue::const_iterator it(p_vecPossibleValue.begin()); it != p_vecPossibleValue.end(); ++it){
176  strBashCompletion += " " + *it;
177  }
178  }else{
179  //Now, we can complete by respect to the expected type
181  strBashCompletion += path_completion_all(cursorOption);
182  }else if(p_type == OptionType::DIRECTORY){
183  strBashCompletion += path_completion_dirOnly(cursorOption);
184  }else{
185  strBashCompletion += convertOptionTypeToString(p_type);
186  }
187  }
188 }
189 
191 
194  p_vecValue = other.p_vecValue;
195  p_type = other.p_type;
198 }
199 
201 
206 void OptionValue::initialisationOptionValue(const VecValue & vecValue, OptionType::OptionType type, const VecValue & vecDefaultValue, const VecValue & vecPossibleValue){
207  p_vecValue = vecValue;
208  p_type = type;
209  p_vecDefaultValue = vecDefaultValue;
210  p_vecPossibleValue = vecPossibleValue;
211 }
212 
213 
214 
215 
216 
OptionValue::operator=
OptionValue & operator=(const OptionValue &other)
Definition of equal operator of OptionValue.
Definition: OptionValue.cpp:97
convertOptionTypeToString
std::string convertOptionTypeToString(OptionType::OptionType type)
Convert the OptionType into string.
Definition: OptionType.cpp:69
OptionValue::setType
void setType(OptionType::OptionType type)
Set the type of the OptionValue.
Definition: OptionValue.cpp:105
path_completion_all
std::string path_completion_all(const std::string &basePath)
Return all path/files which match the basePath.
Definition: path_completion.cpp:41
OptionValue.h
OptionValue::getType
OptionType::OptionType getType() const
Get the type of the OptionValue.
Definition: OptionValue.cpp:141
OptionValue::getPossibleValue
const VecValue & getPossibleValue() const
Get the possible values of the OptionValue.
Definition: OptionValue.cpp:161
OptionType::DIRECTORY
@ DIRECTORY
Definition: OptionType.h:27
OptionValue::p_type
OptionType::OptionType p_type
Type of the OptionValue.
Definition: OptionValue.h:77
OptionValue::bashCompletionValue
void bashCompletionValue(std::string &strBashCompletion, const std::string &cursorOption) const
Print the possible value to the bash completion.
Definition: OptionValue.cpp:172
OptionValue::addValue
void addValue(const std::string &value)
Add value of the OptionValue.
Definition: OptionValue.cpp:126
path_completion_dirOnly
std::string path_completion_dirOnly(const std::string &basePath)
Return all directories only which match the basePath.
Definition: path_completion.cpp:87
OptionValue::initialisationOptionValue
void initialisationOptionValue(const VecValue &vecValue, OptionType::OptionType type, const VecValue &vecDefaultValue, const VecValue &vecPossibleValue)
Initialisation function of the class OptionValue.
Definition: OptionValue.cpp:206
OptionValue::p_vecDefaultValue
VecValue p_vecDefaultValue
Default value of the OptionValue.
Definition: OptionValue.h:81
OptionType::FILE_OR_DIR
@ FILE_OR_DIR
Definition: OptionType.h:28
createReleaseCurl.type
type
Definition: createReleaseCurl.py:124
OptionValue::OptionValue
OptionValue(OptionType::OptionType type=OptionType::STRING)
Default constructeur of OptionValue.
Definition: OptionValue.cpp:13
OptionValue::copyOptionValue
void copyOptionValue(const OptionValue &other)
Copy function of OptionValue.
Definition: OptionValue.cpp:193
OptionType::OptionType
OptionType
Definition: OptionType.h:19
OptionValue::getValue
const VecValue & getValue() const
Get the vector of values.
Definition: OptionValue.cpp:131
OptionValue
Describe the value of an option passed to a program.
Definition: OptionValue.h:20
OptionValue::p_vecValue
VecValue p_vecValue
Vector of the values of the OptionValue.
Definition: OptionValue.h:79
OptionValue::~OptionValue
virtual ~OptionValue()
Destructeur of OptionValue.
Definition: OptionValue.cpp:89
OptionValue::setValue
void setValue(const std::string &value)
Set the value of the OptionValue.
Definition: OptionValue.cpp:112
OptionValue::getDefaultValue
const VecValue & getDefaultValue() const
Get the default value of the OptionValue.
Definition: OptionValue.cpp:151
VecValue
std::vector< std::string > VecValue
Vector of values.
Definition: OptionValue.h:17
path_completion.h
OptionValue::p_vecPossibleValue
VecValue p_vecPossibleValue
Vector of the possible value for the OptionValue.
Definition: OptionValue.h:83
OptionType::FILENAME
@ FILENAME
Definition: OptionType.h:26