C++ Now 技术大会将在于今年5.15-5.20在美国科罗拉州的阿斯彭举办

header_image2

C++ Now 2017技术大会的日程已经公布,5.15-5.20将有来自世界各地的50多位讲师分享modern c++的技术和idea。这里有详细的日程表,以及讲师介绍

purecpp社区创始人祁宇也将在这次的大会上做一个演讲,他也是唯一一位中来自中国的讲师。purecpp社区将持续关注c++ now2017技术大会的最新资讯。

欢迎关注purecpp社区的微信公众号。
qrcode_for_gh_300922997283_430
社区微博:http://weibo.com/5558815868

The design philosophy of rest_rpc

The design philosophy of rest_rpc

Bellow are the design philosophy of rest_rpc:

  1. Rapid development;
  2. Easy to use;
  3. Focus on business;

Rapid development

You can develop a tcp network application in 5 minutes using rest_rpc. There is an example of a rpc server which provides some rpc service.
Firstly, define a business method ‘add’.

Secondly, register the business method as a rpc api for client.

Now You have finished a rpc server less than 10 lines code, the rpc server provide only one service.You can easily
add more rpc api as bellow:

1.define business logic:

2.register business logic:

Above example shows how to apply a business class for rpc service.
How about the client?The client code just need very little code,
Bellow is a rest_rpc client example:

1.define call protocol

2.directly call with parameters

You can develop a network application rapidly and convenient with rest_rpc, very little code is needed.

Easy to use

Easy to use is rest_rpc’s main goal, we do much effort for the goal. We hope both client and server are very easy to use.THe first principle is that RPC called just like local function calls.

At client we call a universal method ‘call’ which needs remote endpoint, RPC service name and parameters, it’s very like a local function call.We hope the user
can forget this is a network program, but treat it as a local application.

The second principle is omitted network and serialization details, because we want to use the interface as simple as we can, no extra afford.So rest_rpc do the fussy for users and they can’t feel it.

We verify RPC parameters are type correct at compile-time instead of just run-time, We can find problem as soon as possible.We utilize meta data to avoid defining a protocol file which can reduce learning costs.

At server we also do much work to simplify user interface. you can register callback of any signature with same manner, no restriction at all.

Focus on business

To be continued…

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 serialization engine based on compile time reflection

iguana is a modern, universal and easy to use serialization engine developed in c++14.

Motivation

Serialize an object to any other format data with compile time reflection, such as json, xml, binary,table and so on.
This library was degined to unify and simplify serialization in a portable cross-plateform manner. This library is also easily to extend, you can serialize any format data with the library.
Library provides a portable across platforms way to:

  • serialization of json
  • serialization of xml
  • serialization of any customized format

Tutorial

This Tutorial is provided to give you an view of how to iguana for serialization.

serialization of json

The first thing to do when you serialize an object is to define meta data. There is an example of defining meta data.

Defining meta data is very simple, just needs to difine a ‘REFLECTION’ micro.

Now let’s serialize person to json string.

This example will output:

serialize person to json string is also very simple, just need to call to_json method, there is nothing more.

How about deserialization of json? Look at the follow example.

It’s as simple as serialization, just need to call from_json method.

serialization of xml

Serialization of xml is similar with json. The first step is also defining meta data as above. This is a complete example.

a complicated example

iguana can deal with objects which contain another objects and containers. Here is the example:

At first define meta data:

Then call the simple interface:

Full sources:

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

F.A.Q

  • Question: Why is the name called iguana?

    • Answer: I think serialization is like an iguana, because the change is only the display format, however the meta data is never changed. With changeless meta data and reflection you can serializa an object to any format which is like an iguana does.
  • Question: Is iguana support raw pointer?

    • Answer: No. iguana doesn’t support raw pointer, but will surpport smart pointer in the future.
  • Question: Is iguana thread safe?

    • Answer: Not yet, but it’s not a problem, you can use lock before call from_json or to_json.
  • Question: Is iguana high performance?

    • Answer: Yes it is, because iguana is based on compile time reflection.
  • Question: I have found a bug, how do I notify?
    Answer: Create an issue at GitHub with a detailed description.

If you like iguana, please star it, thanks.

Copy Protected by Chetan's WP-Copyprotect.