A Universal ORM Engine based on compile time Reflection

A Universal ORM Engine based on Reflection

ormpp is a modern, universal and easy-to-use ORM engine developed in c++14. ormpp only supports sqlite now, however ormpp can support any database, such as mysql, postgresql,oracle etc. ormpp will support many kind of database in future. ormpp is in developing now.

Motivation

Simplify database operation with compile-time reflection.ormpp provides very simple and universal interface, although the databases type are different.In short ormpp shields the difference of the bottom database.
This library provides a portable cross-platform way of:

  • operation of sqlite
  • operation of mysql(in the paln)
  • operation of postgresql(in the paln)
  • operation of any other database

Tutorial

This Tutorial is provided to give you a view of how to use ormpp, now it is only concerned with sqlite.

Data manipulation

Create a database.

Create a table.

The excecute method is a universal interface, it can accept any data manipulation sql string. So you can also call excecute for insert, update and delete etc.

Binding parameters.

The excecute interface support binding parameters, bellow is an example.

If the statement needs some later binding parameters, pass the parameters straight forward. ormpp will atomically binding theparameters.

Operation with object

If you get tired of filling many parameters, you can choose object instead. ormpp can automatically make sql with compile-time reflection.Bellow is an example of inserting with object.
Firstly, define meta data just as iguana dose.

Secondly, directly call excecute interface.

ignore some fields of an object

insert interface provides a default parameter which is used to tell ormpp which fields would be ignored.Just need pass the fields indexes.Bellow is an example about ignore specific fields:

Query table

Query table is also very simple, just need call a query interface with a reflection object.

How about multiple tables query? Still call the query interface.

If you query parts of tables, still call the query interface

Full sources:

  • https://github.com/qicosmos/ormpp/blob/master/example.cpp

If you found a bug, please create an issue on GitHub with a detailed description. If you like it please star it

《A Universal ORM Engine based on compile time Reflection》有3个想法

发表评论

Copy Protected by Chetan's WP-Copyprotect.