aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/scan_name.cpp9
-rw-r--r--src/utils/scan_name.h10
2 files changed, 17 insertions, 2 deletions
diff --git a/src/utils/scan_name.cpp b/src/utils/scan_name.cpp
index b867a0462..3425425e2 100644
--- a/src/utils/scan_name.cpp
+++ b/src/utils/scan_name.cpp
@@ -54,11 +54,18 @@ SCAN_Name::SCAN_Name(const std::string& algo_spec)
std::string SCAN_Name::arg(u32bit i) const
{
- if(i > arg_count())
+ if(i >= arg_count())
throw std::range_error("SCAN_Name::argument");
return name[i+1];
}
+std::string SCAN_Name::arg(u32bit i, const std::string& def_value) const
+ {
+ if(i >= arg_count())
+ return def_value;
+ return name[i+1];
+ }
+
u32bit SCAN_Name::arg_as_u32bit(u32bit i, u32bit def_value) const
{
if(i >= arg_count())
diff --git a/src/utils/scan_name.h b/src/utils/scan_name.h
index 5607599dc..9e7af40d6 100644
--- a/src/utils/scan_name.h
+++ b/src/utils/scan_name.h
@@ -56,7 +56,15 @@ class SCAN_Name
/**
@param i which argument
- @return the ith argument as a u32bit, or a default value
+ @param def_value the default value
+ @return the ith argument or the default value
+ */
+ std::string arg(u32bit i, const std::string& def_value) const;
+
+ /**
+ @param i which argument
+ @param def_value the default value
+ @return the ith argument as a u32bit, or the default value
*/
u32bit arg_as_u32bit(u32bit i, u32bit def_value) const;
private: