diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-14 09:07:19 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-14 09:07:19 +0200 |
commit | 792497f731c5c3a93a442bd487bd7ae4e0ffb2bf (patch) | |
tree | 4145bb0adaa205a01eb34b50c8ff690729c5d02b /zend | |
parent | 7df281b04d7286cd1cf7cad55848b6bf4a250c24 (diff) | |
parent | 06ca40ff782231f58d629b09004700714d96fa0c (diff) |
Merge pull request #82 from valmat/ini
Php::Ini_get()
Diffstat (limited to 'zend')
-rw-r--r-- | zend/includes.h | 1 | ||||
-rw-r--r-- | zend/ini.cpp | 1 | ||||
-rw-r--r-- | zend/inivalue.cpp | 59 |
3 files changed, 61 insertions, 0 deletions
diff --git a/zend/includes.h b/zend/includes.h index 4aa5eb0..cabb096 100644 --- a/zend/includes.h +++ b/zend/includes.h @@ -45,6 +45,7 @@ /** * Include other files from this library */ +#include "../include/inivalue.h" #include "../include/ini.h" #include "../include/exception.h" #include "../include/streams.h" diff --git a/zend/ini.cpp b/zend/ini.cpp index 25f081a..889e388 100644 --- a/zend/ini.cpp +++ b/zend/ini.cpp @@ -48,6 +48,7 @@ void Ini::fill(zend_ini_entry *ini_entry, int module_number) ini_entry->displayer = nullptr; } + /** * End of namespace */ 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 + */ +} + + |