All Projects → mlomb → MetaCPP

mlomb / MetaCPP

Licence: Apache-2.0 license
C++ Reflection & Serialization using Clang's LibTooling

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to MetaCPP

meta-extractor
Super simple and fast html page meta data extractor with low memory footprint
Stars: ✭ 38 (-13.64%)
Mutual labels:  metadata, meta
oge
Page metadata as a service
Stars: ✭ 22 (-50%)
Mutual labels:  metadata, meta
QSerializer
This repo for Qt/C++ serialization objects in JSON or XML based on QtCore
Stars: ✭ 33 (-25%)
Mutual labels:  serialization, meta
reflective-rapidjson
Code generator for serializing/deserializing C++ objects to/from JSON using Clang and RapidJSON
Stars: ✭ 26 (-40.91%)
Mutual labels:  serialization, clang
Seo Manager
Seo Manager Package for Laravel ( with Localization )
Stars: ✭ 192 (+336.36%)
Mutual labels:  metadata, meta
audio-tag-analyzer
Extracts metadata music metadata found in audio files
Stars: ✭ 18 (-59.09%)
Mutual labels:  metadata, meta
Cxxctp
DEPRECATED. USE INSTEAD github.com/blockspacer/flextool
Stars: ✭ 58 (+31.82%)
Mutual labels:  serialization, clang
Awesome-meta-tags
📙 Awesome collection of meta tags
Stars: ✭ 18 (-59.09%)
Mutual labels:  metadata, meta
Metaforge
An OSINT Metadata analyzing tool that filters through tags and creates reports
Stars: ✭ 63 (+43.18%)
Mutual labels:  metadata, meta
Vue Meta
Manage HTML metadata in Vue.js components with SSR support
Stars: ✭ 3,807 (+8552.27%)
Mutual labels:  metadata, meta
where-is-resolver
Попытка ответить на вопрос о резольверах, проверяющих домены из списка РКН
Stars: ✭ 49 (+11.36%)
Mutual labels:  metadata, meta
flextool
C++ compile-time programming (serialization, reflection, code modification, enum to string, better enum, enum to json, extend or parse language, etc.)
Stars: ✭ 32 (-27.27%)
Mutual labels:  serialization, clang
kafka-protobuf-serde
Serializer/Deserializer for Kafka to serialize/deserialize Protocol Buffers messages
Stars: ✭ 52 (+18.18%)
Mutual labels:  serialization
baltar
Example graphics editor using MobX
Stars: ✭ 42 (-4.55%)
Mutual labels:  serialization
rollup-plugin-sizes
Rollup plugin to display bundle contents & size information
Stars: ✭ 77 (+75%)
Mutual labels:  metadata
Bois
Salar.Bois is a compact, fast and powerful binary serializer for .NET Framework. With Bois you can serialize your existing objects with almost no change.
Stars: ✭ 53 (+20.45%)
Mutual labels:  serialization
drf-action-serializer
A serializer for the Django Rest Framework that supports per-action serialization of fields.
Stars: ✭ 48 (+9.09%)
Mutual labels:  serialization
doku
fn(Code) -> Docs
Stars: ✭ 65 (+47.73%)
Mutual labels:  serialization
c-compiler-security
Security-related flags and options for C compilers
Stars: ✭ 125 (+184.09%)
Mutual labels:  clang
geoflow
R engine to orchestrate and run (meta)data workflows
Stars: ✭ 28 (-36.36%)
Mutual labels:  metadata

MetaCPP - Reflection & Serialization

The objective is to generate reflection information and enable serialization/deserialization with the least or -zero- manual code possible.

Note that this project is not production ready, there are many bugs and lacks proper testing.

Example

You can find the definition of the following objects in Example/objects.hpp.

// load the auto-generated metadata
metacpp::Storage* storage = metacpp::Runtime::GetStorage();
metacpp::generated::Load(storage);

Player* player = new Player();
player->health = 255;
player->position = { 5, 5 };
player->velocity = { 1, 1 };
player->name = "mlomb";

Monster* monster = new Monster();
monster->health = 255;
monster->position = { 10, 10 };
monster->velocity = { -1, -1 };
monster->scary_factor = 42.123;

Map map;
map.entities = { player, monster };

map.magic_numbers = { 4, 2 };

map.map = {
        { 1, 2, 3 },
        { 4, 5, 6 },
        { 7, 8, 9 },
};

metacpp::JsonSerializer serializer = metacpp::JsonSerializer(storage);

// serialize
std::string json = serializer.Serialize(&map, true /* pretty print */);

std::cout << json << std::endl;

// deserialize
Map* deserialized_map = serializer.DeSerialize<Map>(json);

The code above spits out a JSON like this:

[{
    "magic_numbers": [4, 2],
    "map": [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
    "entities": [1, 2, null, ...]
}, {
    "reflection_class": "Player",
    "health": 255,
    "position": {
        "x": 5.0,
        "y": 5.0
    },
    "velocity": {
        "x": 1.0,
        "y": 1.0
    },
    "name": "mlomb"
}, {
    "reflection_class": "Monster",
    "health": 255,
    "position": {
        "x": 10.0,
        "y": 10.0
    },
    "velocity": {
        "x": -1.0,
        "y": -1.0
    },
    "scary_factor": 42.12300109863281
}]

You can find the full code for this example here.

Setup

You can set it up using CMake. First clone the repository under your project directory.

Then, inside your CMakeLists.txt add the following:

add_subdirectory(MetaCPP/MetaCPP-CLI)

...

# MetaCPP automatic reflection
include(MetaCPP/CMake/MetaPrebuild.cmake)
meta_generate(YOUR_TARGET "FileToReflect.hpp" "Generated.hpp" "Generated.cpp" "")

Next and last, include the following lines at the begining of your application to load all the metadata:

#include <MetaCPP/Runtime.hpp>

int main() {
  metacpp::Storage* storage = metacpp::Runtime::GetStorage();
  metacpp::generated::Load(storage);
 
  ...
}

Dependencies

MetaCPP relies on Clang's LibTooling to generate all the metadata.
These are the dependencies:

Mustache and rapidjson are included as submodules so don't forget to clone with --recursive.

If you need to compile the CLI make sure to have installed Clang's Libtooling. In Windows you should have in PATH the Clang and LLVM binaries.

Known issues

  • Arrays of pointers are broken (#pr-3)

License

See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].