summaryrefslogtreecommitdiff
path: root/src/option.cpp
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-02-22 17:42:54 +0100
committerDanny Baumann <dannybaumann@web.de>2009-02-22 17:42:54 +0100
commit03f611e6cfd26019bd2ec1701b1b84679722e1cb (patch)
tree1863f7493e4b9e517d5e19cd1b9ace6f7187ab63 /src/option.cpp
parent91fcc47d14c249168d514f74fe27e8e9b212ff9b (diff)
downloadzcomp-03f611e6cfd26019bd2ec1701b1b84679722e1cb.tar.gz
zcomp-03f611e6cfd26019bd2ec1701b1b84679722e1cb.tar.bz2
Option API improvements:
- Better reference usage - Improve const correctness
Diffstat (limited to 'src/option.cpp')
-rw-r--r--src/option.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/option.cpp b/src/option.cpp
index 9739ab8..66b76cb 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -672,24 +672,24 @@ CompOption::operator= (const CompOption &option)
bool
-CompOption::getBoolOptionNamed (Vector &options, CompString name,
- bool defaultValue)
+CompOption::getBoolOptionNamed (const Vector& options,
+ const CompString& name,
+ bool defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeBool &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeBool && o.priv->name == name)
return o.priv->value.b ();
return defaultValue;
}
int
-CompOption::getIntOptionNamed (Vector &options, CompString name,
- int defaultValue)
+CompOption::getIntOptionNamed (const Vector& options,
+ const CompString& name,
+ int defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeInt &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeInt && o.priv->name == name)
return o.priv->value.i ();
return defaultValue;
@@ -697,12 +697,12 @@ CompOption::getIntOptionNamed (Vector &options, CompString name,
float
-CompOption::getFloatOptionNamed (Vector &options, CompString name,
- float defaultValue)
+CompOption::getFloatOptionNamed (const Vector& options,
+ const CompString& name,
+ const float& defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeFloat &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeFloat && o.priv->name == name)
return o.priv->value.f ();
return defaultValue;
@@ -710,12 +710,12 @@ CompOption::getFloatOptionNamed (Vector &options, CompString name,
CompString
-CompOption::getStringOptionNamed (Vector &options, CompString name,
- CompString defaultValue)
+CompOption::getStringOptionNamed (const Vector& options,
+ const CompString& name,
+ const CompString& defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeString &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeString && o.priv->name == name)
return o.priv->value.s ();
return defaultValue;
@@ -723,25 +723,25 @@ CompOption::getStringOptionNamed (Vector &options, CompString name,
unsigned short *
-CompOption::getColorOptionNamed (Vector &options, CompString name,
- unsigned short *defaultValue)
+CompOption::getColorOptionNamed (const Vector& options,
+ const CompString& name,
+ unsigned short *defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeColor &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeColor && o.priv->name == name)
return o.priv->value.c ();
return defaultValue;
}
-CompMatch &
-CompOption::getMatchOptionNamed (Vector &options, CompString name,
- CompMatch &defaultValue)
+CompMatch
+CompOption::getMatchOptionNamed (const Vector& options,
+ const CompString& name,
+ const CompMatch& defaultValue)
{
- foreach (CompOption &o, options)
- if (o.priv->type == CompOption::TypeMatch &&
- o.priv->name.compare(name) == 0)
+ foreach (const CompOption &o, options)
+ if (o.priv->type == CompOption::TypeMatch && o.priv->name == name)
return o.priv->value.match ();
return defaultValue;