I have an unmanaged C++ application (unmanaged meaning: not using anything of the the fancy .Net stuff). I want to extend it with some meta information, and it looks like I could use the concept of attributes.
What I actually try to achieve is the following. Starting from something a simple class like this:
class Book
{
public:
...
private:
string m_name;
string m_author;
int m_year;
};
I want to build functionality that can access the 'meta information' of the class and use it to dynamically build logic on it, e.g.
- a dialog containing 3 edit fields (name, author, year)
- a data grid with 3 columns
- serialization logic
- logic that maps this class to a database table with 3 columns
- ...
I my wildest dreams I imagine modifying this class like this:
[id="Book"]
class Book
{
public:
...
private:
[id="Name", defaultValue="", maximumLength=100]
string m_name;
[id="Author", defaultValue="", maximumLength=100]
string m_author;
[id="Year", defaultValue=2000, minimum=1900]
int m_year;
};
And then being able to get this 'meta' information to build up dialogs, filling data grids, serializing and deserializing instances, ...
But, is the concept of attributes limited to .Net/managed code?
And if I could use attributes in unmanaged code, would it be possible to do something like this? And what is a good place to start? (examples, ...)
Also, can the same (or similar) concepts be found in other compilers, on other platforms?
I am using Visual Studio 2010 and, as said before, unmanaged/native C++.