From 7fedcda2218dc1839411cdac76cbebda0a17dcdd Mon Sep 17 00:00:00 2001
From: Joel Bosveld <Joel.Bosveld@gmail.com>
Date: Thu, 26 Feb 2009 20:35:26 +0900
Subject: [PATCH] Add conversion operators to CompOption::Value

---
 include/core/option.h |   11 ++++++++++
 src/option.cpp        |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
 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)
 {
-- 
1.6.0.6

