Reflection in C++ for Introspection on Stackoverflow – Is Your Project Mature

A few questions and answers on Stackoverflow are insightful about this reflection and introspection topic:

In “Attribute & Reflection libraries for C++” it states: Most mature C++ projects seem to have an own reflection and attribute system, i.e for defining attributes which can be accessed by string and are automatically serializable. At least many C++ projects I participated in seemed to reinvent the wheel.

And in “Reflection in C++“, many answers generally explained various ways of doing reflection in C++ for various purpose. Reading the solutions is no more inspiring than reading the purposes of these solutions to try to solve.

It looks, after downloading and trying various tools, the Xrtti is the promising open source solution. I meant, that is the easiest to implement: With your favourite Linux distribution, you just install gccxml package, then download Xrtti and compile. That’s all you’ll need to do to make it work! I will write another post to cover the details of that.

And I deduce, to test if your C++ project is mature enough, one rule is to see if you have some kind of reflection in it. Not limited to C++, this rule might also be true for your C projects. Isn’t it?

Advertisements

About minghuasweblog

a long time coder
This entry was posted in All, C/C++, Methods and tagged , , . Bookmark the permalink.

4 Responses to Reflection in C++ for Introspection on Stackoverflow – Is Your Project Mature

  1. Pingback: Technical Topics | minghuasweblog

  2. A few more inspiring links on stackoverflow:

    http://stackoverflow.com/questions/4167030/get-list-of-available-data-member-from-a-pod-struct-in-c, it points to clang.llvm.org, and boost_fusion_adapt_struct. Though the latter is not very easy.
    And http://stackoverflow.com/questions/41453/how-can-i-add-reflection-to-a-c-application, there are camp, also boost_fusion_adapt_struct, etc.

    An answer here, http://stackoverflow.com/questions/2758937/printing-values-of-all-fields-in-c-structure, gives some hint of how you can use fusion.adapt and fusion.map, fusion.vector. Interesting. The answer is here http://stackoverflow.com/questions/1878285/iterate-over-struct-easily-display-struct-fields-and-values-in-a-richedit-box

  3. Pingback: Boost Fusion Example | minghuasweblog

  4. Pingback: Boost Fusion Adapt.Struct Part 2 – A Complete Example | minghuasweblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s