All Projects → hiitiger → CoolerCppIdiom

hiitiger / CoolerCppIdiom

Licence: MIT license
cooler c++ patterns like async, event delegate, json auto serialization

Programming Languages

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

Projects that are alternatives of or similar to CoolerCppIdiom

JavaScript-design-patterns
Examples of popular design patterns in JavaScript
Stars: ✭ 41 (-14.58%)
Mutual labels:  design-patterns
design patterns
PHP设计模式
Stars: ✭ 17 (-64.58%)
Mutual labels:  design-patterns
Entitas-Redux
An entity-component framework for Unity with code generation and visual debugging
Stars: ✭ 84 (+75%)
Mutual labels:  design-patterns
laravel-decorator
Easily decorate your method calls with laravel-decorator package
Stars: ✭ 125 (+160.42%)
Mutual labels:  design-patterns
design-system
British Columbia Government Design System for Digital Services
Stars: ✭ 33 (-31.25%)
Mutual labels:  design-patterns
Front-End-Design-Patterns
Design Patterns
Stars: ✭ 25 (-47.92%)
Mutual labels:  design-patterns
swe
Examples and exercises used during Software Engineering course
Stars: ✭ 18 (-62.5%)
Mutual labels:  design-patterns
about-Vue
📔 Vue 源码的探讨和学习
Stars: ✭ 56 (+16.67%)
Mutual labels:  design-patterns
design-pattern-examples-in-crystal
UML model and code examples of design patterns for Crystal. The model is created with Astah.
Stars: ✭ 51 (+6.25%)
Mutual labels:  design-patterns
ruby-patterns
NOTE: NO LONGER MAINTAINED
Stars: ✭ 33 (-31.25%)
Mutual labels:  design-patterns
design-pattern
Design patterns
Stars: ✭ 200 (+316.67%)
Mutual labels:  design-patterns
design-patterns-php
All Design Patterns Samples in PHP
Stars: ✭ 43 (-10.42%)
Mutual labels:  design-patterns
PlantUMLDesignPatterns
No description or website provided.
Stars: ✭ 34 (-29.17%)
Mutual labels:  design-patterns
jw-design-library
A library of product design patterns comprised of code, usage and guidelines.
Stars: ✭ 16 (-66.67%)
Mutual labels:  design-patterns
Design-Patterns-in-Swift
This is a repository for our article about design patterns in the Swift programming language https://rubygarage.org/blog/swift-design-patterns
Stars: ✭ 53 (+10.42%)
Mutual labels:  design-patterns
HeadFirstDesignPatternsSwift
An implementation of examples from "Head First Design Patterns", written in Swift.
Stars: ✭ 20 (-58.33%)
Mutual labels:  design-patterns
git-toolkit
Git工具集
Stars: ✭ 35 (-27.08%)
Mutual labels:  toolkits
dotnet-design-patterns-samples
The samples of .NET design patterns
Stars: ✭ 25 (-47.92%)
Mutual labels:  design-patterns
puremvc-swift-multicore-framework
PureMVC MultiCore Framework for Swift
Stars: ✭ 17 (-64.58%)
Mutual labels:  design-patterns
estore
Electronic Store Application - A web based application developed using PHP and Driven by MySQL Database
Stars: ✭ 48 (+0%)
Mutual labels:  design-patterns

CoolerCppIdiom

Codacy Badge

Collection of useful c++ tools / common idioms you might not found elsewhere, provide with clean code and easy to use api, mose of then are just one file with minimal dependency.

How to

Just include the corresponding file.

Useful kits

cooler cpp async

A cooler version of promise pattern, we can create our own dispatcher to dispatch task to threads(ui,pool,io,http,etc) just like using std::async and future::then.

This specific implementation uses ppltask, but we can implement it on any primise-like library for c++.

using namespace concurrency_;

auto t = delayed(1000)
| ui([] {
    std::cout << "running on ui" << std::endl;
})
| io([] {
    std::cout << "running on io" << std::endl;
    return std::this_thread::get_id();
})
| delay<std::thread::id>(100)
| pool([](std::thread::id id) {
    std::cout << "running on pool" << std::endl;
    std::cout << "received thread_id" << id  << std::endl;
});
json auto serialize

Make json serialization easier for your life.

With nlohmann's JSON for Modern C++ plus a helper file, we can do this now

struct Person{
    std::string name;
    std::optional<std::uint32_t> age;
    std::optional<std::vector<Person>> friends;
};

JSON_AUTO(Person, name, age, friends)

void func()
{
    Person p;
    p.name = "John";
    json obj = p;
    Person op = obj;
}
Event Delegate

A simple yet powerful event delegate implementation, support trackable listener, provide an alternate bind to std::bind which support bind to smart pointer.

Event<void(const std::string&, std::string&&)> signal1;

auto func1 = Storm::lambda([&, nocopy]() {
    signal1("123", "123");
});

auto conn1 = signal1.add([&slot1](const std::string& v, std::string&& str){
    slot1 = true;
    std::cout << "\nslot 1: " << v << ", " << std::string(std::move(str)) << std::endl;
});

Connection conn2 = signal1.add([&slot2, &conn2](const std::string& v, std::string&& str) {
    slot2 = true;
    std::cout << "\nslot 2: " << v << ", " << str << std::endl;
    conn2.disconnect();
});


func1();
qasync

An async call adapter for Qt which enables user to post async lambda to Qt's UI thread.

workerpool

A easy to use c++11 thread pool.

snowflake

Snowflake uuid generator in c++.

throttle

A simple throttle control.

trace

Object leak trace, perf timer and extras.

time

Timetick, Datetime, FpsTimer.

com ptr

Windows Com ptr implementation with clean and safe interface.

object tree

Object tree is a useful way to manage object in c++.

Qt metecall

Generica Qt metacall which enables user to call QObject's method with name and QVariantList packed arguments.

...
const QString& object;
const QString& method; 
const QVariantList& args;
//get meta method from method name
QMetaMethod metaMethod;
Qx::metaCall(object, metaMethod, args);
Qt genericsignalmap

Generica Qt signal map which enables user to connect QObject's signal with name and QVariantList packed arguments.

GenericSignalMapper* mapper1 = new GenericSignalMapper(method, this);
connect(object, qFlagLocation(signature.toUtf8().constData()), mapper1, SLOT(mapSlot()));
connect(mapper1, SIGNAL(mapped(QObject*, QMetaMethod, QVariantList)), this, SLOT(onGenericSignal(QObject*, QMetaMethod, QVariantList)));
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].