PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
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 "value_completion.h"
9 #include "OptionValue.h"
10 
12 
15  PVecString vecValue, vecDefaultValue, vecPossibleValue;
16  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
17 }
18 
20 
24  PVecString vecValue, vecDefaultValue, vecPossibleValue;
25  vecValue.push_back(value);
26  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
27 }
28 
30 
34  PVecString vecDefaultValue, vecPossibleValue;
35  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
36 }
37 
39 
43 OptionValue::OptionValue(const PString & value, OptionType::OptionType type, const PVecString & vecDefaultValue){
44  PVecString vecValue, vecPossibleValue;
45  vecValue.push_back(value);
46  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
47 }
48 
50 
54 OptionValue::OptionValue(const PVecString & vecValue, OptionType::OptionType type, const PVecString & vecDefaultValue){
55  PVecString vecPossibleValue;
56  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
57 }
58 
60 
65 OptionValue::OptionValue(const PString & value, OptionType::OptionType type, const PVecString & vecDefaultValue, const PVecString & vecPossibleValue){
66  PVecString vecValue;
67  vecValue.push_back(value);
68  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
69 }
70 
72 
77 OptionValue::OptionValue(const PVecString & vecValue, OptionType::OptionType type, const PVecString & vecDefaultValue, const PVecString & vecPossibleValue){
78  initialisationOptionValue(vecValue, type, vecDefaultValue, vecPossibleValue);
79 }
80 
81 
83 
86  copyOptionValue(other);
87 }
88 
91 
92 }
93 
95 
99  copyOptionValue(other);
100  return *this;
101 }
102 
104 
107  p_type = type;
108 }
109 
111 
113 void OptionValue::setValue(const PString & value){
114  PVecString vecValue;
115  vecValue.push_back(value);
116  setValue(vecValue);
117 }
118 
120 
122 void OptionValue::setValue(const PVecString & value){p_vecValue = value;}
123 
125 
127 void OptionValue::addValue(const PString & value){p_vecValue.push_back(value);}
128 
130 
132 void OptionValue::setVecPossibleValue(const PVecString & vecPossibleValue){p_vecPossibleValue = vecPossibleValue;}
133 
135 
138 
140 
143 
145 
148 
150 
153 
155 
158 
160 
163 
165 
168 
170 
173 
175 
178 void OptionValue::bashCompletionValue(PString & strBashCompletion, const PString & cursorOption) const{
179 // std::cerr << "OptionValue::bashCompletionValue : cursorOption = '"<<cursorOption<<"'" << std::endl;
180  if(p_vecPossibleValue.size() != 0lu){ //If there is some possible values, we print them
181  strBashCompletion += value_completion(cursorOption, p_vecPossibleValue);
182  }else{
183  //Now, we can complete by respect to the expected type
185  strBashCompletion += path_completion_all(cursorOption);
186  }else if(p_type == OptionType::DIRECTORY){
187  strBashCompletion += path_completion_dirOnly(cursorOption);
188  }else{
189  strBashCompletion += convertOptionTypeToString(p_type);
190  }
191  }
192 }
193 
195 
198  p_vecValue = other.p_vecValue;
199  p_type = other.p_type;
202 }
203 
205 
210 void OptionValue::initialisationOptionValue(const PVecString & vecValue, OptionType::OptionType type, const PVecString & vecDefaultValue, const PVecString & vecPossibleValue){
211  p_vecValue = vecValue;
212  p_type = type;
213  p_vecDefaultValue = vecDefaultValue;
214  p_vecPossibleValue = vecPossibleValue;
215 }
216 
217 
218 
219 
220 
PString convertOptionTypeToString(OptionType::OptionType type)
Convert the OptionType into PString.
Definition: OptionType.cpp:69
std::vector< PString > PVecString
Definition: PString.h:96
Describe the value of an option passed to a program.
Definition: OptionValue.h:16
void initialisationOptionValue(const PVecString &vecValue, OptionType::OptionType type, const PVecString &vecDefaultValue, const PVecString &vecPossibleValue)
Initialisation function of the class OptionValue.
virtual ~OptionValue()
Destructeur of OptionValue.
Definition: OptionValue.cpp:90
const PVecString & getValue() const
Get the vector of values.
void setValue(const PString &value)
Set the value of the OptionValue.
void setVecPossibleValue(const PVecString &vecPossibleValue)
Set the vector of possible values.
OptionValue & operator=(const OptionValue &other)
Definition of equal operator of OptionValue.
Definition: OptionValue.cpp:98
PVecString p_vecDefaultValue
Default value of the OptionValue.
Definition: OptionValue.h:75
void bashCompletionValue(PString &strBashCompletion, const PString &cursorOption) const
Print the possible value to the bash completion.
void addValue(const PString &value)
Add value of the OptionValue.
PVecString p_vecPossibleValue
Vector of the possible value for the OptionValue.
Definition: OptionValue.h:77
OptionValue(OptionType::OptionType type=OptionType::STRING)
Default constructeur of OptionValue.
Definition: OptionValue.cpp:14
OptionType::OptionType getType() const
Get the type of the OptionValue.
void copyOptionValue(const OptionValue &other)
Copy function of OptionValue.
const PVecString & getDefaultValue() const
Get the default value of the OptionValue.
const PVecString & getPossibleValue() const
Get the possible values of the OptionValue.
OptionType::OptionType p_type
Type of the OptionValue.
Definition: OptionValue.h:71
void setType(OptionType::OptionType type)
Set the type of the OptionValue.
PVecString p_vecValue
Vector of the values of the OptionValue.
Definition: OptionValue.h:73
Extends the std::string.
Definition: PString.h:16
PPath path_completion_dirOnly(const PPath &basePath)
Return all directories only which match the basePath.
PPath path_completion_all(const PPath &basePath)
Return all path/files which match the basePath.
PString value_completion(const PString &baseValue, const PVecString &vecPossibleValue)
Complete the given value.