summaryrefslogtreecommitdiff
path: root/tests/cpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpp/include')
-rw-r--r--tests/cpp/include/Classes_and_objects.h (renamed from tests/cpp/include/MyCustomClass.h)62
1 files changed, 57 insertions, 5 deletions
diff --git a/tests/cpp/include/MyCustomClass.h b/tests/cpp/include/Classes_and_objects.h
index 02ff44b..e9b7434 100644
--- a/tests/cpp/include/MyCustomClass.h
+++ b/tests/cpp/include/Classes_and_objects.h
@@ -1,7 +1,7 @@
/**
*
*
- *
+ * Classes_and_objects.h
*
*/
@@ -12,10 +12,6 @@
namespace TestBaseClass {
-/**
- * Namespace to use
- */
- using namespace std;
class MyCustomClass : public Php::Base, public Php::Countable
{
@@ -61,6 +57,62 @@ namespace TestBaseClass {
};
+ /**
+ * custom comparison operator
+ */
+ class Comparable : public Php::Base
+ {
+ private:
+ /**
+ * Internal value of the class
+ * @var int
+ */
+ static int count;
+ int _nom;
+ int _value;
+
+ public:
+ /**
+ * C++ constructor
+ */
+ Comparable()
+ {
+ // start with random value
+ //_value = rand();
+ _nom = ++count;
+ _value = _nom%2+1;
+ }
+
+ /**
+ * C++ destructor
+ */
+ virtual ~Comparable() {}
+
+ /**
+ * Cast the object to a string
+ * @return std::string
+ */
+ std::string __toString()
+ {
+ return "Obj#" + std::to_string(_nom) + "(" + std::to_string(_value) + ")";
+ }
+
+ /**
+ * Compare with a different object
+ * @param that
+ * @return int
+ */
+ int __compare(const Comparable &that) const
+ {
+ return _value - that._value;
+ }
+ };
+ int Comparable::count = 0;
+
+
+
+
+
/**
* End of namespace