# reflectionpp **Repository Path**: cpp_log/reflectionpp ## Basic Information - **Project Name**: reflectionpp - **Description**: A header-only C++11 reflection library - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-05-07 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Reflection++ === Yet another (?) header-only C++11 reflection library. Usage --- Add meta information to an object: struct TestStruct { int member1; float member2; }; RPP_TYPE_OBJECT( __(member1) __(member2), TestStruct ) Add meta information to an STL container: template RPP_TYPE_DYNAMIC_GENERIC(T, std::vector) Create a visitor: struct Visitor: public VisitorBase<> { void visit(int &value) { std::cerr << "int(" << value << ") "; } void visit(float &value) { std::cerr << "float(" << value << ") "; } template void operator()(AccessorSimple &accessor) { visit(accessor()); } template void operator()(AccessorObject &accessor) { std::cerr << "object( "; for (rpp_size_t i = 0; i < accessor.size(); ++i) { accessor.doMemberVisit(*this, i); } std::cerr << ") "; } }; Register the visitor and list all visitors: RPP_VISITOR_REG(Visitor) RPP_VISITOR_COLLECT(VisitorAll) Add meta information to a variable: TestStruct s{2, 3.5}; RPP_META_REF(s, VisitorAll) m; Visit the variable: Visitor v; m.doVisit(v); Build --- Compile it like this: clang++ -std=c++11 your_code.cpp If you want to use the BSON visitor, [bson-cxx](https://github.com/mongodb/mongo-cxx-driver) is required. License --- LGPL v3 applies by default.