From 5b71849f2a59bc9c6f05444c024d0771b2b187f0 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Mon, 13 Oct 2008 11:42:07 +0200 Subject: Make CompAction *FromString functions return the information whether the conversion was successful or not. --- src/action.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/action.cpp') diff --git a/src/action.cpp b/src/action.cpp index ea94e48..fc672ff 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -147,7 +147,7 @@ CompAction::KeyBinding::keycode () } bool -CompAction::KeyBinding::fromString (const CompString str) +CompAction::KeyBinding::fromString (const CompString &str) { CompString sStr; unsigned int mods; @@ -262,7 +262,7 @@ CompAction::ButtonBinding::button () } bool -CompAction::ButtonBinding::fromString (const CompString str) +CompAction::ButtonBinding::fromString (const CompString &str) { unsigned int mods; size_t pos; @@ -442,19 +442,25 @@ CompAction::operator= (const CompAction &action) return *this; } -void -CompAction::keyFromString (const CompString str) +bool +CompAction::keyFromString (const CompString &str) { - if (priv->key.fromString (str)) + bool retval = priv->key.fromString (str); + + if (retval) priv->type = CompAction::BindingTypeKey; else priv->type = CompAction::BindingTypeNone; + + return retval; } -void -CompAction::buttonFromString (const CompString str) +bool +CompAction::buttonFromString (const CompString &str) { - if (priv->button.fromString (str)) + bool retval = priv->button.fromString (str); + + if (retval) { priv->edgeMask = bindingStringToEdgeMask (str); if (priv->edgeMask) @@ -466,10 +472,12 @@ CompAction::buttonFromString (const CompString str) { priv->type = CompAction::BindingTypeNone; } + + return retval; } -void -CompAction::edgeMaskFromString (const CompString str) +bool +CompAction::edgeMaskFromString (const CompString &str) { unsigned int edgeMask = 0; size_t pos; @@ -495,6 +503,8 @@ CompAction::edgeMaskFromString (const CompString str) } priv->edgeMask = edgeMask; + + return (edgeMask != 0 || str.empty ()); } CompString -- cgit v1.1