diff options
author | Danny Baumann <dannybaumann@web.de> | 2008-10-13 11:42:07 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2008-10-13 11:42:07 +0200 |
commit | 5b71849f2a59bc9c6f05444c024d0771b2b187f0 (patch) | |
tree | ed095a64a1a80359124e7a63afce7771403a0d29 | |
parent | c4fdbc30f3ed3286dc9017633eb7e755a598d724 (diff) | |
download | unity-window-decorator-5b71849f2a59bc9c6f05444c024d0771b2b187f0.tar.gz unity-window-decorator-5b71849f2a59bc9c6f05444c024d0771b2b187f0.tar.bz2 |
Make CompAction *FromString functions return the information whether the conversion was successful or not.
-rw-r--r-- | include/core/action.h | 10 | ||||
-rw-r--r-- | src/action.cpp | 30 |
2 files changed, 25 insertions, 15 deletions
diff --git a/include/core/action.h b/include/core/action.h index b7e36db..a7e18fd 100644 --- a/include/core/action.h +++ b/include/core/action.h @@ -88,7 +88,7 @@ class CompAction { unsigned int modifiers (); int keycode (); - bool fromString (const CompString str); + bool fromString (const CompString &str); CompString toString (); private: @@ -104,7 +104,7 @@ class CompAction { unsigned int modifiers (); int button (); - bool fromString (const CompString str); + bool fromString (const CompString &str); CompString toString (); private: @@ -146,9 +146,9 @@ class CompAction { bool operator== (const CompAction& val); CompAction & operator= (const CompAction &action); - void keyFromString (const CompString str); - void buttonFromString (const CompString str); - void edgeMaskFromString (const CompString str); + bool keyFromString (const CompString &str); + bool buttonFromString (const CompString &str); + bool edgeMaskFromString (const CompString &str); CompString keyToString (); CompString buttonToString (); 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 |