{"id":5361,"date":"2014-03-30T21:06:27","date_gmt":"2014-03-30T21:06:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/is-it-possible-to-use-attributes-in-unmanaged-code-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:06:27","modified_gmt":"2014-03-30T21:06:27","slug":"is-it-possible-to-use-attributes-in-unmanaged-code-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/is-it-possible-to-use-attributes-in-unmanaged-code-collection-of-common-programming-errors\/","title":{"rendered":"Is it possible to use attributes in unmanaged code?-Collection of common programming errors"},"content":{"rendered":"<p>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.<\/p>\n<p>What I actually try to achieve is the following. Starting from something a simple class like this:<\/p>\n<pre><code>class Book\n   {\n   public:\n      ...\n   private:\n      string m_name;\n      string m_author;\n      int    m_year;\n   };\n<\/code><\/pre>\n<p>I want to build functionality that can access the &#8216;meta information&#8217; of the class and use it to dynamically build logic on it, e.g.<\/p>\n<ul>\n<li>a dialog containing 3 edit fields (name, author, year)<\/li>\n<li>a data grid with 3 columns<\/li>\n<li>serialization logic<\/li>\n<li>logic that maps this class to a database table with 3 columns<\/li>\n<li>&#8230;<\/li>\n<\/ul>\n<p>I my wildest dreams I imagine modifying this class like this:<\/p>\n<pre><code>[id=\"Book\"]\nclass Book\n   {\n   public:\n      ...\n   private:\n      [id=\"Name\", defaultValue=\"\", maximumLength=100]\n      string m_name;\n\n      [id=\"Author\", defaultValue=\"\", maximumLength=100]\n      string m_author;\n\n      [id=\"Year\", defaultValue=2000, minimum=1900]\n      int    m_year;\n   };\n<\/code><\/pre>\n<p>And then being able to get this &#8216;meta&#8217; information to build up dialogs, filling data grids, serializing and deserializing instances, &#8230;<\/p>\n<p>But, is the concept of attributes limited to .Net\/managed code?<\/p>\n<p>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, &#8230;)<\/p>\n<p>Also, can the same (or similar) concepts be found in other compilers, on other platforms?<\/p>\n<p>I am using Visual Studio 2010 and, as said before, unmanaged\/native C++.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5361","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5361"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5361\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}