summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <Joel.Bosveld@gmail.com>2009-02-26 20:35:26 +0900
committerDennis Kasprzyk <onestone@compiz-fusion.org>2009-02-27 14:55:58 +0100
commita94019f989004220a319c7c04429089f5c637f49 (patch)
tree4c84a834de99899f736acf5470b89d1cbeee2ca9
parent07e6cee21b8236e8577666ea0f6363741d2d1ae3 (diff)
downloadzcomp-a94019f989004220a319c7c04429089f5c637f49.tar.gz
zcomp-a94019f989004220a319c7c04429089f5c637f49.tar.bz2
Add conversion operators to CompOption::Value
-rw-r--r--include/core/option.h11
-rw-r--r--src/option.cpp50
2 files changed, 61 insertions, 0 deletions
diff --git a/include/core/option.h b/include/core/option.h
index 0ee362e..b9f47c5 100644
--- a/include/core/option.h
+++ b/include/core/option.h
@@ -98,6 +98,17 @@ class CompOption {
bool operator!= (const Value& val);
Value & operator= (const Value &val);
+ operator bool ();
+ operator int ();
+ operator float();
+ operator unsigned short * ();
+ operator CompString ();
+ operator CompMatch & ();
+ operator CompAction & ();
+ operator CompAction * ();
+ operator Type ();
+ operator Vector & ();
+
private:
PrivateValue *priv;
};
diff --git a/src/option.cpp b/src/option.cpp
index 66b76cb..c8fcd2f 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -250,6 +250,56 @@ CompOption::Value::list ()
return priv->list;
}
+CompOption::Value::operator bool ()
+{
+ return b();
+}
+
+CompOption::Value::operator int ()
+{
+ return i();
+}
+
+CompOption::Value::operator float()
+{
+ return f();
+}
+
+CompOption::Value::operator unsigned short * ()
+{
+ return c();
+}
+
+CompOption::Value::operator CompString ()
+{
+ return s();
+}
+
+CompOption::Value::operator CompMatch & ()
+{
+ return match();
+}
+
+CompOption::Value::operator CompAction & ()
+{
+ return action();
+}
+
+CompOption::Value::operator CompAction * ()
+{
+ return &action();
+}
+
+CompOption::Value::operator Type ()
+{
+ return listType();
+}
+
+CompOption::Value::operator Vector & ()
+{
+ return list();
+}
+
bool
CompOption::Value::operator== (const CompOption::Value &val)
{