Created
August 8, 2017 01:27
-
-
Save veryjos/167d580f4b069a3fdc67c867b7cfc5b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include "MetaPlug/generated/MetaPlug.hpp" | |
#include "main.hpp" | |
int main(int argc, char** argv) { | |
auto metaclass = CppMetaGen::GetMetaClassByName("TestClass"); | |
auto obj = new TestClass(); | |
obj->someField = 23; | |
printf("Class Name:\n - %s\n", metaclass->GetName()); | |
printf("\nFields:\n"); | |
auto fields = metaclass->GetFields(); | |
for (auto field : fields) { | |
auto f = field->GetVariant(); | |
printf(" - %s : %d\n", field->GetName(), *f->GetValue<int>(obj)); | |
} | |
printf("\nMeta Tags:\n"); | |
auto tags = metaclass->GetMetaTags(); | |
for (auto tag : tags) { | |
printf(" - %s\n", tag->GetName()); | |
{ | |
auto annotation = tag->GetVariant()->GetValue<TestAnnotation>(); | |
if (annotation) printf(" - %d\n", annotation->number); | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Meta.hpp" | |
DefineMetaTag() | |
struct TestAnnotation { | |
TestAnnotation(int number) : | |
number(number) {}; | |
int number; | |
}; | |
Meta(TestAnnotation(13)) | |
class TestClass { | |
public: | |
TestClass() {}; | |
~TestClass() {}; | |
int someField; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Name: | |
- TestClass | |
Fields: | |
- someField : 23 | |
Meta Tags: | |
- TestAnnotation | |
- 13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment