Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1607 - trunk/Core/Util
- Date: Fri, 3 Aug 2007 13:45:15 -0600 (MDT)
Author: bigler
Date: Fri Aug 3 13:45:14 2007
New Revision: 1607
Modified:
trunk/Core/Util/Args.cc
Log:
Core/Util/Args.cc
Refactored some of the getXArg code.
Modified: trunk/Core/Util/Args.cc
==============================================================================
--- trunk/Core/Util/Args.cc (original)
+++ trunk/Core/Util/Args.cc Fri Aug 3 13:45:14 2007
@@ -22,53 +22,17 @@
bool getLongArg(int& i, const vector<string>& args, long& result)
{
- if(++i >= static_cast<int>(args.size())){
- i--;
- return false;
- } else {
- char* ptr = const_cast<char*>(args[i].c_str());
- long tmpresult = strtol(ptr, &ptr, 10);
- if(ptr == args[i].c_str() || *ptr != 0){
- i--;
- return false;
- }
- result = tmpresult;
- return true;
- }
+ return getArg<long>(i, args, result);
}
bool getIntArg(int& i, const vector<string>& args, int& result)
{
- if(++i >= static_cast<int>(args.size())){
- i--;
- return false;
- } else {
- char* ptr = const_cast<char*>(args[i].c_str());
- int tmpresult = (int)strtol(ptr, &ptr, 10);
- if(ptr == args[i].c_str() || *ptr != 0){
- i--;
- return false;
- }
- result = tmpresult;
- return true;
- }
+ return getArg<int>(i, args, result);
}
bool getDoubleArg(int& i, const vector<string>& args, double& result)
{
- if(++i >= static_cast<int>(args.size())){
- i--;
- return false;
- } else {
- char* ptr = const_cast<char*>(args[i].c_str());
- double tmpresult = strtod(ptr, &ptr);
- if(ptr == args[i].c_str() || *ptr != 0){
- i--;
- return false;
- }
- result = tmpresult;
- return true;
- }
+ return getArg<double>(i, args, result);
}
// Parse an argument of the form NxM, where N and M are integers
@@ -78,21 +42,12 @@
i--;
return false;
} else {
- char* ptr = const_cast<char*>(args[i].c_str());
- int tmpxres = (int)strtol(ptr, &ptr, 10);
- if(ptr == args[i].c_str() || *ptr != 'x'){
- i--;
- return false;
- }
- char* oldptr = ++ptr; // Skip the x
- int tmpyres = (int)strtol(ptr, &ptr, 10);
- if(ptr == oldptr || *ptr != 0){
+ if (getResolutionArg(args[i], xres, yres)) {
+ return true;
+ } else {
i--;
return false;
}
- xres = tmpxres;
- yres = tmpyres;
- return true;
}
}
- [MANTA] r1607 - trunk/Core/Util, bigler, 08/03/2007
Archive powered by MHonArc 2.6.16.