summaryrefslogtreecommitdiff
path: root/src/option.cpp
diff options
context:
space:
mode:
authorJoel Bosveld <Joel.Bosveld@gmail.com>2009-02-26 20:36:51 +0900
committerDennis Kasprzyk <onestone@compiz-fusion.org>2009-02-27 14:56:04 +0100
commit573db36d5fddafbaab1940ed5c7b92a1890c6f47 (patch)
tree1199d082863f202ea8704329ce83d4f804e28b61 /src/option.cpp
parenta94019f989004220a319c7c04429089f5c637f49 (diff)
downloadunity-window-decorator-573db36d5fddafbaab1940ed5c7b92a1890c6f47.tar.gz
unity-window-decorator-573db36d5fddafbaab1940ed5c7b92a1890c6f47.tar.bz2
Warn if attempting to get wrong type from CompOption::Value
Diffstat (limited to 'src/option.cpp')
-rw-r--r--src/option.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/option.cpp b/src/option.cpp
index c8fcd2f..8779244 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -190,7 +190,10 @@ bool
CompOption::Value::b ()
{
if (priv->type != CompOption::TypeBool)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a bool");
return false;
+ }
return priv->value.b;
}
@@ -198,7 +201,10 @@ int
CompOption::Value::i ()
{
if (priv->type != CompOption::TypeInt)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an int");
return 0;
+ }
return priv->value.i;
}
@@ -206,7 +212,10 @@ float
CompOption::Value::f ()
{
if (priv->type != CompOption::TypeFloat)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a float");
return 0.0;
+ }
return priv->value.f;
}
@@ -216,37 +225,54 @@ unsigned short*
CompOption::Value::c ()
{
if (priv->type != CompOption::TypeColor)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a color");
return reinterpret_cast<unsigned short *> (&defaultColor);
+ }
return priv->value.c;
}
CompString
CompOption::Value::s ()
{
+ if (priv->type != CompOption::TypeString)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a string");
return priv->string;
}
CompMatch &
CompOption::Value::match ()
{
+ if (priv->type != CompOption::TypeMatch)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a match");
return priv->match;
}
CompAction &
CompOption::Value::action ()
{
+ if (priv->type != CompOption::TypeAction &&
+ priv->type != CompOption::TypeKey &&
+ priv->type != CompOption::TypeButton &&
+ priv->type != CompOption::TypeEdge &&
+ priv->type != CompOption::TypeBell)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an action");
return priv->action;
}
CompOption::Type
CompOption::Value::listType ()
{
+ if (priv->type != CompOption::TypeList)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list");
return priv->listType;
}
CompOption::Value::Vector &
CompOption::Value::list ()
{
+ if (priv->type != CompOption::TypeList)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list");
return priv->list;
}