diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ini.h | 15 | ||||
-rw-r--r-- | include/namespace.h | 6 |
2 files changed, 16 insertions, 5 deletions
diff --git a/include/ini.h b/include/ini.h index 2223bee..9d4cbd9 100644 --- a/include/ini.h +++ b/include/ini.h @@ -116,9 +116,20 @@ namespace Php { * @param int module_number */ void fill(_zend_ini_entry *ini_entry, int module_number); - + /** + * Compare by name + * A predicate that takes two arguments of type Ini. + * Used when adding elements of type Ini in the container std::set + */ + struct Compare + { + int operator()(const std::shared_ptr<Ini> &s1, const std::shared_ptr<Ini> &s2) const + { + return s1->_name.compare(s2->_name); + } + }; private: @@ -128,7 +139,7 @@ namespace Php { } // ini entry name - const char* _name; + std::string _name; // ini entry value std::string _value; diff --git a/include/namespace.h b/include/namespace.h index 645eace..468a423 100644 --- a/include/namespace.h +++ b/include/namespace.h @@ -52,7 +52,7 @@ protected: * Ini entry defined by the extension * @var list */ - std::list<std::shared_ptr<Ini>> _ini_entries; + std::set<std::shared_ptr<Ini>, Ini::Compare> _ini_entries; public: /** @@ -172,7 +172,7 @@ public: Namespace &add(Ini &&ini) { // and add it to the list of classes - _ini_entries.push_back(std::unique_ptr<Ini>(new Ini(std::move(ini)))); + _ini_entries.emplace(new Ini(std::move(ini))); // allow chaining return *this; @@ -186,7 +186,7 @@ public: Namespace &add(const Ini &ini) { // and add it to the list of classes - _ini_entries.push_back(std::unique_ptr<Ini>(new Ini(ini))); + _ini_entries.emplace(new Ini(ini)); // allow chaining return *this; |