Mirror reflection library 0.5.13
|
Defines | |
#define | MIRROR_TYPEDEF(NAMESPACE, TYPEDEF) |
Returns a special type representing a nested typedef to Mirror. | |
#define | MIRROR_GLOBAL_SCOPE_TYPEDEF(TYPEDEF) |
Returns a special type representing a typedef from the global scope. | |
#define | MIRROR_USING_NESTED_NAMESPACE(ID, NAMESPACE) |
Macro which tells Mirror to remove this nested namespace's name from local names. | |
#define | MIRROR_USING_NAMESPACE(NAMESPACE) MIRROR_USING_NESTED_NAMESPACE(NAMESPACE, NAMESPACE) |
Macro which tells Mirror to remove this namespace's name from local names. | |
#define | MIRROR_USING_NAMESPACE_(NAMESPACE) MIRROR_USING_NESTED_NAMESPACE(_, NAMESPACE) |
Macro which tells Mirror to remove this namespace's name from local names. |
Other macros
#define MIRROR_GLOBAL_SCOPE_TYPEDEF | ( | TYPEDEF | ) |
Returns a special type representing a typedef from the global scope.
This macro expands into a special type that represents a typedef registered with Mirror. This special type can be used for example in registering class member variables having typedefined types.
TYPEDEF | the base typedef-ined name |
#define MIRROR_TYPEDEF | ( | NAMESPACE, | |
TYPEDEF | |||
) |
Returns a special type representing a nested typedef to Mirror.
This macro expands into a special type that represents a typedef registered with Mirror. This special type can be used for example in registering class member variables having typedefined types.
NAMESPACE | the full namespace name NOT containing the leading double colon |
TYPEDEF | the base typedef-ined name |
#include <mirror/mirror.hpp> #include <mirror/using_directive.hpp> #include <iostream> namespace test { // use typedef to define some types typedef double kilogram; typedef size_t centimeter; typedef size_t year; // a test class using typedefs for member variable types struct person { std::string first_name; std::string middle_name; std::string family_name; kilogram weight; centimeter height; year age; }; } // namespace test MIRROR_REG_BEGIN // register the test namespace MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE(test) // register the typedefs with Mirror MIRROR_REG_TYPEDEF(test, kilogram) MIRROR_REG_TYPEDEF(test, centimeter) MIRROR_REG_TYPEDEF(test, year) // get the typedefs typedef MIRROR_TYPEDEF(test, kilogram) _typedef_kilogram; typedef MIRROR_TYPEDEF(test, centimeter) _typedef_centimeter; typedef MIRROR_TYPEDEF(test, year) _typedef_year; // register the person class MIRROR_REG_CLASS_BEGIN(struct, test, person) MIRROR_REG_CLASS_MEM_VARS_BEGIN MIRROR_REG_CLASS_MEM_VAR( _, _, _, first_name) MIRROR_REG_CLASS_MEM_VAR( _, _, _, middle_name) MIRROR_REG_CLASS_MEM_VAR( _, _, _, family_name) MIRROR_REG_CLASS_MEM_VAR( _, _, _typedef_kilogram, weight) MIRROR_REG_CLASS_MEM_VAR( _, _, _typedef_centimeter, height) MIRROR_REG_CLASS_MEM_VAR( _, _, _typedef_year, age) MIRROR_REG_CLASS_MEM_VARS_END MIRROR_REG_CLASS_END MIRROR_REG_END struct info_printer { template <class IterInfo> void operator()(IterInfo) { using namespace mirror; if(IterInfo::is_first::value) std::cout << "(" << std::endl; std::cout << "\t" << IterInfo::type::type::local_name() << " " << IterInfo::type::base_name(); if(IterInfo::is_last::value) std::cout << std::endl << ")" << std::endl; else std::cout << ", " << std::endl; } }; template <class Class> void print_info(void) { using namespace mirror; typedef MIRRORED_CLASS(Class) meta_X; std::cout << "Members of " << meta_X::local_name() << ": "; mp::for_each_ii< all_member_variables<meta_X> >(info_printer()); } int main(void) { using namespace mirror; // // print with the full names print_info<test::person>(); // // print with the test:: name specifier stripped { MIRROR_USING_NAMESPACE(test); print_info<test::person>(); } // // print with the test:: and the std:: // name specifiers stripped { MIRROR_USING_NAMESPACE(test); MIRROR_USING_NAMESPACE(std); print_info<test::person>(); } // return 0; } /* Example of output: | Members of test::person: ( | std::string first_name, | std::string middle_name, | std::string family_name, | test::kilogram weight, | test::centimeter height, | test::year age | ) | Members of person: ( | std::string first_name, | std::string middle_name, | std::string family_name, | kilogram weight, | centimeter height, | year age | ) | Members of person: ( | std::string first_name, | std::string middle_name, | std::string family_name, | kilogram weight, | centimeter height, | year age | ) */
#define MIRROR_USING_NAMESPACE | ( | NAMESPACE | ) | MIRROR_USING_NESTED_NAMESPACE(NAMESPACE, NAMESPACE) |
Macro which tells Mirror to remove this namespace's name from local names.
This macro acts in a similar way as the 'using namespace' directive and causes the local_name member function of MetaNamedScopedObject(s) to remove the namespace name from the full names of members of this namespace. It can be used only with top-level namespaces. For nested namespaces see the MIRROR_USING_NESTED_NAMESPACE() or the MIRROR_USING_NAMESPACE_() macro.
NAMESPACE | the name of the namespace to be used. If it is a nested namespace (i.e. its name contains ::) then the MIRROR_USING_NESTED_NAMESPACE() macro must be used instead. |
#define MIRROR_USING_NAMESPACE_ | ( | NAMESPACE | ) | MIRROR_USING_NESTED_NAMESPACE(_, NAMESPACE) |
Macro which tells Mirror to remove this namespace's name from local names.
This macro acts in a similar way as the 'using namespace' directive and causes the local_name member function of MetaNamedScopedObject(s) to remove the namespace name from the full names of members of this namespace. Unlike MIRROR_USING_NAMESPACE(), this macro can be also used for nested namespaces, but only one namespace can be 'used' on a particular scope.
NAMESPACE | the name of the namespace to be used. |
#define MIRROR_USING_NESTED_NAMESPACE | ( | ID, | |
NAMESPACE | |||
) |
const mirror::aux::_using< \ MIRRORED_NAMESPACE(NAMESPACE) \ > _boost_mirror_using_ ## ID(__COUNTER__)
Macro which tells Mirror to remove this nested namespace's name from local names.
This macro acts in a similar way as the 'using namespace' directive and causes the local_name member function of MetaNamedScopedObject(s) to remove the namespace name from the full names of members of this namespace. This version of the macro must be used for nested namespaces (i.e. namespaces whose name contains ::).
ID | an identifier for the using directive, which distinguishes it from other using directives on the same scope. Generally the same rules as for the identifier names apply, except that it can start with a digit. |
NAMESPACE | the name of the namespace to be used |