From d82b3d010572bcae2f86c6ed8926756736f3d3de Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 25 Nov 2003 10:56:12 +0000 Subject: [PATCH] Added read(string,float,float,float,float) method --- include/osg/ArgumentParser | 5 +++++ src/osg/ArgumentParser.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/osg/ArgumentParser b/include/osg/ArgumentParser index 96692fad4..548395a77 100644 --- a/include/osg/ArgumentParser +++ b/include/osg/ArgumentParser @@ -105,6 +105,11 @@ class SG_EXPORT ArgumentParser * remove the four entries from the list and return true, otherwise return false.*/ bool read(const std::string& str,float& value1,float& value2,float& value3); + /** search for an occurance of a string in the argument list followed by three numeric values, + * on sucess set the values with the second & third & fourth parameters and then + * remove the four entries from the list and return true, otherwise return false.*/ + bool read(const std::string& str,float& value1,float& value2,float& value3,float& value4); + enum ErrorSeverity { diff --git a/src/osg/ArgumentParser.cpp b/src/osg/ArgumentParser.cpp index 6ac0d13ab..651dadf02 100644 --- a/src/osg/ArgumentParser.cpp +++ b/src/osg/ArgumentParser.cpp @@ -264,6 +264,23 @@ bool ArgumentParser::read(const std::string& str,float& value1,float& value2,flo return true; } +bool ArgumentParser::read(const std::string& str,float& value1,float& value2,float& value3,float& value4) +{ + int pos=find(str); + if (pos<=0) return false; + if (!isNumber(pos+1) || !isNumber(pos+2) || !isNumber(pos+3)) + { + reportError("argument to `"+str+"` is missing"); + return false; + } + value1 = atof(_argv[pos+1]); + value2 = atof(_argv[pos+2]); + value3 = atof(_argv[pos+3]); + value4 = atof(_argv[pos+4]); + remove(pos,5); + return true; +} + bool ArgumentParser::errors(ErrorSeverity severity) const { for(ErrorMessageMap::const_iterator itr=_errorMessageMap.begin();