summaryrefslogtreecommitdiff
path: root/include/namespace.h
diff options
context:
space:
mode:
authorMartijn Otto <martijn.otto@copernica.com>2015-03-26 16:00:10 +0100
committerMartijn Otto <martijn.otto@copernica.com>2015-03-26 16:00:10 +0100
commit7a928e2b19bddf152fd838469cc50805d4132401 (patch)
tree0a6657f4b94c27556b2f218e407f752018540d3b /include/namespace.h
parentae4fa5f871d937773e9facde87a32784e715e3ae (diff)
Changed default visibility for symbols in the PHP-CPP library to hidden and explicitly exported all symbols available from the public API. Moved the hiddenpointer to the zend implementation directory as it is not meant to be used publicly and not referenced anywhere from the API anyway
Diffstat (limited to 'include/namespace.h')
-rw-r--r--include/namespace.h69
1 files changed, 34 insertions, 35 deletions
diff --git a/include/namespace.h b/include/namespace.h
index 4bb23db..bdfb8c6 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -1,9 +1,9 @@
/**
* Namespace.h
- *
+ *
* Class that can be used to group various functions and classes into one
* namespace.
- *
+ *
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2014 Copernica BV
*/
@@ -21,7 +21,7 @@ class NativeFunction;
/**
* Class definition
*/
-class Namespace
+class PHPCPP_EXPORT Namespace
{
protected:
/**
@@ -41,13 +41,13 @@ protected:
* @var list
*/
std::list<std::shared_ptr<ClassBase>> _classes;
-
+
/**
* Constants defined in the namespace
* @var list
*/
std::list<std::shared_ptr<Constant>> _constants;
-
+
/**
* Namespaces defined inside the namespace
* @var list
@@ -56,19 +56,19 @@ protected:
/**
* Is the object locked?
- *
+ *
* After the object is locked, no more elements can be added to it.
* This happens after the call to get_module - it the no longer makes
* sense to add more objects. When 'apache reload' is executed, the
* get_module() function is called for a second (or third, or fourth)
* time, but the classes, functions and namespaces will then not be
* filled.
- *
+ *
* @var bool
*/
virtual bool locked() const
{
- // by default, namespaces are not locked (only derived extension
+ // by default, namespaces are not locked (only derived extension
// objects can end up in a locked state
return false;
}
@@ -80,12 +80,12 @@ public:
* @param name Name of the namespace
*/
Namespace(const char *name) : _name(name) {}
-
+
/**
* Destructor
*/
virtual ~Namespace() {}
-
+
/**
* Add a native function directly to the namespace
* @param name Name of the function
@@ -97,7 +97,7 @@ public:
Namespace &add(const char *name, const native_callback_1 &function, const Arguments &arguments = {});
Namespace &add(const char *name, const native_callback_2 &function, const Arguments &arguments = {});
Namespace &add(const char *name, const native_callback_3 &function, const Arguments &arguments = {});
-
+
/**
* Add a native class to the namespace by moving it
* @param type The class implementation
@@ -108,10 +108,10 @@ public:
{
// skip when locked
if (locked()) return *this;
-
+
// make a copy of the object, and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(new Class<T>(std::move(type))));
-
+
// allow chaining
return *this;
}
@@ -129,7 +129,7 @@ public:
// and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(new Class<T>(type)));
-
+
// allow chaining
return *this;
}
@@ -146,7 +146,7 @@ public:
// make a copy and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(new Interface(std::move(interface))));
-
+
// allow chaining
return *this;
}
@@ -163,11 +163,11 @@ public:
// make a copy and add it to the list of classes
_classes.push_back(std::unique_ptr<ClassBase>(new Interface(interface)));
-
+
// allow chaining
return *this;
}
-
+
/**
* Add a constant to the namespace
* @param constant The constant to add
@@ -180,11 +180,11 @@ public:
// and add it to the list of constants
_constants.push_back(std::unique_ptr<Constant>(new Constant(std::move(constant))));
-
+
// allow chaining
return *this;
}
-
+
/**
* Add a constant to the namespace
* @param constant The constant to add
@@ -197,11 +197,11 @@ public:
// and add it to the list of constants
_constants.push_back(std::unique_ptr<Constant>(new Constant(constant)));
-
+
// allow chaining
return *this;
}
-
+
/**
* Add a namespace to the namespace by moving it
* @param ns The namespace
@@ -214,7 +214,7 @@ public:
// add it to the list of namespaces
_namespaces.push_back(std::unique_ptr<Namespace>(new Namespace(std::move(ns))));
-
+
// allow chaining
return *this;
}
@@ -231,7 +231,7 @@ public:
// make a copy and add it to the list of namespaces
_namespaces.push_back(std::unique_ptr<Namespace>(new Namespace(ns)));
-
+
// allow chaining
return *this;
}
@@ -244,48 +244,47 @@ public:
{
// number of functions in this namespace
int result = _functions.size();
-
+
// number of functions in sub-namespace
for (auto &ns : _namespaces) result += ns->functions();
-
+
// done
return result;
}
/**
* Apply a callback to each registered function
- *
+ *
* The callback will be called with the name of the namespace, and
* a reference to the registered function.
- *
+ *
* @param callback
*/
void functions(const std::function<void(const std::string &ns, NativeFunction &func)> &callback);
-
+
/**
* Apply a callback to each registered class
- *
+ *
* The callback will be called with the name of the namespace, and
* a reference to the registered class.
- *
+ *
* @param callback
*/
void classes(const std::function<void(const std::string &ns, ClassBase &clss)> &callback);
-
+
/**
* Apply a callback to each registered constant
- *
+ *
* The callback will be called with the name of the namespace, and
* a reference to the registered constant
- *
+ *
* @param callback
*/
void constants(const std::function<void(const std::string &ns, Constant &constant)> &callback);
};
-
+
/**
* End namespace
*/
}
-