[colobot] 103/145: Added C++ operator overloads to CBotVar

Didier Raboud odyx at moszumanska.debian.org
Mon Jul 11 12:56:22 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit b56cd11c9805e49957f13f7535cfbdc9c3a1dce7
Author: krzys-h <krzys_h at interia.pl>
Date:   Sun May 29 00:06:34 2016 +0200

    Added C++ operator overloads to CBotVar
---
 src/CBot/CBotVar/CBotVar.cpp | 34 ++++++++++++++++++++++++++++++++++
 src/CBot/CBotVar/CBotVar.h   |  8 ++++++++
 2 files changed, 42 insertions(+)

diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp
index fc4503e..4e88cd6 100644
--- a/src/CBot/CBotVar/CBotVar.cpp
+++ b/src/CBot/CBotVar/CBotVar.cpp
@@ -741,5 +741,39 @@ CBotClass* CBotVar::GetClass()
     return nullptr;
 }
 
+CBotVar::operator int()
+{
+    return GetValInt();
+}
+
+CBotVar::operator float()
+{
+    return GetValFloat();
+}
+
+CBotVar::operator std::string()
+{
+    return GetValString();
+}
+
+void CBotVar::operator=(const CBotVar &var)
+{
+    SetVal(const_cast<CBotVar*>(&var));
+}
+
+void CBotVar::operator=(int x)
+{
+    SetValInt(x);
+}
+
+void CBotVar::operator=(float x)
+{
+    SetValFloat(x);
+}
+
+void CBotVar::operator=(const std::string &x)
+{
+    SetValString(x);
+}
 
 } // namespace CBot
diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h
index be17178..7babb7d 100644
--- a/src/CBot/CBotVar/CBotVar.h
+++ b/src/CBot/CBotVar/CBotVar.h
@@ -444,6 +444,14 @@ public:
      */
     //@{
 
+    operator int();
+    operator float();
+    operator std::string();
+    void operator=(const CBotVar& var);
+    void operator=(int x);
+    void operator=(float x);
+    void operator=(const std::string &x);
+
     /**
      * \brief Set the value
      * \param var Another variable to copy value from

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list