Skip to content

Instantly share code, notes, and snippets.

@veryjos
Created August 8, 2017 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veryjos/167d580f4b069a3fdc67c867b7cfc5b3 to your computer and use it in GitHub Desktop.
Save veryjos/167d580f4b069a3fdc67c867b7cfc5b3 to your computer and use it in GitHub Desktop.
#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;
}
#include "Meta.hpp"
DefineMetaTag()
struct TestAnnotation {
TestAnnotation(int number) :
number(number) {};
int number;
};
Meta(TestAnnotation(13))
class TestClass {
public:
TestClass() {};
~TestClass() {};
int someField;
};
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