summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasperVanEck <jaspergkurtz@gmail.com>2013-11-29 10:53:22 +0100
committerJasperVanEck <jaspergkurtz@gmail.com>2013-11-29 10:53:22 +0100
commitdf717775f6e484cd8901e01d5a355f1683fbeb64 (patch)
tree80efdd5c54fd79812c285019482956997bcb4379
parentf22a2c5f26eba8f4e907e8919c56b67038c95354 (diff)
Partial Exception implementation added, inherits from std::exception
-rw-r--r--include/exception.h28
-rw-r--r--phpcpp.h1
-rw-r--r--src/exception.cpp1
-rw-r--r--src/function.cpp4
-rwxr-xr-xsrc/libphpcpp.sobin132635 -> 132689 bytes
5 files changed, 20 insertions, 14 deletions
diff --git a/include/exception.h b/include/exception.h
index ea328fe..f787582 100644
--- a/include/exception.h
+++ b/include/exception.h
@@ -5,6 +5,7 @@
* @author Jasper van Eck <jasper.vaneck@copernica.com>
* @copyright 2013 Copernica BV
*/
+#include <exception>
/**
* Set up namespace
@@ -14,41 +15,44 @@ namespace Php {
/**
* Class definition
*/
-class Exception
+class Exception : public std::exception
{
private:
/**
* The exception message
- * @var char*
+ * @var char*
*/
- char* _message;
+ std::string _message;
public:
/**
* Constructor
- * @param string The exception message.
+ * @param &string
*/
- Exception(char* message) throw()
+ Exception(const std::string &message) : std::exception(), _message(message)
{
- _message = message;
}
-
+
/**
- * Destructor
+ * Destructor
*/
- ~Exception() throw()
+ virtual ~Exception()
{
}
/**
* Returns the message of the exception.
- * @return std::string
+ * @return &string
*/
- char* getMessage() const throw()
+ std::string &message() throw()
{
return _message;
}
-
};
+/**
+ * End of namespace
+ */
}
+
+
diff --git a/phpcpp.h b/phpcpp.h
index 170613f..37ccb4b 100644
--- a/phpcpp.h
+++ b/phpcpp.h
@@ -17,6 +17,7 @@
#include <map>
#include <memory>
#include <set>
+#include <exception>
/**
* Include all headers files that are related to this library
diff --git a/src/exception.cpp b/src/exception.cpp
index 19591db..f60f27c 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -14,4 +14,5 @@
namespace Php {
+
}
diff --git a/src/function.cpp b/src/function.cpp
index fe96745..ef9cf78 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -43,9 +43,9 @@ void invoke_function(INTERNAL_FUNCTION_PARAMETERS)
// get the result
result = function->invoke(*PHPCPP_G(environment), params);
}
- catch (const Php::Exception &exception)
+ catch (Php::Exception &exception)
{
- zend_throw_exception(zend_exception_get_default(), exception.getMessage(), 0 TSRMLS_CC);
+ zend_throw_exception(zend_exception_get_default(), (char*)exception.message().c_str(), 0 TSRMLS_CC);
}
}
diff --git a/src/libphpcpp.so b/src/libphpcpp.so
index d217cab..2b81ba7 100755
--- a/src/libphpcpp.so
+++ b/src/libphpcpp.so
Binary files differ