|
Boost-Commit : |
From: chochlik_at_[hidden]
Date: 2008-07-15 09:46:41
Author: matus.chochlik
Date: 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
New Revision: 47442
URL: http://svn.boost.org/trac/boost/changeset/47442
Log:
[mirror 0.2.x]
- Documentation update
Added:
sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_01.xml (contents, props changed)
sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_02.xml (contents, props changed)
sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_01.xml (contents, props changed)
sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_02.xml (contents, props changed)
sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_03.xml (contents, props changed)
Text files modified:
sandbox/mirror/boost/mirror/meta_data_fwd.hpp | 10 ++
sandbox/mirror/boost/mirror/meta_types/_native.hpp | 2
sandbox/mirror/doc/html/boost/mirror/meta_class.html | 8 +-
sandbox/mirror/doc/html/boost/mirror/meta_namespace.html | 142 +++++++++++++++++++++++++++++++++++----
sandbox/mirror/doc/html/boost/mirror/meta_type.html | 108 ++++++++++++++++++++++++-----
sandbox/mirror/doc/html/index.html | 2
sandbox/mirror/doc/html/mirror.html | 2
sandbox/mirror/libs/mirror/doc/reference/meta_namespace.xml | 70 +++++++++----------
sandbox/mirror/libs/mirror/doc/reference/meta_type.xml | 14 +++
sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_02.xml | 33 ++++++--
10 files changed, 302 insertions(+), 89 deletions(-)
Modified: sandbox/mirror/boost/mirror/meta_data_fwd.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_data_fwd.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_data_fwd.hpp 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -61,6 +61,16 @@
::boost::mirror::meta_type<TYPE>
/** Macro that expands into the meta_type for the
+ * given type or class. This is an alternate version
+ * of the BOOST_MIRRORED_TYPE taking the namespace
+ * and the type separatelly as two distinct args
+ * (thus the _NS suffix). It works however only
+ * with types defined in named namespaces.
+ */
+#define BOOST_MIRRORED_TYPE_NS(NAMESPACE, TYPE) \
+ ::boost::mirror::meta_type<NAMESPACE :: TYPE>
+
+/** Macro that expands into the meta_type for the
* given typedefined type.
*/
#define BOOST_MIRRORED_TYPEDEF(NAMESPACE, TYPEDEF) \
Modified: sandbox/mirror/boost/mirror/meta_types/_native.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_types/_native.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_types/_native.hpp 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -37,6 +37,8 @@
BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(float)
BOOST_MIRROR_REG_TYPE_GLOBAL_SCOPE(double)
+BOOST_MIRROR_REG_TYPEDEF(::std, size_t)
+
} // namespace mirror
} // namespace boost
Modified: sandbox/mirror/doc/html/boost/mirror/meta_class.html
==============================================================================
--- sandbox/mirror/doc/html/boost/mirror/meta_class.html (original)
+++ sandbox/mirror/doc/html/boost/mirror/meta_class.html 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -43,16 +43,16 @@
</em></span>
{
<span class="bold"><strong>public</strong></span>:
- <span class="emphasis"><em>// <a class="link" href="meta_class.html#id495310-bbtypes">types</a></em></span>
+ <span class="emphasis"><em>// <a class="link" href="meta_class.html#id459098-bbtypes">types</a></em></span>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_class.html#boost.mirror.meta_class.base_classes">base_classes</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_class.html#boost.mirror.meta_class.attributes">attributes</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_class.html#boost.mirror.meta_class.all_attributes">all_attributes</a>;
};</pre></div>
<div class="refsect1" lang="en">
-<a name="id671795"></a><h2>Description</h2>
+<a name="id706902"></a><h2>Description</h2>
<div class="refsect2" lang="en">
-<a name="id671798"></a><h3>
-<a name="id495310-bbtypes"></a><code class="computeroutput">meta_class</code> public types</h3>
+<a name="id706906"></a><h3>
+<a name="id459098-bbtypes"></a><code class="computeroutput">meta_class</code> public types</h3>
<div class="orderedlist"><ol type="1">
<li>
<p>
Modified: sandbox/mirror/doc/html/boost/mirror/meta_namespace.html
==============================================================================
--- sandbox/mirror/doc/html/boost/mirror/meta_namespace.html (original)
+++ sandbox/mirror/doc/html/boost/mirror/meta_namespace.html 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -37,7 +37,7 @@
namespace (with the exception of the global scope) use the reflection
macro <code class="computeroutput">BOOST_MIRRORED_NAMESPACE(FULL_NAMESPACE_NAME)</code>. To
get the <code class="computeroutput">meta_namespace</code> specialization for
- the global scope use the <code class="computeroutput">BOOST_MIRRORED_NAMESPACE()</code>
+ the global scope use the <code class="computeroutput">BOOST_MIRRORED_GLOBAL_SCOPE()</code>
macro.
</p>
</div>
@@ -45,19 +45,130 @@
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> NamespacePlaceholder>
<span class="bold"><strong>class</strong></span> <a class="link" href="meta_namespace.html" title="Class template meta_namespace">meta_namespace</a> {
<span class="bold"><strong>public</strong></span>:
- <span class="emphasis"><em>// <a class="link" href="meta_namespace.html#id496123-bbtypes">types</a></em></span>
+ <span class="emphasis"><em>// <a class="link" href="meta_namespace.html#id459983-bbtypes">types</a></em></span>
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_namespace.html#boost.mirror.meta_namespace.scope">scope</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_namespace.html#boost.mirror.meta_namespace.ancestors">ancestors</a>;
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id496009-bb">base_name</a>();
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id495967-bb">full_name</a>();
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id459860-bb">base_name</a>();
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id459818-bb">full_name</a>();
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>bool</strong></span> FullName>
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id495913-bb">get_name</a>(::boost::mpl::bool_<FullName>);
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_namespace.html#id459764-bb">get_name</a>(::boost::mpl::bool_<FullName>);
};</pre></div>
<div class="refsect1" lang="en">
-<a name="id670751"></a><h2>Description</h2>
+<a name="id705703"></a><h2>Description</h2>
+<p>The specializations of <code class="computeroutput">meta_type</code> can
+ be used to get meta-information about the reflected types, some at compile-time and some at run-time.
+ The following examples show type reflection and basic
+ <code class="computeroutput">meta_type</code> usage. Mirror works with the native C++ types
+ and some of the very common types like <code class="computeroutput">::std::string</code>, etc. out of the box.
+ Meta-types for many other types from the standard library and Boost
+ are also provided and can be <code class="computeroutput">#include</code>d when necessary.
+ </p>
+<div class="section" lang="en">
+<div class="titlepage"></div>
+<div class="toc"><dl>
+<dt><span class="section">Example - Basic usage</span></dt>
+<dt><span class="section">Example - Scope and ancestors</span></dt>
+</dl></div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h6 class="title">
+<a name="mirror.meta_namespace.reference.sample01"></a>Example - Basic usage</h6></div></div></div>
+<p>This sample code shows how to reflect a namespace and how to get its
+ base and full name.
+ </p>
+<a name="mirror.reference.sample.meta_namespace.usage01"></a><pre class="programlisting">
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_namespace.hpp>
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ cts::bostream& bcout = cts::bcout();
+
+ // several namespaces are pre-registered
+ bcout << BOOST_MIRRORED_GLOBAL_SCOPE() ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::std) ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost) ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost::mirror) ::base_name() << endl;
+ //
+ bcout << BOOST_MIRRORED_GLOBAL_SCOPE() ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::std) ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost) ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost::mirror) ::full_name() << endl;
+
+ return 0;
+}
+</pre>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h6 class="title">
+<a name="mirror.meta_namespace.reference.sample02"></a>Example - Scope and ancestors</h6></div></div></div>
+<p>The following example shows what can be done with the
+ <code class="computeroutput">meta_namespace</code>s <code class="computeroutput">scope</code> and
+ <code class="computeroutput">ancestors</code> <code class="computeroutput">typedef</code>s. It also shows the usage
+ of the <code class="computeroutput">reflects_global_scope</code> trait
+ template.
+ </p>
+<a name="mirror.reference.sample.meta_namespace.usage02"></a><pre class="programlisting">
+#include <boost/mpl/for_each.hpp>
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/traits/reflects_global_scope.hpp>
+
+class printer
+{
+public:
+ template <class MetaNamespace>
+ void operator()(MetaNamespace mn)
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ cts::bostream& bcout = cts::bcout();
+ bcout <<
+ BOOST_CTS_LIT("ancestor ") <<
+ ctr++ <<
+ BOOST_CTS_LIT(": '") <<
+ MetaNamespace::base_name() <<
+ BOOST_CTS_LIT("'") <<
+ endl;
+ }
+
+ printer(void):ctr(0){ }
+private:
+ int ctr;
+};
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ cts::bostream& bcout = cts::bcout();
+ //
+ typedef BOOST_MIRRORED_NAMESPACE(::boost::mirror) meta_boost_mirror;
+ //
+ // get the full name of the parent scope of the reflected namespace
+ bcout << meta_boost_mirror::scope::full_name() << endl;
+ //
+ // check whether the grandparent namespace is the global scope
+ if(reflects_global_scope<meta_boost_mirror::scope::scope> :: value)
+ bcout << BOOST_CTS_LIT("OK") << endl;
+ else
+ bcout << BOOST_CTS_LIT("Error") << endl;
+
+ // the ancestors typedef is an mpl vector of meta_namespaces
+ printer p;
+ mpl::for_each<meta_boost_mirror::ancestors>(p);
+
+ return 0;
+}
+</pre>
+</div>
+</div>
<div class="refsect2" lang="en">
-<a name="id670754"></a><h3>
-<a name="id496123-bbtypes"></a><code class="computeroutput">meta_namespace</code> public types</h3>
+<a name="id705799"></a><h3>
+<a name="id459983-bbtypes"></a><code class="computeroutput">meta_namespace</code> public types</h3>
<div class="orderedlist"><ol type="1">
<li>
<p>
@@ -84,7 +195,7 @@
for <code class="computeroutput">meta_namespace</code>s
reflecting any namespace with the exception of the global scope:
</p>
-<pre class="programlisting">
+<a name="mirror.reference.sample.meta_namespace.ancestors01"></a><pre class="programlisting">
using namespace ::boost;
using namespace ::boost::mirror;
@@ -112,24 +223,25 @@
BOOST_MIRRORED_NAMESPACE(::boost::mirror)::scope
>
));
- </pre>
+</pre>
<p>For the <code class="computeroutput">meta_namespace</code>
reflecting the global scope the following holds true.
</p>
-<pre class="programlisting">
+<a name="mirror.reference.sample.meta_namespace.ancestors02"></a><pre class="programlisting">
BOOST_MPL_ASSERT((
mpl::empty <
BOOST_MIRRORED_GLOBAL_SCOPE()::ancestors
>
));
- </pre>
+
+</pre>
<p>To find out whether a meta-namespace reflects the global scope
use the <code class="computeroutput">reflects_global_scope</code> template meta-function.
</p>
</li>
</ol></div>
</div>
-<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id496009-bb"></a>base_name();</pre>
+<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459860-bb"></a>base_name();</pre>
<p>This static member function returns the base name of the
namespace reflected by a <code class="computeroutput">meta_namespace</code>.
For example the base namespace name "returned" by the invocation of
@@ -141,7 +253,7 @@
<span class="bold"><strong>with</strong></span> the nested name specifier
is needed use the <code class="computeroutput">full_name</code> member function
instead.</p>
-<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id495967-bb"></a>full_name();</pre>
+<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459818-bb"></a>full_name();</pre>
<p>This static member function returns the full name of the
namespace reflected by a <code class="computeroutput">meta_namespace</code>
with the nested name specifier. For example:
@@ -167,7 +279,7 @@
</tr></tbody>
</table></div>
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>bool</strong></span> FullName>
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id495913-bb"></a>get_name(::boost::mpl::bool_<FullName> full);</pre>
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459764-bb"></a>get_name(::boost::mpl::bool_<FullName> full);</pre>
<p>This static member template function returns either the base name
<span class="bold"><strong>without</strong></span> the nested name specifier
or the full name <span class="bold"><strong>with</strong></span> the
Modified: sandbox/mirror/doc/html/boost/mirror/meta_type.html
==============================================================================
--- sandbox/mirror/doc/html/boost/mirror/meta_type.html (original)
+++ sandbox/mirror/doc/html/boost/mirror/meta_type.html 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -44,16 +44,16 @@
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>typename</strong></span> Type>
<span class="bold"><strong>class</strong></span> <a class="link" href="meta_type.html" title="Class template meta_type">meta_type</a> {
<span class="bold"><strong>public</strong></span>:
- <span class="emphasis"><em>// <a class="link" href="meta_type.html#id495672-bbtypes">types</a></em></span>
+ <span class="emphasis"><em>// <a class="link" href="meta_type.html#id459471-bbtypes">types</a></em></span>
<span class="bold"><strong>typedef</strong></span> Type <a class="link" href="meta_type.html#boost.mirror.meta_type.reflected_type">reflected_type</a>;
<span class="bold"><strong>typedef</strong></span> <span class="emphasis"><em>unspecified</em></span> <a class="link" href="meta_type.html#boost.mirror.meta_type.scope">scope</a>;
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id495610-bb">base_name</a>();
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id495550-bb">full_name</a>();
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id459410-bb">base_name</a>();
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id459350-bb">full_name</a>();
<span class="bold"><strong>template</strong></span><<span class="bold"><strong>bool</strong></span> FullName>
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id495490-bb">get_name</a>(::boost::mpl::bool_<FullName>);
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a class="link" href="meta_type.html#id459290-bb">get_name</a>(::boost::mpl::bool_<FullName>);
};</pre></div>
<div class="refsect1" lang="en">
-<a name="id671255"></a><h2>Description</h2>
+<a name="id706304"></a><h2>Description</h2>
<p>The specializations of <code class="computeroutput">meta_type</code> can
be used to get meta-information about the reflected types, some at compile-time and some at run-time.
The following examples show type reflection and basic
@@ -67,6 +67,7 @@
<div class="toc"><dl>
<dt><span class="section">Example - Basic usage</span></dt>
<dt><span class="section">Example - Using with typeof and getting scope-related information</span></dt>
+<dt><span class="section">Example - Reflection of typedef
-ined types</span></dt>
</dl></div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h6 class="title">
@@ -115,8 +116,8 @@
</p>
<a name="mirror.reference.sample.meta_type.usage02"></a><pre class="programlisting">
-#include <iostream>
#include <string>
+#include <boost/char_type_switch/iostream.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/mirror/meta_type.hpp>
#include <boost/mirror/meta_types/std_pair.hpp>
@@ -128,17 +129,30 @@
using namespace ::std;
using namespace ::boost;
using namespace ::boost::mirror;
-
+ cts::bostream& bcout = cts::bcout();
// print out the base type name
- wcout << "The type name is: "<< MetaType::base_name() << endl;
+ bcout <<
+ BOOST_CTS_LIT("The type name is: ") <<
+ MetaType::base_name() <<
+ endl;
//
- if(reflects_global_scope<MetaType::scope>::value)
- wcout << "It's defined on the global scope" << endl;
- else wcout <<
- "It's defined in the " <<
- MetaType::scope::full_name() <<
- " namespace" << endl;
- wcout << "--------------------------------------" << endl;
+ if(reflects_global_scope<typename MetaType::scope>::value)
+ {
+ bcout <<
+ BOOST_CTS_LIT("It's defined on the global scope") <<
+ endl;
+ }
+ else
+ {
+ bcout <<
+ BOOST_CTS_LIT("It's defined in the ") <<
+ MetaType::scope::full_name() <<
+ BOOST_CTS_LIT(" namespace") <<
+ endl;
+ bcout <<
+ BOOST_CTS_LIT("--------------------------------------") <<
+ endl;
+ }
}
int main(void)
@@ -166,10 +180,64 @@
}
</pre>
</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h6 class="title">
+<a name="mirror.meta_type.reference.sample03"></a>Example - Reflection of <code class="computeroutput">typedef</code>-ined types</h6></div></div></div>
+<p>The next example shows how to reflect <code class="computeroutput">typedef</code>-ined
+ types. This is useful when the info about the name and the scope of the <code class="computeroutput">typedef</code>
+ is required instead of the meta-information about the "source" type.
+ However, the usage shown in this example is not very common. The full utility becomes obvious
+ only when the <code class="computeroutput">meta_type</code> is part of
+ some other meta-structure like for example with <code class="computeroutput">typedef</code>'d class member attributes.
+ </p>
+<p>Mirror comes with several pre-registered <code class="computeroutput">typedef</code>s. If user-defined
+ <code class="computeroutput">typedef</code>s are to be reflected they need to be registered first.
+ </p>
+<a name="mirror.reference.sample.meta_type.usage03"></a><pre class="programlisting">
+
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_type.hpp>
+
+template <class MetaType>
+void print_meta_data(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ cts::bostream& bcout = cts::bcout();
+ bcout << BOOST_CTS_LIT("type: '");
+ bcout << MetaType::base_name();
+ bcout << BOOST_CTS_LIT("' defined in: '");
+ bcout << MetaType::scope::full_name();
+ bcout << BOOST_CTS_LIT("'");
+ bcout << endl;
+}
+
+int main(void)
+{
+ using namespace ::boost::mirror;
+ //
+ // the first arg is the namespace the second the typedefined type
+ typedef BOOST_MIRRORED_TYPEDEF(::boost::cts, bstring) meta_bstring_td;
+ // reflection of the "source" type
+ typedef BOOST_MIRRORED_TYPE(::boost::cts::bstring) meta_bstring;
+ //
+ print_meta_data< meta_bstring_td >();
+ print_meta_data< meta_bstring >();
+ //
+ print_meta_data< BOOST_MIRRORED_TYPEDEF(::std, size_t) >();
+ // this is another version of the BOOST_MIRRORED_TYPE macro
+ // that gets the namespace and the type as two separate args
+ print_meta_data< BOOST_MIRRORED_TYPE_NS(::std, size_t) >();
+ //
+
+ return 0;
+}
+</pre>
+</div>
</div>
<div class="refsect2" lang="en">
-<a name="id671335"></a><h3>
-<a name="id495672-bbtypes"></a><code class="computeroutput">meta_type</code> public types</h3>
+<a name="id706442"></a><h3>
+<a name="id459471-bbtypes"></a><code class="computeroutput">meta_type</code> public types</h3>
<div class="orderedlist"><ol type="1">
<li>
<p>
@@ -188,7 +256,7 @@
</li>
</ol></div>
</div>
-<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id495610-bb"></a>base_name();</pre>
+<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459410-bb"></a>base_name();</pre>
<p>This static member function returns the base name of the
type reflected by <code class="computeroutput">meta_type</code>
without the nested name specifier. For example:
@@ -218,7 +286,7 @@
</p></td>
</tr></tbody>
</table></div>
-<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id495550-bb"></a>full_name();</pre>
+<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459350-bb"></a>full_name();</pre>
<p>This static member function returns the full name of the
type reflected by <code class="computeroutput">meta_type</code>
with the nested name specifier. For example:
@@ -249,7 +317,7 @@
</tr></tbody>
</table></div>
<pre class="literallayout"><span class="bold"><strong>template</strong></span><<span class="bold"><strong>bool</strong></span> FullName>
- <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id495490-bb"></a>get_name(::boost::mpl::bool_<FullName> full);</pre>
+ <span class="type"><span class="bold"><strong>const</strong></span> cts::bstring&</span> <a name="id459290-bb"></a>get_name(::boost::mpl::bool_<FullName> full);</pre>
<p>This static member template function returns either the base name
<span class="bold"><strong>without</strong></span> the nested name specifier
or the full name <span class="bold"><strong>with</strong></span> the
Modified: sandbox/mirror/doc/html/index.html
==============================================================================
--- sandbox/mirror/doc/html/index.html (original)
+++ sandbox/mirror/doc/html/index.html 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -21,7 +21,7 @@
<div class="book" lang="en">
<div class="titlepage">
<div><div><h1 class="title">
-<a name="id568709"></a>The Mirror library documentation</h1></div></div>
+<a name="id603662"></a>The Mirror library documentation</h1></div></div>
<hr>
</div>
<div class="toc">
Modified: sandbox/mirror/doc/html/mirror.html
==============================================================================
--- sandbox/mirror/doc/html/mirror.html (original)
+++ sandbox/mirror/doc/html/mirror.html 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -34,7 +34,7 @@
</div></div>
<div><p class="copyright">Copyright © 2008 Matúš Chochlík</p></div>
<div><div class="legalnotice">
-<a name="id670193"></a><p>Use, modification and distribution is subject to the Boost
+<a name="id705145"></a><p>Use, modification and distribution is subject to the Boost
Software License, Version 1.0. (See accompanying file
<code class="filename">LICENSE_1_0.txt</code> or copy at http://www.boost.org/LICENSE_1_0.txt)
</p>
Modified: sandbox/mirror/libs/mirror/doc/reference/meta_namespace.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/reference/meta_namespace.xml (original)
+++ sandbox/mirror/libs/mirror/doc/reference/meta_namespace.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -21,10 +21,39 @@
namespace (with the exception of the global scope) use the reflection
macro <code><macroname>BOOST_MIRRORED_NAMESPACE</macroname>(FULL_NAMESPACE_NAME)</code>. To
get the <code><classname>meta_namespace</classname></code> specialization for
- the global scope use the <code><macroname>BOOST_MIRRORED_NAMESPACE</macroname>()</code>
+ the global scope use the <code><macroname>BOOST_MIRRORED_GLOBAL_SCOPE</macroname>()</code>
macro.
</para>
</purpose>
+ <description>
+ <para>The specializations of <code><classname>meta_type</classname></code> can
+ be used to get meta-information about the reflected types, some at compile-time and some at run-time.
+ The following examples show type reflection and basic
+ <code><classname>meta_type</classname></code> usage. Mirror works with the native C++ types
+ and some of the very common types like <code>::std::string</code>, etc. out of the box.
+ Meta-types for many other types from the standard library and <libraryname>Boost</libraryname>
+ are also provided and can be <code>#include</code>d when necessary.
+ </para>
+ <section id="mirror.meta_namespace.reference.samples">
+ <section id="mirror.meta_namespace.reference.sample01">
+ <title>Example - Basic usage</title>
+ <para>This sample code shows how to reflect a namespace and how to get its
+ base and full name.
+ </para>
+ <xi:include href="../samples/usage_meta_namespace_01.xml"/>
+ </section>
+ <section id="mirror.meta_namespace.reference.sample02">
+ <title>Example - Scope and ancestors</title>
+ <para>The following example shows what can be done with the
+ <code><classname>meta_namespace</classname></code>s <code>scope</code> and
+ <code>ancestors</code> <code>typedef</code>s. It also shows the usage
+ of the <code><classname>reflects_global_scope</classname></code> trait
+ template.
+ </para>
+ <xi:include href="../samples/usage_meta_namespace_02.xml"/>
+ </section>
+ </section>
+ </description>
<access name="public">
<typedef name="scope">
@@ -55,46 +84,11 @@
for <code><classname>meta_namespace</classname></code>s
reflecting any namespace with the exception of the global scope:
</para>
- <programlisting>
-using namespace ::boost;
-using namespace ::boost::mirror;
-
-BOOST_MPL_ASSERT((
- reflects_global_scope <
- mpl::front <
- BOOST_MIRRORED_NAMESPACE(::std)::ancestors
- >
- >
-));
-
-BOOST_MPL_ASSERT((
- reflects_global_scope <
- mpl::front <
- BOOST_MIRRORED_NAMESPACE(::boost::mirror)::ancestors
- >
- >
-));
-
-BOOST_MPL_ASSERT((
- is_same <
- mpl::back <
- BOOST_MIRRORED_NAMESPACE(::boost::mirror)::ancestors
- >,
- BOOST_MIRRORED_NAMESPACE(::boost::mirror)::scope
- >
-));
- </programlisting>
+ <xi:include href="../samples/meta_namespace_ancestors_01.xml"/>
<para>For the <code><classname>meta_namespace</classname></code>
reflecting the global scope the following holds true.
</para>
-
- <programlisting>
-BOOST_MPL_ASSERT((
- mpl::empty <
- BOOST_MIRRORED_GLOBAL_SCOPE()::ancestors
- >
-));
- </programlisting>
+ <xi:include href="../samples/meta_namespace_ancestors_02.xml"/>
<para>To find out whether a meta-namespace reflects the global scope
use the <code><classname>reflects_global_scope</classname></code> template meta-function.
</para>
Modified: sandbox/mirror/libs/mirror/doc/reference/meta_type.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/reference/meta_type.xml (original)
+++ sandbox/mirror/libs/mirror/doc/reference/meta_type.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -50,6 +50,20 @@
</para>
<xi:include href="../samples/usage_meta_type_02.xml"/>
</section>
+ <section id="mirror.meta_type.reference.sample03">
+ <title>Example - Reflection of <code>typedef</code>-ined types</title>
+ <para>The next example shows how to reflect <code>typedef</code>-ined
+ types. This is useful when the info about the name and the scope of the <code>typedef</code>
+ is required instead of the meta-information about the "source" type.
+ However, the usage shown in this example is not very common. The full utility becomes obvious
+ only when the <code><classname>meta_type</classname></code> is part of
+ some other meta-structure like for example with <code>typedef</code>'d class member attributes.
+ </para>
+ <para>Mirror comes with several pre-registered <code>typedef</code>s. If user-defined
+ <code>typedef</code>s are to be reflected they need to be registered first.
+ </para>
+ <xi:include href="../samples/usage_meta_type_03.xml"/>
+ </section>
</section>
</description>
Added: sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_01.xml
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_01.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<programlisting id="mirror.reference.sample.meta_namespace.ancestors01">
+using namespace ::boost;
+using namespace ::boost::mirror;
+
+BOOST_MPL_ASSERT((
+ reflects_global_scope <
+ mpl::front <
+ BOOST_MIRRORED_NAMESPACE(::std)::ancestors
+ >
+ >
+));
+
+BOOST_MPL_ASSERT((
+ reflects_global_scope <
+ mpl::front <
+ BOOST_MIRRORED_NAMESPACE(::boost::mirror)::ancestors
+ >
+ >
+));
+
+BOOST_MPL_ASSERT((
+ is_same <
+ mpl::back <
+ BOOST_MIRRORED_NAMESPACE(::boost::mirror)::ancestors
+ >,
+ BOOST_MIRRORED_NAMESPACE(::boost::mirror)::scope
+ >
+));
+</programlisting>
+
Added: sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_02.xml
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/doc/samples/meta_namespace_ancestors_02.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<programlisting id="mirror.reference.sample.meta_namespace.ancestors02">
+BOOST_MPL_ASSERT((
+ mpl::empty <
+ BOOST_MIRRORED_GLOBAL_SCOPE()::ancestors
+ >
+));
+
+</programlisting>
+
Added: sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_01.xml
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_01.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<programlisting id="mirror.reference.sample.meta_namespace.usage01">
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_namespace.hpp>
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ cts::bostream& bcout = cts::bcout();
+
+ // several namespaces are pre-registered
+ bcout << BOOST_MIRRORED_GLOBAL_SCOPE() ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::std) ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost) ::base_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost::mirror) ::base_name() << endl;
+ //
+ bcout << BOOST_MIRRORED_GLOBAL_SCOPE() ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::std) ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost) ::full_name() << endl;
+ bcout << BOOST_MIRRORED_NAMESPACE(::boost::mirror) ::full_name() << endl;
+
+ return 0;
+}
+</programlisting>
+
Added: sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_02.xml
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/doc/samples/usage_meta_namespace_02.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<programlisting id="mirror.reference.sample.meta_namespace.usage02">
+#include <boost/mpl/for_each.hpp>
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/traits/reflects_global_scope.hpp>
+
+class printer
+{
+public:
+ template <class MetaNamespace>
+ void operator()(MetaNamespace mn)
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ cts::bostream& bcout = cts::bcout();
+ bcout <<
+ BOOST_CTS_LIT("ancestor ") <<
+ ctr++ <<
+ BOOST_CTS_LIT(": '") <<
+ MetaNamespace::base_name() <<
+ BOOST_CTS_LIT("'") <<
+ endl;
+ }
+
+ printer(void):ctr(0){ }
+private:
+ int ctr;
+};
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ cts::bostream& bcout = cts::bcout();
+ //
+ typedef BOOST_MIRRORED_NAMESPACE(::boost::mirror) meta_boost_mirror;
+ //
+ // get the full name of the parent scope of the reflected namespace
+ bcout << meta_boost_mirror::scope::full_name() << endl;
+ //
+ // check whether the grandparent namespace is the global scope
+ if(reflects_global_scope<meta_boost_mirror::scope::scope> :: value)
+ bcout << BOOST_CTS_LIT("OK") << endl;
+ else
+ bcout << BOOST_CTS_LIT("Error") << endl;
+
+ // the ancestors typedef is an mpl vector of meta_namespaces
+ printer p;
+ mpl::for_each<meta_boost_mirror::ancestors>(p);
+
+ return 0;
+}
+</programlisting>
+
Modified: sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_02.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_02.xml (original)
+++ sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_02.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -3,8 +3,8 @@
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<programlisting id="mirror.reference.sample.meta_type.usage02">
-#include <iostream>
#include <string>
+#include <boost/char_type_switch/iostream.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/mirror/meta_type.hpp>
#include <boost/mirror/meta_types/std_pair.hpp>
@@ -16,17 +16,30 @@
using namespace ::std;
using namespace ::boost;
using namespace ::boost::mirror;
-
+ cts::bostream& bcout = cts::bcout();
// print out the base type name
- wcout << "The type name is: "<< MetaType::base_name() << endl;
+ bcout <<
+ BOOST_CTS_LIT("The type name is: ") <<
+ MetaType::base_name() <<
+ endl;
//
- if(reflects_global_scope<MetaType::scope>::value)
- wcout << "It's defined on the global scope" << endl;
- else wcout <<
- "It's defined in the " <<
- MetaType::scope::full_name() <<
- " namespace" << endl;
- wcout << "--------------------------------------" << endl;
+ if(reflects_global_scope<typename MetaType::scope>::value)
+ {
+ bcout <<
+ BOOST_CTS_LIT("It's defined on the global scope") <<
+ endl;
+ }
+ else
+ {
+ bcout <<
+ BOOST_CTS_LIT("It's defined in the ") <<
+ MetaType::scope::full_name() <<
+ BOOST_CTS_LIT(" namespace") <<
+ endl;
+ bcout <<
+ BOOST_CTS_LIT("--------------------------------------") <<
+ endl;
+ }
}
int main(void)
Added: sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_03.xml
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/doc/samples/usage_meta_type_03.xml 2008-07-15 09:46:40 EDT (Tue, 15 Jul 2008)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<programlisting id="mirror.reference.sample.meta_type.usage03">
+
+#include <boost/char_type_switch/iostream.hpp>
+#include <boost/mirror/meta_type.hpp>
+
+template <class MetaType>
+void print_meta_data(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ cts::bostream& bcout = cts::bcout();
+ bcout << BOOST_CTS_LIT("type: '");
+ bcout << MetaType::base_name();
+ bcout << BOOST_CTS_LIT("' defined in: '");
+ bcout << MetaType::scope::full_name();
+ bcout << BOOST_CTS_LIT("'");
+ bcout << endl;
+}
+
+int main(void)
+{
+ using namespace ::boost::mirror;
+ //
+ // the first arg is the namespace the second the typedefined type
+ typedef BOOST_MIRRORED_TYPEDEF(::boost::cts, bstring) meta_bstring_td;
+ // reflection of the "source" type
+ typedef BOOST_MIRRORED_TYPE(::boost::cts::bstring) meta_bstring;
+ //
+ print_meta_data< meta_bstring_td >();
+ print_meta_data< meta_bstring >();
+ //
+ print_meta_data< BOOST_MIRRORED_TYPEDEF(::std, size_t) >();
+ // this is another version of the BOOST_MIRRORED_TYPE macro
+ // that gets the namespace and the type as two separate args
+ print_meta_data< BOOST_MIRRORED_TYPE_NS(::std, size_t) >();
+ //
+
+ return 0;
+}
+</programlisting>
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk