Mirror reflection library 0.5.13

mirror/example/hello_world.cpp

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.
*/

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.