summaryrefslogtreecommitdiff
path: root/zend/inivalue.cpp
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-04-14 00:36:01 +0600
committervalmat <ufabiz@gmail.com>2014-04-14 00:36:01 +0600
commit06ca40ff782231f58d629b09004700714d96fa0c (patch)
tree4145bb0adaa205a01eb34b50c8ff690729c5d02b /zend/inivalue.cpp
parente6660c521ea5d03e0caffa2a1f69e6e28982ab8b (diff)
Separated class IniValue from class Ini
Also replaced Ini::get() on ini_get() see https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/64#issuecomment-40313791
Diffstat (limited to 'zend/inivalue.cpp')
-rw-r--r--zend/inivalue.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/zend/inivalue.cpp b/zend/inivalue.cpp
new file mode 100644
index 0000000..f89dcd2
--- /dev/null
+++ b/zend/inivalue.cpp
@@ -0,0 +1,59 @@
+/**
+ * IniValue.cpp
+ *
+ * Class IniValue designed for extracting values from ini entries
+ *
+ * @copyright 2013 Copernica BV
+ */
+#include "includes.h"
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * Cast to a number
+ * @return uint64_t
+ */
+int64_t IniValue::numericValue() const
+{
+ return zend_ini_long(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
+
+}
+
+/**
+ * Get access to the raw buffer for read operationrs.
+ * @return const char *
+ */
+const char* IniValue::rawValue() const
+{
+ return zend_ini_string(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
+}
+
+/**
+ * Cast to a floating point
+ * @return double
+ */
+IniValue::operator double() const
+{
+ return zend_ini_double(const_cast<char*>(_name.c_str()), _name.size()+1, _isorig);
+}
+
+/**
+ * Custom output stream operator
+ * @param stream
+ * @param ini_val
+ * @return ostream
+ */
+std::ostream &operator<<(std::ostream &stream, const IniValue &ini_val)
+{
+ return stream << static_cast<const char*>(ini_val);
+}
+
+/**
+ * End of namespace
+ */
+}
+
+