From 5ea3a8d897496cbbafc5202b2b874396cb37914e Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 18 Jan 2015 23:34:34 +0100 Subject: implemented namespace::constants() method --- zend/namespace.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'zend') diff --git a/zend/namespace.cpp b/zend/namespace.cpp index 893f2f0..575becf 100644 --- a/zend/namespace.cpp +++ b/zend/namespace.cpp @@ -139,6 +139,31 @@ void Namespace::classes(const std::function &callback) +{ + // loop through the constants, and apply the callback + for (auto &c : _constants) callback(_name, *c); + + // loop through the other namespaces + for (auto &ns : _namespaces) ns->constants([this, callback](const std::string &ns, Constant &constant) { + + // if this is the root namespace, we don't have to change the prefix + if (_name.size() == 0) return callback(ns, constant); + + // construct a new prefix + // @todo this could be slightly inefficient + return callback(_name + "\\" + ns, constant); + }); +} + /** * End namespace */ -- cgit v1.2.3