Changeset 13041 for OpenSceneGraph/trunk/src/osg/ArgumentParser.cpp
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/ArgumentParser.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/ArgumentParser.cpp
r11875 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 58 58 59 59 const char* ptr = str; 60 60 61 61 // check if could be a hex number. 62 62 if (strncmp(ptr,"0x",2)==0) … … 68 68 *ptr!=0 && 69 69 ((*ptr>='0' && *ptr<='9') || 70 (*ptr>='a' && *ptr<='f') || 70 (*ptr>='a' && *ptr<='f') || 71 71 (*ptr>='A' && *ptr<='F')) 72 72 ) … … 74 74 ++ptr; 75 75 } 76 76 77 77 // got to end of string without failure, therefore must be a hex integer. 78 78 if (*ptr==0) return true; 79 79 } 80 80 81 81 ptr = str; 82 82 … … 137 137 138 138 return false; 139 139 140 140 } 141 141 … … 187 187 { 188 188 #ifdef __APPLE__ 189 //On OSX, any -psn arguments need to be removed because they will 189 //On OSX, any -psn arguments need to be removed because they will 190 190 // confuse the application. -psn plus a concatenated argument are 191 191 // passed by the finder to application bundles 192 192 for(int pos=1;pos<this->argc();++pos) 193 193 { 194 if (std::string(_argv[pos]).compare(0, 4, std::string("-psn")) == 0) 194 if (std::string(_argv[pos]).compare(0, 4, std::string("-psn")) == 0) 195 195 { 196 196 remove(pos, 1); … … 216 216 } 217 217 218 218 219 219 bool ArgumentParser::isOption(int pos) const 220 220 { … … 264 264 { 265 265 if (num==0) return; 266 266 267 267 for(;pos+num<*_argc;++pos) 268 268 { … … 595 595 { 596 596 std::set<std::string> options; 597 if (_usage.valid()) 597 if (_usage.valid()) 598 598 { 599 599 // parse the usage options to get all the option that the application can potential handle. … … 606 606 while ((pos=option.find(' ',prevpos))!=std::string::npos) 607 607 { 608 if (option[prevpos]=='-') 608 if (option[prevpos]=='-') 609 609 { 610 610 options.insert(std::string(option,prevpos,pos-prevpos)); … … 612 612 prevpos=pos+1; 613 613 } 614 if (option[prevpos]=='-') 614 if (option[prevpos]=='-') 615 615 { 616 616 … … 618 618 } 619 619 } 620 620 621 621 } 622 622 … … 624 624 { 625 625 // if an option and havn't been previous querried for report as unrecognized. 626 if (isOption(pos) && options.find(_argv[pos])==options.end()) 626 if (isOption(pos) && options.find(_argv[pos])==options.end()) 627 627 { 628 628 reportError(std::string("unrecognized option ")+std::string(_argv[pos]),severity); … … 643 643 } 644 644 645 ApplicationUsage::Type ArgumentParser::readHelpType() 645 ApplicationUsage::Type ArgumentParser::readHelpType() 646 646 { 647 647 getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
