Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-15 04:58:42


Author: matus.chochlik
Date: 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
New Revision: 44428
URL: http://svn.boost.org/trac/boost/changeset/44428

Log:
Initial commit of the mirror library source files.
Added:
   sandbox/mirror/boost/
   sandbox/mirror/boost/char_type_switch/
   sandbox/mirror/boost/char_type_switch/choice.hpp (contents, props changed)
   sandbox/mirror/boost/char_type_switch/iostream.hpp (contents, props changed)
   sandbox/mirror/boost/char_type_switch/string.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/
   sandbox/mirror/boost/mirror/access_spec.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/class_kind_spec.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/common_defs.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/detail/
   sandbox/mirror/boost/mirror/inherit_spec.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_attribs_base.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_attribs_getset.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_attributes.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_class.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_inheritance.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_namespace.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_type.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_types/
   sandbox/mirror/boost/mirror/utils/
   sandbox/mirror/boost/mirror/utils/name_to_stream.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/visitors/
   sandbox/mirror/boost/mirror/visitors/fallback.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/visitors/sample.hpp (contents, props changed)

Added: sandbox/mirror/boost/char_type_switch/choice.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/char_type_switch/choice.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,26 @@
+/**
+ * \file boost/char_width_switch/choice.hpp
+ * Definition of pp symbols for choosing of the used character type
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_CHAR_WIDTH_SWITCH_CHOICE
+#define BOOST_CHAR_WIDTH_SWITCH_CHOICE
+
+namespace boost {
+
+// TODO: there is a lot of work to do here ;)
+#ifndef BOOST_USE_WIDE_CHARS
+
+# ifdef UNICODE
+# define BOOST_USE_WIDE_CHARS
+# endif
+
+#endif
+
+} // namespace boost
+
+#endif //include guard

Added: sandbox/mirror/boost/char_type_switch/iostream.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/char_type_switch/iostream.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,41 @@
+/**
+ * \file boost/char_width_switch/iostream.hpp
+ * Narrow/Wide character type switching for iostreams
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_CHAR_WIDTH_SWITCH_IOSTREAM
+#define BOOST_CHAR_WIDTH_SWITCH_IOSTREAM
+
+#include <boost/char_type_switch/choice.hpp>
+// Needed for ::std cout, cin, cerr, wcin, wcout, wcerr
+#include <iostream>
+
+namespace boost {
+
+#ifdef BOOST_USE_WIDE_CHARS
+ // If wide characters were chosen
+ //
+ // define input stream
+ ::std::wistream& bcin = ::std::wcin;
+ // define output stream
+ ::std::wostream& bcout = ::std::wcout;
+ // define error stream
+ ::std::wostream& bcerr = ::std::wcerr;
+#else // NOT BOOST_USE_WIDE_CHARS
+ // if narrow characters were chosen
+ //
+ // define input stream
+ ::std::istream& bcin = ::std::cin;
+ // define output stream
+ ::std::ostream& bcout = ::std::cout;
+ // define error stream
+ ::std::ostream& bcerr = ::std::cerr;
+#endif // NOT BOOST_USE_WIDE_CHARS
+
+} // namespace boost
+
+#endif //include guard

Added: sandbox/mirror/boost/char_type_switch/string.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/char_type_switch/string.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,42 @@
+/**
+ * \file boost/char_width_switch/string.hpp
+ * Narrow/Wide character type switching for string.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_CHAR_WIDTH_SWITCH_STRING
+#define BOOST_CHAR_WIDTH_SWITCH_STRING
+
+#include <boost/char_type_switch/choice.hpp>
+// Needed for ::std::string / ::std::wstring
+#include <string>
+
+namespace boost {
+
+
+#ifdef BOOST_USE_WIDE_CHARS
+ // If wide characters were chosen
+ //
+ // define character type
+ typedef wchar_t bchar;
+ // define string class type
+ typedef ::std::wstring bstring;
+ // define macro for string literal type selection
+# define BOOST_STR_LIT(STR) L##STR
+#else // NOT BOOST_USE_WIDE_CHARS
+ // if narrow characters were chosen
+ //
+ // define character type
+ typedef char bchar;
+ // define string class type
+ typedef ::std::string bstring;
+ // define macro for string literal type selection
+# define BOOST_STR_LIT(STR) STR
+#endif // NOT BOOST_USE_WIDE_CHARS
+
+} // namespace boost
+
+#endif //include guard

Added: sandbox/mirror/boost/mirror/access_spec.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/access_spec.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,28 @@
+/**
+ * \file boost/mirror/access_spec.hpp
+ * Definition of token types representing member access specifiers
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_ACCESS_SPEC
+#define BOOST_MIRROR_ACCESS_SPEC
+
+namespace boost {
+namespace mirror {
+
+/** Access specifier 'keywords'
+ */
+struct access_specifier { };
+
+struct private_ : access_specifier { };
+struct protected_ : access_specifier { };
+struct public_ : access_specifier { };
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/class_kind_spec.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/class_kind_spec.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,52 @@
+/**
+ * \file boost/mirror/class_kind_spec.hpp
+ * Definition of token types representing class kind specifiers
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_CLASS_KIND_SPEC
+#define BOOST_MIRROR_CLASS_KIND_SPEC
+
+// access specifiers
+#include <boost/mirror/access_spec.hpp>
+
+
+namespace boost {
+namespace mirror {
+
+/** Class 'kind' (class|struct|union) specifier
+ */
+struct class_kind_specifier { };
+
+struct class_ : class_kind_specifier { };
+struct struct_ : class_kind_specifier { };
+struct union_ : class_kind_specifier { };
+
+template <class a_class>
+struct meta_class_kind
+{
+ typedef class_ result;
+};
+
+/** Default inheritance access specifier for the given class kind
+ */
+template <class a_class_kind>
+struct class_kind_default_access
+{
+ typedef public_ specifier;
+};
+
+template <>
+struct class_kind_default_access<class_>
+{
+ typedef private_ specifier;
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/common_defs.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/common_defs.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,23 @@
+/**
+ * \file boost/mirror/common_defs.hpp
+ * Common definitions for the mirror library
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_COMMON_DEFS_HPP
+#define BOOST_MIRROR_COMMON_DEFS_HPP
+
+namespace boost {
+namespace mirror {
+
+#define BOOST_MIRROR_CONST_MEMBER_ATTRIB(TYPE, NAME, VALUE) \
+ enum {NAME = VALUE};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/inherit_spec.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/inherit_spec.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,27 @@
+/**
+ * \file boost/mirror/inherit_spec.hpp
+ * Definition of token types representing inheritance type specifiers
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_INHERIT_SPEC
+#define BOOST_MIRROR_INHERIT_SPEC
+
+namespace boost {
+namespace mirror {
+
+/** Virtual vs. non-virtual inheritance specifier
+ */
+struct inheritance_specifier { };
+struct virtual_base_ : inheritance_specifier { };
+struct nonvirtual_base_ : inheritance_specifier { };
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_attribs_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_attribs_base.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,115 @@
+/**
+ * \file boost/mirror/meta_attribs_simple.hpp
+ * Registering and reflection of simple class attributes
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_ATTRIBS_SIMPLE
+#define BOOST_MIRROR_META_ATTRIBS_SIMPLE
+
+// mirror common definitions
+#include <boost/mirror/common_defs.hpp>
+//
+// necessary type traits
+#include <boost/call_traits.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Defaut (empty) list of base attributes of a meta class
+ */
+template <class the_class>
+struct meta_class_attributes
+{
+ typedef mpl::vector<> type_list;
+};
+
+/** This macro should start the declaration of attributes
+ * of the given class
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(THE_CLASS) \
+ template <> struct meta_class_attributes<THE_CLASS> \
+ { \
+ typedef THE_CLASS the_class; \
+ typedef mpl::vector<>
+
+/** This is a helper for the BOOST_MIRROR_CLASS_ATTRIB*
+ * macros.
+ * It declares all common things that need to be declared
+ * before the specific stuff.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, NAME) \
+ _partial_list_##NUMBER;\
+ static const bchar* base_name(mpl::int_<NUMBER>){return BOOST_STR_LIT(#NAME);}
+
+/** This is a helper for the BOOST_MIRROR_CLASS_ATTRIB*
+ * macros.
+ * It declares all common things that need to be declared
+ * after the specific stuff.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME) \
+ typedef mpl::push_back<_partial_list_##NUMBER, TYPE>::type
+
+/** Helper macro for implementing simple attrib value getting
+ * querying scheme
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME) \
+ static call_traits<TYPE>::param_type get(const the_class& context, mpl::int_<NUMBER>)\
+ {\
+ return context.NAME;\
+ } \
+ static TYPE& query(const the_class& context, mpl::int_<NUMBER>, TYPE& dest)\
+ {\
+ dest = context.NAME;\
+ return dest;\
+ }
+
+/** Helper macro for implementing no-op query meta-class function
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_GETTER(NUMBER, TYPE) \
+ static void get(const the_class& context, mpl::int_<NUMBER>){ }\
+ static void query(const the_class& context, mpl::int_<NUMBER>, TYPE& dest){ }
+
+/** Helper macros
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
+ static call_traits<TYPE>::param_type set(the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val)\
+ {\
+ context.NAME = val;\
+ return val;\
+ } \
+ static void set(const the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val)\
+ {\
+ }
+
+
+/** Helper macro for implementing no-op set meta-class function
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE) \
+ static void set(the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val){ }\
+ static void set(const the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val){ }
+
+
+/** This macro declares the meta-data for a single class' attribute
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, NAME)
+
+/** This macro finishes the declaration of attributes
+ * of the given class
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIBS_END \
+ type_list; \
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_attribs_getset.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_attribs_getset.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,183 @@
+/**
+ * \file boost/mirror/meta_attributes.hpp
+ * Mscros for declaring meta attributes accessed through getters/setters
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_ATTRIBS_GETSET_HPP
+#define BOOST_MIRROR_META_ATTRIBS_GETSET_HPP
+
+// macros for declaration of simple meta attributes
+#include <boost/mirror/meta_attribs_base.hpp>
+//
+// necessary preprocessor macros
+#include <boost/preprocessor/tuple/to_list.hpp>
+#include <boost/preprocessor/list/enum.hpp>
+//
+// various other things from boost to get this going
+#include <boost/function_types/property_tags.hpp>
+#include <boost/function_types/is_member_function_pointer.hpp>
+#include <boost/typeof/typeof.hpp>
+
+
+
+namespace boost {
+namespace mirror {
+
+/** Helper macro for implementing getter based query meta-class function
+ *
+ * TODO: This is a rather unfortunate implementation ...
+ * It would be great is we could get rid of the do_* helpers.
+ * Anyway there should be two overloads of get and two for query
+ * one having 'const the_class&' and the other 'the_class&' as the first param
+ * if the provided getter IS const qualified.
+ * Otherwise, if the getter IS NOT const qualified there should be only one
+ * version of get and one version of query, both having a 'the_class&'
+ * as the first argument.
+ *
+ * Now, both overloads get always compiled, but if the one with const the_class&
+ * gets never used it is (hopefully) culled out of the final binary.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_GETTER_ARGS(NUMBER, TYPE, GETTER_NAME, GETTER_ARGS_TUPLE, ARG_COUNT) \
+ static call_traits<TYPE>::param_type do_get(the_class& context, mpl::int_<NUMBER>, mpl::bool_<true>)\
+ {\
+ return context.GETTER_NAME(BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(ARG_COUNT, GETTER_ARGS_TUPLE)));\
+ } \
+ static call_traits<TYPE>::param_type do_get(const the_class& context, mpl::int_<NUMBER>, mpl::bool_<function_types::is_member_function_pointer<BOOST_TYPEOF(&the_class::GETTER_NAME), function_types::const_qualified>::value>)\
+ {\
+ return const_cast<the_class&>(context).GETTER_NAME(BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(ARG_COUNT, GETTER_ARGS_TUPLE)));\
+ } \
+ static TYPE& do_query(the_class& context, mpl::int_<NUMBER>, TYPE& dest, mpl::bool_<true>)\
+ {\
+ dest = context.GETTER_NAME(BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(ARG_COUNT, GETTER_ARGS_TUPLE)));\
+ return dest;\
+ } \
+ static TYPE& do_query(const the_class& context, mpl::int_<NUMBER>, TYPE& dest, mpl::bool_<function_types::is_member_function_pointer<BOOST_TYPEOF(&the_class::GETTER_NAME), function_types::const_qualified>::value>)\
+ {\
+ dest = const_cast<the_class&>(context).GETTER_NAME(BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(ARG_COUNT, GETTER_ARGS_TUPLE)));\
+ return dest;\
+ } \
+ template <class a_class> static call_traits<TYPE>::param_type get(a_class& context, mpl::int_<NUMBER>)\
+ {\
+ return do_get(context, mpl::int_<NUMBER>(), mpl::bool_<true>());\
+ }\
+ template <class a_class> static TYPE& query(a_class& context, mpl::int_<NUMBER>, TYPE& dest)\
+ {\
+ return do_query(context, mpl::int_<NUMBER>(), dest, mpl::bool_<true>());\
+ }
+
+
+#define BOOST_MIRROR_SETTER_SRC val
+
+/** Helper macro for implementing setter based set meta-class function
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SETTER_ARGS(NUMBER, TYPE, SETTER_NAME, SETTER_ARGS_TUPLE, ARG_COUNT) \
+ static call_traits<TYPE>::param_type set(the_class& context, mpl::int_<NUMBER>, call_traits<TYPE>::param_type val)\
+ {\
+ context.SETTER_NAME(BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(ARG_COUNT, SETTER_ARGS_TUPLE)));\
+ return val;\
+ }
+
+
+/** This macro declares a single class' query-only attribute with a getter
+ * member function.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS_ONLY(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME, GETTER_ARGS_TUPLE, ARG_COUNT) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, ATTRIB_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_GETTER_ARGS(NUMBER, TYPE, GETTER_NAME, GETTER_ARGS_TUPLE, ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_SETTER(NUMBER, TYPE)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, ATTRIB_NAME)
+
+/** Simpler version of the BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS
+ * for getter functions with no bound arguments
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_ONLY(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS_ONLY(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME, (), 0)
+
+/** This macro declares a single class' getter-query-simple-set attribute with a getter
+ * member function and a simple value setting scheme.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME, GETTER_ARGS_TUPLE, ARG_COUNT) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, ATTRIB_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_GETTER_ARGS(NUMBER, TYPE, GETTER_NAME, GETTER_ARGS_TUPLE, ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_SET(NUMBER, TYPE, ATTRIB_NAME)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, ATTRIB_NAME)
+
+/** Simpler version of the BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS
+ * for getter functions with no bound arguments
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_W_ARGS(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME, (), 0)
+
+
+
+/** This macro declares a single class' set-only attribute with a setter
+ * member function.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS_ONLY(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME, SETTER_ARGS_TUPLE, ARG_COUNT) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, ATTRIB_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_NO_GETTER(NUMBER, TYPE)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SETTER_ARGS(NUMBER, TYPE, SETTER_NAME, SETTER_ARGS_TUPLE, ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, ATTRIB_NAME)
+
+/** Simpler version of the BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS
+ * for getter functions with no bound arguments
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_ONLY(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS_ONLY(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME, (BOOST_MIRROR_SETTER_SRC), 1)
+
+
+/** This macro declares a single class' simple-get-setter-set attribute with a setter
+ * member function and simple value getting scheme.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME, SETTER_ARGS_TUPLE, ARG_COUNT) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, ATTRIB_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SIMPLE_GET(NUMBER, TYPE, ATTRIB_NAME)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SETTER_ARGS(NUMBER, TYPE, SETTER_NAME, SETTER_ARGS_TUPLE, ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, ATTRIB_NAME)
+
+/** Simpler version of the BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS
+ * for setter functions with no bound arguments besides the value to be set
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_SETTER_W_ARGS(NUMBER, TYPE, ATTRIB_NAME, SETTER_NAME, (BOOST_MIRROR_SETTER_SRC), 1)
+
+
+/** This macro declares a single class' simple-get-setter-set attribute with a setter
+ * member function and simple value getting scheme.
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_SETTER_W_ARGS(\
+ NUMBER, \
+ TYPE, \
+ ATTRIB_NAME, \
+ GETTER_NAME, \
+ GETTER_ARGS_TUPLE, \
+ GETTER_ARG_COUNT, \
+ SETTER_NAME, \
+ SETTER_ARGS_TUPLE, \
+ SETTER_ARG_COUNT\
+) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_PROLOGUE(NUMBER, TYPE, ATTRIB_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_GETTER_ARGS(NUMBER, TYPE, GETTER_NAME, GETTER_ARGS_TUPLE, GETTER_ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_DECL_SETTER_ARGS(NUMBER, TYPE, SETTER_NAME, SETTER_ARGS_TUPLE, SETTER_ARG_COUNT)\
+ BOOST_MIRROR_REG_CLASS_ATTRIB_EPILOGUE(NUMBER, TYPE, ATTRIB_NAME)
+
+/** Simpler version of the BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_SETTER_W_ARGS
+ * for getter and setter functions with no bound arguments
+ */
+#define BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_SETTER(NUMBER, TYPE, ATTRIB_NAME, GETTER_NAME, SETTER_NAME) \
+ BOOST_MIRROR_REG_CLASS_ATTRIB_GETTER_SETTER_W_ARGS(\
+ NUMBER, TYPE, ATTRIB_NAME, \
+ GETTER_NAME, (), 0, \
+ SETTER_NAME, (BOOST_MIRROR_SETTER_SRC), 1\
+ )
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_attributes.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_attributes.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,26 @@
+/**
+ * \file boost/mirror/meta_attributes.hpp
+ * Registering and reflection of class attributes
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_ATTRIBUTES_HPP
+#define BOOST_MIRROR_META_ATTRIBUTES_HPP
+
+// macros for declaration of simple meta attributes
+#include <boost/mirror/meta_attribs_base.hpp>
+// macros for declaration of meta attributes accessed through getters/setters
+#include <boost/mirror/meta_attribs_getset.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_class.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_class.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,42 @@
+/**
+ * \file boost/mirror/meta_class.hpp
+ * Registering and reflection of classes
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_CLASS_HPP
+#define BOOST_MIRROR_META_CLASS_HPP
+
+// basic meta types
+#include <boost/mirror/meta_type.hpp>
+// reflection of class inheritance
+#include <boost/mirror/meta_inheritance.hpp>
+// reflection of class member attributes
+#include <boost/mirror/meta_attributes.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** Meta class - specializes the meta_type for classes
+ */
+template <class a_class>
+struct meta_class : public meta_type<a_class>
+{
+ typedef typename meta_base_classes<a_class>::list base_classes;
+ typedef typename meta_class_attributes<a_class> attributes;
+};
+
+/** This macro should be included in the definition of every class
+ * with private or protected members, that should be refleccted
+ */
+#define BOOST_MIRROR_FRIENDLY_CLASS(CLASS_NAME) \
+ friend struct ::boost::mirror::meta_class_attributes<CLASS_NAME>;
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_inheritance.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_inheritance.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,145 @@
+/**
+ * \file boost/mirror/meta_inheritance.hpp
+ * Templates used in describing class inheritance
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_INHERITANCE_HPP
+#define BOOST_MIRROR_META_INHERITANCE_HPP
+
+// access specifiers
+#include <boost/mirror/access_spec.hpp>
+// inheritance specifiers
+#include <boost/mirror/inherit_spec.hpp>
+// class 'kind' specifiers
+#include <boost/mirror/class_kind_spec.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+/** helper template instances of which define the inheritance type,
+ * access specifiers and base class of a meta_class
+ */
+template <class a_class, typename access_spec, typename inheritance_spec>
+struct meta_inheritance_defs
+{
+ typedef inheritance_spec inheritance_specifier;
+ typedef access_spec access_specifier;
+ typedef a_class base_class;
+};
+
+/** This template stores the inheritance type and access specifier
+ * of a base class for a derived class
+ */
+template <class a_class, typename access_spec, typename inheritance_spec>
+struct meta_inheritance_spec;
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, private_, virtual_base_>
+: meta_inheritance_defs<a_class, private_, virtual_base_> { };
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, protected_, virtual_base_>
+: meta_inheritance_defs<a_class, protected_, virtual_base_> { };
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, public_, virtual_base_>
+: meta_inheritance_defs<a_class, public_, virtual_base_> { };
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, private_, nonvirtual_base_>
+: meta_inheritance_defs<a_class, private_, nonvirtual_base_> { };
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, protected_, nonvirtual_base_>
+: meta_inheritance_defs<a_class, protected_, nonvirtual_base_> { };
+
+template <class a_class>
+struct meta_inheritance_spec<a_class, public_, nonvirtual_base_>
+: meta_inheritance_defs<a_class, public_, nonvirtual_base_> { };
+
+/** This template stores the inheritance type and access specifier
+ * of a base class for a derived class
+ */
+template <
+ class a_class,
+ typename access_spec = class_kind_default_access<meta_class_kind<a_class>::result>::specifier,
+ typename inheritance_spec = nonvirtual_base_
+>
+struct meta_inheritance : meta_inheritance_spec<a_class, access_spec, inheritance_spec>{ };
+
+/** Default (empty) list of base classes of a meta_class
+ */
+template <class a_class>
+struct meta_base_classes
+{
+ typedef mpl::vector<> list;
+};
+
+
+/** This macro starts the declaration of base classes
+ * of the given class
+ */
+#define BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(A_CLASS) \
+ template <> struct meta_base_classes<A_CLASS> \
+ { \
+ typedef mpl::vector<
+
+/** This macro declares that the A_BASE_CLASS class is the i-th
+ * base class of the given class, with default access specifier
+ * and inheritance type specifier. The numbering starts from
+ * zero, declarations must be ordered by number.
+ */
+#define BOOST_MIRROR_REG_BASE_CLASS_SIMPLE(NUMBER, A_BASE_CLASS) \
+ BOOST_PP_COMMA_IF(NUMBER) meta_inheritance<A_BASE_CLASS>
+
+/** This macro declares that the A_BASE_CLASS class is the i-th
+ * base class of the given class, with the given access specifier
+ * and default inheritance type specifier. The numbering starts from
+ * zero, declarations must be ordered by number.
+ */
+#define BOOST_MIRROR_REG_BASE_CLASS(NUMBER, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_PP_COMMA_IF(NUMBER) meta_inheritance<A_BASE_CLASS, ACCESS_SPEC##_>
+
+/** This macro declares that the A_BASE_CLASS class is the i-th
+ * base class of the given class, with the given access specifier
+ * and virtual inheritance type specifier. The numbering starts from
+ * zero, declarations must be ordered by number.
+ */
+#define BOOST_MIRROR_REG_BASE_CLASS_VIRTUAL(NUMBER, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_PP_COMMA_IF(NUMBER) meta_inheritance<A_BASE_CLASS, ACCESS_SPEC##_, virtual_base_>
+
+/** This macro finishes the declaration of base classes
+ * of the given class
+ */
+#define BOOST_MIRROR_REG_BASE_CLASSES_END \
+ > list; \
+};
+
+/** This macro registers a the A_BASE_CLASS class
+ * as the only base class of the A_CLASS class
+ * with the ACCESS_SPEC access specifier
+ */
+#define BOOST_MIRROR_REG_SINGLE_BASE_CLASS(A_CLASS, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(A_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASS(0, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASSES_END
+
+/** This macro registers a the A_BASE_CLASS class
+ * as the only virtual base class of the A_CLASS class
+ * with the ACCESS_SPEC access specifier
+ */
+#define BOOST_MIRROR_REG_SINGLE_BASE_CLASS_VIRTUAL(A_CLASS, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(A_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASS_VIRTUAL(0, ACCESS_SPEC, A_BASE_CLASS) \
+ BOOST_MIRROR_REG_BASE_CLASSES_END
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_namespace.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_namespace.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,96 @@
+/**
+ * \file boost/mirror/meta_namespace.hpp
+ * Registering and reflection of namespaces
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_NAMESPACE
+#define BOOST_MIRROR_META_NAMESPACE
+
+// true type/false type for trait templates
+#include <boost/type_traits/integral_constant.hpp>
+// for various typelists
+#include <boost/mpl/vector.hpp>
+// for "compile time strings"
+#include <boost/mpl/vector_c.hpp>
+// common mpl algoritgms
+#include <boost/mpl/push_back.hpp>
+//
+// for bulk declarations
+#include <boost/preprocessor.hpp>
+
+// mirror uses switchable character type
+#include <boost/char_type_switch/string.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** meta-namespace template definition
+ */
+template<class parent_meta_ns, class namespace_name>
+struct meta_namespace;
+
+/** meta-namespace for the global scope
+ */
+template<> struct meta_namespace<void, mpl::vector_c<char> >
+{
+ typedef void parent;
+ typedef mpl::vector0<> scope;
+ static const bchar* base_name (void) {return BOOST_STR_LIT("");}
+};
+/** defines an alias (_) for the meta-namespace for the global scope
+ */
+namespace namespaces {
+typedef meta_namespace<void, mpl::vector_c<char> > _;
+}
+
+/** Is-global-scope trait template for namespaces
+ */
+template <class meta_namespace>
+struct is_global_scope : public false_type{ };
+
+/** Is-global-scope trait specialization for global scope meta_namespace
+ */
+template <>
+struct is_global_scope<namespaces::_> : public true_type{ };
+
+
+/** Helper macro for registering new general namespaces (top level or nested)
+ */
+#define BOOST_MIRROR_REG_META_NAMESPACE_HELPER(PARENT_META_NS, PREFIX, NAMESPACE, SPELLED_NAME) \
+template<> struct meta_namespace<PARENT_META_NS, mpl::vector_c<char, SPELLED_NAME> > \
+{ \
+ typedef PARENT_META_NS parent; \
+ typedef mpl::push_back<typedef PARENT_META_NS::scope, PARENT_META_NS>::type scope; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#NAMESPACE);} \
+}; \
+namespace namespaces { \
+ typedef meta_namespace<PARENT_META_NS, mpl::vector_c<char, SPELLED_NAME> > PREFIX##_##NAMESPACE; \
+}
+
+/** Macro for registering new general namespaces (top level or nested)
+ */
+#define BOOST_MIRROR_REG_META_NAMESPACE(PARENT_META_NS_ALIAS, NAMESPACE, SPELLED_NAME) \
+ BOOST_MIRROR_REG_META_NAMESPACE_HELPER(namespaces::PARENT_META_NS_ALIAS, PARENT_META_NS_ALIAS, NAMESPACE, SPELLED_NAME)
+
+
+/** Macro for registering of top-level namespaces
+ */
+#define BOOST_MIRROR_REG_META_NAMESPACE_TOP_LEVEL(NAMESPACE, SPELLED_NAME) \
+ BOOST_MIRROR_REG_META_NAMESPACE_HELPER(namespaces::_, BOOST_PP_EMPTY(), NAMESPACE, SPELLED_NAME)
+
+// Registration of the ::std namespace
+BOOST_MIRROR_REG_META_NAMESPACE_TOP_LEVEL(std, BOOST_PP_TUPLE_REM_CTOR(3,('s','t','d')));
+// Registration of the ::boost namespace
+BOOST_MIRROR_REG_META_NAMESPACE_TOP_LEVEL(boost, BOOST_PP_TUPLE_REM_CTOR(5,('b','o','o','s','t')));
+// Registration of the ::boost::mirror namespace
+BOOST_MIRROR_REG_META_NAMESPACE(_boost, mirror, BOOST_PP_TUPLE_REM_CTOR(6,('m','i','r','r','o','r')));
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_type.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,141 @@
+/**
+ * \file boost/mirror/meta_type.hpp
+ * Registering and reflection of types
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_META_TYPE_HPP
+#define BOOST_MIRROR_META_TYPE_HPP
+
+// true type/false type for trait templates
+#include <boost/type_traits/integral_constant.hpp>
+// meta namespaces (includes boost/char_type_switch/string.hpp)
+#include <boost/mirror/meta_namespace.hpp>
+// for declarations of meta-types for groups of types
+#include <boost/preprocessor.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** meta-type template definition
+ */
+template <class base_type>
+struct meta_type;
+
+
+/** Macro for declaration of meta-types
+ */
+#define BOOST_MIRROR_REG_META_TYPE(META_NAMESPACE_ALIAS, NAMESPACE, BASE_NAME) \
+ template <> struct meta_type< NAMESPACE::BASE_NAME > \
+ { \
+ typedef namespaces::META_NAMESPACE_ALIAS scope; \
+ typedef NAMESPACE::BASE_NAME base_type; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_NAME);}\
+ };
+
+/** Declaration of meta types for types in the global scope
+ */
+#define BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_TYPE) \
+ template <> struct meta_type< BASE_TYPE > \
+ { \
+ typedef namespaces::_ scope; \
+ typedef BASE_TYPE base_type; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_TYPE);}\
+ };
+
+/** Declaration of meta types for types in declared inside
+ * of a class.
+ */
+#define BOOST_MIRROR_REG_META_TYPE_EMBEDDED(WRAPPER, BASE_TYPE) \
+ template <> struct meta_type< WRAPPER::BASE_TYPE > \
+ { \
+ typedef meta_type< WRAPPER > scope; \
+ typedef WRAPPER::BASE_TYPE base_type; \
+ static const bchar* base_name (void) {return BOOST_STR_LIT(#BASE_TYPE);}\
+ };
+
+
+/** Helper macro used for batch registering of the meta-types for
+ * the C++ native types
+ */
+#define BOOST_MIRROR_REG_ITH_META_TYPE_NATIVE(I, _, BASE_TYPE)\
+ BOOST_MIRROR_REG_META_TYPE_GLOBAL_SCOPE(BASE_TYPE)
+
+#define BOOST_MIRROR_NATIVE_TYPES \
+ BOOST_PP_TUPLE_TO_LIST( \
+ 14, \
+ ( \
+ bool, \
+ char, signed char, unsigned char, wchar_t, \
+ unsigned short, short, \
+ int, unsigned, \
+ long, unsigned long, \
+ float, \
+ double, long double \
+ ) \
+ )
+
+/** Declare the meta types for the native C++ types
+ */
+BOOST_PP_LIST_FOR_EACH(BOOST_MIRROR_REG_ITH_META_TYPE_NATIVE, _, BOOST_MIRROR_NATIVE_TYPES)
+
+/** We're done with registering of the meta types for native
+ * types now so we don't need this anymore
+ */
+#undef BOOST_MIRROR_REG_ITH_META_TYPE_NATIVE
+
+
+/** Meta-types for pointers
+ */
+template <class pointee_type>
+struct meta_type<pointee_type*>
+{
+ typedef typename meta_type<pointee_type>::scope scope;
+ typedef pointee_type* base_type;
+};
+
+/** Meta-types for references
+ */
+template <class refered_to_type>
+struct meta_type<refered_to_type&>
+{
+ typedef typename meta_type<refered_to_type>::scope scope;
+ typedef refered_to_type& base_type;
+};
+
+/** Meta-types for const types
+ */
+template <class non_const_type>
+struct meta_type<const non_const_type>
+{
+ typedef typename meta_type<non_const_type>::scope scope;
+ typedef const non_const_type base_type;
+};
+
+/** Meta-types for volatile types
+ */
+template <class non_volatile_type>
+struct meta_type<volatile non_volatile_type>
+{
+ typedef typename meta_type<non_volatile_type>::scope scope;
+ typedef volatile non_volatile_type base_type;
+};
+
+/** Meta-types for const volatile types
+ */
+template <class non_cv_type>
+struct meta_type<const volatile non_cv_type>
+{
+ typedef typename meta_type<non_cv_type>::scope scope;
+ typedef const volatile non_cv_type base_type;
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/utils/name_to_stream.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/utils/name_to_stream.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,179 @@
+/**
+ * \file boost/mirror/utils/name_to_stream.hpp
+ * Putting names of reflected nammespaces, classes, etc. to streams
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_UTILS_NAME_TO_STREAM
+#define BOOST_MIRROR_UTILS_NAME_TO_STREAM
+
+// meta namespaces (includes boost/char_type_switch/string.hpp)
+#include <boost/mirror/meta_namespace.hpp>
+// meta types
+#include <boost/mirror/meta_type.hpp>
+
+namespace boost {
+namespace mirror {
+
+/** name_to_stream_helper function object
+ */
+template <class meta_object>
+struct name_to_stream_helper;
+
+/** Specialization for the global scope meta-namespace
+ */
+template <class namespace_name>
+struct name_to_stream_helper<meta_namespace<void, namespace_name> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ return ldng_dbl_cln? s << BOOST_STR_LIT("::") : s;
+ }
+};
+
+/** Specialization for the top level namespaces
+ */
+template <class namespace_name>
+struct name_to_stream_helper<meta_namespace<namespaces::_, namespace_name> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ return (ldng_dbl_cln? s << BOOST_STR_LIT("::") : s) <<
+ meta_namespace<namespaces::_, namespace_name>::base_name();
+ }
+};
+
+/** Specialization of meta_namespace for nested namespaces
+ */
+template <class parent_meta_ns, class namespace_name>
+struct name_to_stream_helper<meta_namespace<parent_meta_ns, namespace_name> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ return name_to_stream<parent_meta_ns>::put(s, ldng_dbl_cln) <<
+ BOOST_STR_LIT("::") <<
+ meta_namespace<parent_meta_ns, namespace_name>::base_name();
+ }
+};
+
+/** Specialization for meta-types
+ */
+template <typename base_type>
+struct name_to_stream_helper<meta_type<base_type> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ if(!is_global_scope<typename meta_type<base_type>::scope>::value)
+ name_to_stream<meta_type<base_type>::scope>::put(s, ldng_dbl_cln) << BOOST_STR_LIT("::");
+ else if(ldng_dbl_cln) s << BOOST_STR_LIT("::");
+ return s << meta_type<base_type>::base_name();
+ }
+};
+
+/** Specialization for meta-types for pointers
+ */
+template <typename pointee_type>
+struct name_to_stream_helper<meta_type<pointee_type*> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ return name_to_stream_helper<meta_type<pointee_type> >::put(s,ldng_dbl_cln) << BOOST_STR_LIT("*");
+ }
+};
+
+/** Specialization for meta-types for references
+ */
+template <typename refered_to_type>
+struct name_to_stream_helper<meta_type<refered_to_type&> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ return name_to_stream_helper<meta_type<refered_to_type> >::put(s,ldng_dbl_cln) << BOOST_STR_LIT("&");
+ }
+};
+
+/** Specialization for meta-types for const types
+ */
+template <typename non_const_type>
+struct name_to_stream_helper<meta_type<const non_const_type> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ s << BOOST_STR_LIT("const ");
+ return name_to_stream_helper<meta_type<non_const_type> >::put(s,ldng_dbl_cln);
+ }
+};
+
+/** Specialization for meta-types for volatile types
+ */
+template <typename non_volatile_type>
+struct name_to_stream_helper<meta_type<volatile non_volatile_type> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ s << BOOST_STR_LIT("volatile ");
+ return name_to_stream_helper<meta_type<non_volatile_type> >::put(s,ldng_dbl_cln);
+ }
+};
+
+/** Specialization for meta-types for volatile types
+ */
+template <typename non_cv_type>
+struct name_to_stream_helper<meta_type<const volatile non_cv_type> >
+{
+ template <class out_stream>
+ static out_stream& put(out_stream& s, bool ldng_dbl_cln = false)
+ {
+ s << BOOST_STR_LIT("const volatile ");
+ return name_to_stream_helper<meta_type<non_cv_type> >::put(s,ldng_dbl_cln);
+ }
+};
+
+
+/** Specialization for meta-classes
+ */
+template <typename base_type>
+struct name_to_stream_helper<meta_class<base_type> > :
+public name_to_stream_helper<meta_type<base_type> > { };
+
+/** name_to_stream function object
+ * Puts the whole name of the meta object into the given stream.
+ * There are three ways how to use this function object
+ * 1) invocation of static member function put(...)
+ * name_to_stream<meta_object>::put(stream);
+ * 2) construction with a stream as argument
+ * name_to_stream<meta_object> nts(stream);
+ * 3) construction and calling of the function call operator
+ * name_to_stream<meta_object>()(stream); or
+ * name_to_stream<meta_object> nts; nts();
+ */
+template <typename meta_object>
+struct name_to_stream : public name_to_stream_helper<meta_object>
+{
+ // default constructor
+ name_to_stream(void){ }
+ // this constructor invokes the put operation on the given stream
+ template <class out_stream>
+ name_to_stream(out_stream& s, bool ldng_dbl_cln = false){put(s, ldng_dbl_cln);}
+ // function call operator
+ template <class out_stream>
+ out_stream& operator()(out_stream& s, bool ldng_dbl_cln = false){return put(s, ldng_dbl_cln);}
+};
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/visitors/fallback.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/visitors/fallback.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,32 @@
+/**
+ * \file boost/mirror/visitors/fallback.hpp
+ * Base implementation of a meta-object visitor
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_VISITORS_FALLBACK
+#define BOOST_MIRROR_VISITORS_FALLBACK
+
+// meta namespaces (includes boost/char_type_switch/string.hpp)
+#include <boost/mirror/meta_namespace.hpp>
+// meta types
+#include <boost/mirror/meta_type.hpp>
+
+namespace boost {
+namespace mirror {
+
+struct fallback_visitor
+{
+ // visitation of the
+ template <typename base_type, typename meta_type>
+ void visit_instance(const meta_type& meta_data, base_type& instance, const bchar* name){ }
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/visitors/sample.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/visitors/sample.hpp 2008-04-15 04:58:40 EDT (Tue, 15 Apr 2008)
@@ -0,0 +1,28 @@
+/**
+ * \file boost/mirror/visitors/sample.hpp
+ * Sample implementation of a meta-object visitor
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#ifndef BOOST_MIRROR_VISITORS_SAMPLE
+#define BOOST_MIRROR_VISITORS_SAMPLE
+
+// meta namespaces (includes boost/char_type_switch/string.hpp)
+#include <boost/mirror/meta_namespace.hpp>
+// meta types
+#include <boost/mirror/meta_type.hpp>
+// the base fallback visitor implementation
+#include <boost/mirror/visitors/fallback.hpp>
+
+namespace boost {
+namespace mirror {
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+


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