Mirror reflection library 0.5.13
|
Simple yet not very useful hello world example. Shows the basics of namespace and type registration and reflection
Copyright 2008-2011 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)
#include <mirror/meta_namespace.hpp> #include <mirror/meta_type.hpp> #include <iostream> namespace Hello { struct World { }; } // namespace Hello MIRROR_REG_BEGIN // Register the Hello namespace MIRROR_QREG_GLOBAL_SCOPE_NAMESPACE(Hello) // Register the ::Hello::World type MIRROR_REG_TYPE(Hello, World) MIRROR_REG_END int main(void) { using namespace mirror; // reflect the Hello::World type and print its full name std::cout << MIRRORED_TYPE(Hello::World)::full_name() << std::endl; // // get the scope of the Hello::World class (the Hello namespace) // and print its base name and then print the base name // of the Hello::World class std::cout << mirror::reflected<Hello::World>::type::scope::base_name() << ", " << mirror::reflected_type<Hello::World>::base_name() << "." << std::endl; // return 0; } /* Example of output: Hello::World Hello, World. */