Giter Site home page Giter Site logo

proplib's Introduction

Build Status

Properties serialization library

proplib is a set of crossplatform c++11 libraries and tools which allow serialize, deserialize, visualize and edit c++ objects without codegeneration what well suitable for algorithms properties configuration.

Example of usage

#include <fstream>
#include <iostream>

#include <serialize/serializable.h>
#include <serialize/serialize.h>
#include <yaml-cpp/yaml.h>

class Box : public proplib::Serializable
{

public:
  float height;
  float width;
  std::string name;

private:
  SERIALIZE(height, "height of the box");
  SERIALIZE(width, "width of the box");
  SERIALIZE(name, "name of the box");
};

int main()
{
  Box box; 
  box.height = 1.0;
  box.width = 1.4;
  box.name = "just a small box in the big world";

  YAML::Emitter out;
  box.serialize(out, false);
  std::ofstream outfile;
  outfile.open("box.prop.yml");
  outfile << out.c_str() << std::endl;
  outfile.close();

  box.height = 0.0;
  box.width = 0.0;
  box.name = "--";

  box.deserialize(YAML::LoadFile("box.prop.yml"));

  std::cout << "box.height " << box.height << std::endl;
  std::cout << "box.width " << box.width << std::endl;
  std::cout << "box.name " << box.name << std::endl;

  system("pause");
  return 0;
}

box.prop.yml file content:

height: 1
name: just a small box in the big world
width: 1.4

console output:

box.height 1
box.width 1.4
box.name just a small box in the big world
Для продолжения нажмите любую клавишу . . .

Also we can serialize box with docstrings and metainfo for gui generation

box.serialize(out, true);

box.prop.yml file content:

height: !<float> 1
height_doc: !<doc> height of the box
name: !<string> just a small box in the big world
name_doc: !<doc> name of the box
width: !<float> 1.4
width_doc: !<doc> width of the box

then we can open, edit and save this file in proplib-qt-editor

alt text

or in ImGui based proplib-imgui-editor

alt text

Supported types

  • arithmetic
  • bool
  • std::string
  • std::map
  • std::vector

Supported formats

  • YAML

Components

  • proplib-serialize - serialization/deserialization lib
  • proplib-gui
    • proplib-qt-gui - qt based qui lib
  • proplib-qt-editor - qt based editor app
  • propsdk-imgui-editor - imgui based editor app
  • tests
    • prop-serialize - serialization/deserialization test
    • http-client - remote transfer test

Future work

  • support JSON format
  • support binary format
  • support enums serialization/deserialization
  • add meta info in docstring like hints for better data representation and hins about possible values of object fields
  • minimize transferred data size

proplib's People

Contributors

lishen1 avatar ueberaccelerate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

happydpc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.