| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef _OPTIONPK_H_ |
| 22 |
#define _OPTIONPK_H_ |
| 23 |
|
| 24 |
#include <vector> |
| 25 |
#include <string> |
| 26 |
#include <cstdlib> |
| 27 |
#include <assert.h> |
| 28 |
#include <stdexcept> |
| 29 |
#include <iostream> |
| 30 |
#include <iomanip> |
| 31 |
#include <sstream> |
| 32 |
#include <typeinfo> |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#include "ogr_feature.h" |
| 41 |
|
| 42 |
#ifdef HAVE_CONFIG_H |
| 43 |
#include <config_jiplib.h> |
| 44 |
#endif |
| 45 |
|
| 46 |
#include "typeconversion.h" |
| 47 |
#include "apps/AppFactory.h" |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
template<class T> class Optionjl : public std::vector <T> |
| 79 |
{ |
| 80 |
public: |
| 81 |
|
| 82 |
Optionjl(); |
| 83 |
|
| 84 |
Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo); |
| 85 |
|
| 86 |
Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const T& defaultValue, short hide=0); |
| 87 |
|
| 88 |
~Optionjl(); |
| 89 |
|
| 90 |
void setHelp(const std::string& helpInfo){m_help=helpInfo;}; |
| 91 |
|
| 92 |
void setHide(short hide){m_hide=hide;}; |
| 93 |
|
| 94 |
bool retrieveOption(int argc, const std::vector<std::string>& argv); |
| 95 |
|
| 96 |
bool retrieveOption(int argc, char ** argv); |
| 97 |
|
| 98 |
bool retrieveOption(const app::AppFactory& app); |
| 99 |
bool retrieveOption(app::AppFactory& app); |
| 100 |
|
| 101 |
template<class T1> friend std::ostream& operator<<(std::ostream & os, const Optionjl<T1>& theOption); |
| 102 |
|
| 103 |
void setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo); |
| 104 |
|
| 105 |
void setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const T& defaultValue, short hide); |
| 106 |
|
| 107 |
void setDefault(const T& defaultValue); |
| 108 |
std::string getDefaultValue() const {return m_defaultValue;}; |
| 109 |
|
| 110 |
void setShortName(const std::string& shortName); |
| 111 |
|
| 112 |
void setLongName(const std::string& longName); |
| 113 |
|
| 114 |
std::string getShortName() const {return m_shortName;}; |
| 115 |
|
| 116 |
std::string getLongName() const {return m_longName;}; |
| 117 |
|
| 118 |
std::string getHelp() const {return m_help;}; |
| 119 |
|
| 120 |
static std::string getGPLv3License(){ |
| 121 |
return static_cast<std::string>("\n\ |
| 122 |
This program is free software: you can redistribute it and/or modify\n\ |
| 123 |
it under the terms of the GNU General Public License as published by\n\ |
| 124 |
the Free Software Foundation, either version 3 of the License, or\n\ |
| 125 |
(at your option) any later version.\n\ |
| 126 |
\n\ |
| 127 |
This program is distributed in the hope that it will be useful,\n\ |
| 128 |
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
| 129 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
| 130 |
GNU General Public License for more details.\n\ |
| 131 |
\n\ |
| 132 |
You should have received a copy of the GNU General Public License\n\ |
| 133 |
along with this program. If not, see <http://www.gnu.org/licenses/>.\n");}; |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
typename std::vector<T>::const_iterator findSubstring(const T& argument) const {std::string errorString="Error: findSubstring only defined for options of type std::string"; throw(errorString);}; |
| 138 |
|
| 139 |
int countSubstring(const T& argument) const{std::string errorString="Error: countSubstring only defined for options of type std::string"; throw(errorString);}; |
| 140 |
|
| 141 |
private: |
| 142 |
|
| 143 |
bool hasArgument() const {return m_hasArgument;}; |
| 144 |
|
| 145 |
bool hasShortOption() const {return m_shortName.compare("\0");}; |
| 146 |
|
| 147 |
bool hasLongOption() const {return m_longName.compare("\0");}; |
| 148 |
|
| 149 |
std::string usage() const; |
| 150 |
|
| 151 |
std::string usageDoxygen() const; |
| 152 |
|
| 153 |
std::string usageDict() const; |
| 154 |
|
| 155 |
std::string usageDoxypar() const; |
| 156 |
|
| 157 |
std::string m_shortName; |
| 158 |
|
| 159 |
std::string m_longName; |
| 160 |
|
| 161 |
std::string m_help; |
| 162 |
|
| 163 |
bool m_hasArgument; |
| 164 |
|
| 165 |
T m_defaultValue; |
| 166 |
|
| 167 |
bool m_hasDefault; |
| 168 |
|
| 169 |
short m_hide; |
| 170 |
}; |
| 171 |
|
| 172 |
template<class T1> std::ostream& operator<<(std::ostream& os, const Optionjl<T1>& theOption) |
| 173 |
{ |
| 174 |
os << theOption.getLongName() << ": "; |
| 175 |
for(int index=0;index<theOption.size();++index) |
| 176 |
os << type2string<T1>(theOption[index]) << " "; |
| 177 |
os << std::endl; |
| 178 |
return os; |
| 179 |
} |
| 180 |
|
| 181 |
template<class T> inline Optionjl<T>::Optionjl() |
| 182 |
: m_hasDefault(false) |
| 183 |
{ |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
template<class T> inline Optionjl<T>::Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo) |
| 193 |
: m_hasDefault(false) |
| 194 |
{ |
| 195 |
setAll(shortName,longName,helpInfo); |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
template<class T> inline Optionjl<T>::Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const T& defaultValue, short hide) |
| 209 |
{ |
| 210 |
setAll(shortName,longName,helpInfo,defaultValue, hide); |
| 211 |
} |
| 212 |
|
| 213 |
template<class T> inline std::string Optionjl<T>::usage() const |
| 214 |
{ |
| 215 |
std::ostringstream helpss; |
| 216 |
std::string shortOption=m_shortName; |
| 217 |
std::string longOption=m_longName; |
| 218 |
shortOption.insert(0,"-"); |
| 219 |
longOption.insert(0,"--"); |
| 220 |
if(hasShortOption()){ |
| 221 |
helpss << " " << std::setiosflags(std::ios::left) << std::setw(6) << shortOption; |
| 222 |
} |
| 223 |
else{ |
| 224 |
helpss << " " << std::setiosflags(std::ios::left) << std::setw(6) << " "; |
| 225 |
} |
| 226 |
if(hasLongOption()){ |
| 227 |
helpss << " " << std::setiosflags(std::ios::left) << std::setw(20) << longOption; |
| 228 |
} |
| 229 |
else{ |
| 230 |
helpss << " " << std::setiosflags(std::ios::left) << std::setw(20) << " "; |
| 231 |
} |
| 232 |
helpss << " " << m_help; |
| 233 |
if(m_hasDefault) |
| 234 |
helpss << " (default: " << type2string<T>(m_defaultValue) << ")"; |
| 235 |
return helpss.str(); |
| 236 |
} |
| 237 |
|
| 238 |
template<class T> inline std::string Optionjl<T>::usageDoxypar() const |
| 239 |
{ |
| 240 |
std::ostringstream helpss; |
| 241 |
std::string shortOption=m_shortName; |
| 242 |
std::string longOption=m_longName; |
| 243 |
|
| 244 |
if(hasLongOption()) |
| 245 |
helpss << std::setiosflags(std::ios::left) << " * @param " << longOption << " "; |
| 246 |
else if(hasShortOption()) |
| 247 |
helpss << " | " << std::setiosflags(std::ios::left) << " * @param "<< shortOption << " "; |
| 248 |
int status; |
| 249 |
helpss << std::setiosflags(std::ios::left) << std::setw(4) << "(type: " << mytypeid(T) << ") "; |
| 250 |
if(m_hasDefault) |
| 251 |
helpss << std::setiosflags(std::ios::left) << std::setw(4) << "(default: " << type2string<T>(m_defaultValue) << ") "; |
| 252 |
helpss << m_help; |
| 253 |
return helpss.str(); |
| 254 |
} |
| 255 |
|
| 256 |
template<class T> inline std::string Optionjl<T>::usageDict() const |
| 257 |
{ |
| 258 |
std::ostringstream helpss; |
| 259 |
std::string shortOption=m_shortName; |
| 260 |
std::string longOption=m_longName; |
| 261 |
|
| 262 |
if(hasLongOption()) |
| 263 |
helpss << std::setiosflags(std::ios::left) << longOption << ":<value> "; |
| 264 |
else if(hasShortOption()) |
| 265 |
helpss << std::setiosflags(std::ios::left) << shortOption << ":<value> "; |
| 266 |
int status; |
| 267 |
helpss << std::setiosflags(std::ios::left) << std::setw(4) << " (type: " << mytypeid(T) << ") "; |
| 268 |
if(m_hasDefault) |
| 269 |
helpss << std::setiosflags(std::ios::left) << std::setw(4) << " (default: " << type2string<T>(m_defaultValue) << ") : "; |
| 270 |
helpss << m_help; |
| 271 |
return helpss.str(); |
| 272 |
} |
| 273 |
|
| 274 |
template<class T> inline std::string Optionjl<T>::usageDoxygen() const |
| 275 |
{ |
| 276 |
std::ostringstream helpss; |
| 277 |
std::string shortOption=m_shortName; |
| 278 |
std::string longOption=m_longName; |
| 279 |
|
| 280 |
if(hasShortOption()) |
| 281 |
helpss << " | " << std::setiosflags(std::ios::left) << std::setw(6) << shortOption << " | "; |
| 282 |
else |
| 283 |
helpss << " | " << std::setiosflags(std::ios::left) << " | "; |
| 284 |
if(hasLongOption()) |
| 285 |
helpss << std::setiosflags(std::ios::left) << std::setw(20) << longOption << " | "; |
| 286 |
else |
| 287 |
helpss << std::setiosflags(std::ios::left) << " | "; |
| 288 |
int status; |
| 289 |
helpss << std::setiosflags(std::ios::left) << std::setw(4) << mytypeid(T) << " | "; |
| 290 |
|
| 291 |
if(m_hasDefault) |
| 292 |
helpss <<std::setiosflags(std::ios::left) << std::setw(5) << type2string<T>(m_defaultValue) << " |"; |
| 293 |
else |
| 294 |
helpss << " |"; |
| 295 |
helpss << m_help << " | "; |
| 296 |
|
| 297 |
return helpss.str(); |
| 298 |
} |
| 299 |
|
| 300 |
template<class T> inline void Optionjl<T>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo) |
| 301 |
{ |
| 302 |
m_shortName=shortName; |
| 303 |
m_longName=longName; |
| 304 |
m_hasArgument=true; |
| 305 |
m_help=helpInfo; |
| 306 |
m_hide=0; |
| 307 |
} |
| 308 |
|
| 309 |
template<class T> inline void Optionjl<T>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const T& defaultValue, short hide) |
| 310 |
{ |
| 311 |
m_shortName=shortName; |
| 312 |
m_longName=longName; |
| 313 |
m_hasArgument=true; |
| 314 |
m_help=helpInfo; |
| 315 |
m_defaultValue=defaultValue; |
| 316 |
m_hasDefault=true; |
| 317 |
m_hide=hide; |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
template<class T> inline Optionjl<T>::~Optionjl() |
| 322 |
{ |
| 323 |
} |
| 324 |
|
| 325 |
template<class T> inline bool Optionjl<T>::retrieveOption(const app::AppFactory& app){ |
| 326 |
return(retrieveOption(app.getArgc(),app.getArgv())); |
| 327 |
} |
| 328 |
|
| 329 |
template<class T> inline bool Optionjl<T>::retrieveOption(app::AppFactory& app){ |
| 330 |
if(getShortName()!="\0") |
| 331 |
app.registerShortOption(getShortName()); |
| 332 |
if(getLongName()!="\0") |
| 333 |
app.registerLongOption(getLongName()); |
| 334 |
return(retrieveOption(app.getArgc(),app.getArgv())); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
template<class T> inline bool Optionjl<T>::retrieveOption(int argc, const std::vector<std::string>& argv){ |
| 339 |
bool noHelp=true; |
| 340 |
std::string helpStringShort="-h"; |
| 341 |
std::string helpStringLong="--help"; |
| 342 |
std::string helpStringDict="--dict"; |
| 343 |
std::string helpStringDoxygen="--doxygen"; |
| 344 |
std::string helpStringDoxypar="--doxypar"; |
| 345 |
std::string versionString="--version"; |
| 346 |
std::string licenseString="--license"; |
| 347 |
for(int i = 1; i < argc; ++i ){ |
| 348 |
std::string currentArgument; |
| 349 |
std::string currentOption=argv[i]; |
| 350 |
std::string shortOption=m_shortName; |
| 351 |
std::string longOption=m_longName; |
| 352 |
shortOption.insert(0,"-"); |
| 353 |
longOption.insert(0,"--"); |
| 354 |
size_t foundEqual=currentOption.rfind("="); |
| 355 |
if(foundEqual!=std::string::npos){ |
| 356 |
currentArgument=currentOption.substr(foundEqual+1); |
| 357 |
currentOption=currentOption.substr(0,foundEqual); |
| 358 |
} |
| 359 |
if(!helpStringShort.compare(currentOption)){ |
| 360 |
if(m_hide<1) |
| 361 |
std::cout << usage() << std::endl; |
| 362 |
noHelp=false; |
| 363 |
} |
| 364 |
else if(!helpStringLong.compare(currentOption)){ |
| 365 |
if(m_hide<2) |
| 366 |
std::cout << usage() << std::endl; |
| 367 |
noHelp=false; |
| 368 |
} |
| 369 |
else if(!helpStringDoxygen.compare(currentOption)){ |
| 370 |
if(m_hide<2) |
| 371 |
std::cout << usageDoxygen() << std::endl; |
| 372 |
noHelp=false; |
| 373 |
} |
| 374 |
else if(!helpStringDoxypar.compare(currentOption)){ |
| 375 |
if(m_hide<2) |
| 376 |
std::cout << usageDoxypar() << std::endl; |
| 377 |
noHelp=false; |
| 378 |
} |
| 379 |
else if(!helpStringDict.compare(currentOption)){ |
| 380 |
if(m_hide<2) |
| 381 |
std::cout << usageDict() << std::endl; |
| 382 |
noHelp=false; |
| 383 |
} |
| 384 |
else if(!versionString.compare(currentOption)){ |
| 385 |
std::ostringstream oss; |
| 386 |
oss << "version " << JIPLIB_VERSION; |
| 387 |
std::string theVersion="version "; |
| 388 |
|
| 389 |
oss << ", Copyright (C) Pieter Kempeneers.\n\ |
| 390 |
This program comes with ABSOLUTELY NO WARRANTY; for details type use option -h.\n \ |
| 391 |
This is free software, and you are welcome to redistribute it\n \ |
| 392 |
under certain conditions; use option --license for details."; |
| 393 |
throw(oss.str()); |
| 394 |
} |
| 395 |
else if(!licenseString.compare(currentOption)){ |
| 396 |
throw(getGPLv3License()); |
| 397 |
} |
| 398 |
if(hasShortOption()&&!(shortOption.compare(currentOption))){ |
| 399 |
if(foundEqual!=std::string::npos) |
| 400 |
this->push_back(string2type<T>(currentArgument)); |
| 401 |
else if(m_hasArgument && i < argc-1) |
| 402 |
this->push_back(string2type<T>(argv[++i])); |
| 403 |
else |
| 404 |
this->push_back(string2type<T>("1")); |
| 405 |
} |
| 406 |
else if(hasLongOption()&&!(longOption.compare(currentOption))){ |
| 407 |
if(foundEqual!=std::string::npos) |
| 408 |
this->push_back(string2type<T>(currentArgument)); |
| 409 |
else if(m_hasArgument && i < argc-1){ |
| 410 |
std::string argValue=argv[++i]; |
| 411 |
this->push_back(string2type<T>(argValue)); |
| 412 |
|
| 413 |
} |
| 414 |
else |
| 415 |
this->push_back(string2type<T>("1")); |
| 416 |
} |
| 417 |
} |
| 418 |
if(!(this->size())&&m_hasDefault) |
| 419 |
this->push_back(m_defaultValue); |
| 420 |
return(noHelp); |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
template<class T> inline bool Optionjl<T>::retrieveOption(int argc, char **argv){ |
| 427 |
bool noHelp=true; |
| 428 |
std::string helpStringShort="-h"; |
| 429 |
std::string helpStringLong="--help"; |
| 430 |
std::string helpStringDict="--dict"; |
| 431 |
std::string helpStringDoxygen="--doxygen"; |
| 432 |
std::string helpStringDoxypar="--doxypar"; |
| 433 |
std::string versionString="--version"; |
| 434 |
std::string licenseString="--license"; |
| 435 |
for(int i = 1; i < argc; ++i ){ |
| 436 |
std::string currentArgument; |
| 437 |
std::string currentOption=argv[i]; |
| 438 |
std::string shortOption=m_shortName; |
| 439 |
std::string longOption=m_longName; |
| 440 |
shortOption.insert(0,"-"); |
| 441 |
longOption.insert(0,"--"); |
| 442 |
size_t foundEqual=currentOption.rfind("="); |
| 443 |
if(foundEqual!=std::string::npos){ |
| 444 |
currentArgument=currentOption.substr(foundEqual+1); |
| 445 |
currentOption=currentOption.substr(0,foundEqual); |
| 446 |
} |
| 447 |
if(!helpStringShort.compare(currentOption)){ |
| 448 |
if(m_hide<1) |
| 449 |
std::cout << usage() << std::endl; |
| 450 |
noHelp=false; |
| 451 |
} |
| 452 |
else if(!helpStringLong.compare(currentOption)){ |
| 453 |
if(m_hide<2) |
| 454 |
std::cout << usage() << std::endl; |
| 455 |
noHelp=false; |
| 456 |
} |
| 457 |
else if(!helpStringDoxygen.compare(currentOption)){ |
| 458 |
if(m_hide<2) |
| 459 |
std::cout << usageDoxygen() << std::endl; |
| 460 |
noHelp=false; |
| 461 |
} |
| 462 |
else if(!helpStringDict.compare(currentOption)){ |
| 463 |
if(m_hide<2) |
| 464 |
std::cout << usageDict() << std::endl; |
| 465 |
noHelp=false; |
| 466 |
} |
| 467 |
else if(!helpStringDoxypar.compare(currentOption)){ |
| 468 |
if(m_hide<2) |
| 469 |
std::cout << usageDoxypar() << std::endl; |
| 470 |
noHelp=false; |
| 471 |
} |
| 472 |
else if(!versionString.compare(currentOption)){ |
| 473 |
std::ostringstream oss; |
| 474 |
oss << "version " << JIPLIB_VERSION; |
| 475 |
std::string theVersion="version "; |
| 476 |
|
| 477 |
oss << ", Copyright (C) Pieter Kempeneers.\n\ |
| 478 |
This program comes with ABSOLUTELY NO WARRANTY; for details type use option -h.\n \ |
| 479 |
This is free software, and you are welcome to redistribute it\n \ |
| 480 |
under certain conditions; use option --license for details."; |
| 481 |
throw(oss.str()); |
| 482 |
} |
| 483 |
else if(!licenseString.compare(currentOption)){ |
| 484 |
throw(getGPLv3License()); |
| 485 |
} |
| 486 |
if(hasShortOption()&&!(shortOption.compare(currentOption))){ |
| 487 |
if(foundEqual!=std::string::npos) |
| 488 |
this->push_back(string2type<T>(currentArgument)); |
| 489 |
else if(m_hasArgument && i < argc-1) |
| 490 |
this->push_back(string2type<T>(argv[++i])); |
| 491 |
else |
| 492 |
this->push_back(string2type<T>("1")); |
| 493 |
} |
| 494 |
else if(hasLongOption()&&!(longOption.compare(currentOption))){ |
| 495 |
if(foundEqual!=std::string::npos) |
| 496 |
this->push_back(string2type<T>(currentArgument)); |
| 497 |
else if(m_hasArgument && i < argc-1) |
| 498 |
this->push_back(string2type<T>(argv[++i])); |
| 499 |
else |
| 500 |
this->push_back(string2type<T>("1")); |
| 501 |
} |
| 502 |
} |
| 503 |
if(!(this->size())&&m_hasDefault) |
| 504 |
this->push_back(m_defaultValue); |
| 505 |
return(noHelp); |
| 506 |
} |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
template<> inline void Optionjl<bool>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo) |
| 512 |
{ |
| 513 |
m_shortName=shortName; |
| 514 |
m_longName=longName; |
| 515 |
m_hasArgument=false; |
| 516 |
m_help=helpInfo; |
| 517 |
m_hide=0; |
| 518 |
} |
| 519 |
|
| 520 |
|
| 521 |
template<> inline void Optionjl<bool>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const bool& defaultValue, short hide) |
| 522 |
{ |
| 523 |
m_shortName=shortName; |
| 524 |
m_longName=longName; |
| 525 |
m_hasArgument=false; |
| 526 |
m_help=helpInfo; |
| 527 |
m_defaultValue=defaultValue; |
| 528 |
m_hasDefault=true; |
| 529 |
m_hide=hide; |
| 530 |
} |
| 531 |
|
| 532 |
|
| 533 |
template<> inline Optionjl<bool>::Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo) |
| 534 |
{ |
| 535 |
setAll(shortName,longName,helpInfo); |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
template<> inline Optionjl<bool>::Optionjl(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const bool& defaultValue, short hide) |
| 540 |
{ |
| 541 |
setAll(shortName,longName,helpInfo,defaultValue, hide); |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
template<> inline std::vector<std::string>::const_iterator Optionjl<std::string>::findSubstring(const std::string& argument) const{ |
| 547 |
std::vector<std::string>::const_iterator opit=this->begin(); |
| 548 |
while(opit!=this->end()){ |
| 549 |
if(opit->find(argument)!=std::string::npos) |
| 550 |
break; |
| 551 |
++opit; |
| 552 |
} |
| 553 |
return opit; |
| 554 |
} |
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
template<> inline int Optionjl<std::string>::countSubstring(const std::string& argument) const{ |
| 559 |
int count=0; |
| 560 |
std::vector<std::string>::const_iterator opit=this->begin(); |
| 561 |
while(opit!=this->end()){ |
| 562 |
if(opit->find(argument)!=std::string::npos) |
| 563 |
++count; |
| 564 |
++opit; |
| 565 |
} |
| 566 |
return count; |
| 567 |
} |
| 568 |
|
| 569 |
#endif |