← Back

ofxBooLINQ

github.com/ffunatsu/ofxBooLINQ · @ffunatsu
OF 0.12 Utilities

boolinq for openFrameworks

2 0 Last commit 1y ago Created 1y ago

README

ofxBooLINQ



boolinq for openFrameworks (tested on v0.12.0, boolinq version: 3.0.4)

Usage



See example. (Please use projectGenerator before run it)

#include "boolinq/boolinq.h"

struct Man {
    std::string name;
    int age;
};

using namespace boolinq;

void ofApp::setup(){
    ofLogToConsole();

    int src[] = {1,2,3,4,5,6,7,8};
    auto dst = from(src).where( [](int a) { return a % 2 == 1; })      // 1,3,5,7
                        .select([](int a) { return a * 2; })           // 2,6,10,14
                        .where( [](int a) { return a > 2 && a < 12; }) // 6,10
                        .toStdVector();

    ofLogNotice("ofApp") << "dst: " << ofToString(dst);
    
    Man src2[] = {
        {"Kevin",14},
        {"Anton",18},
        {"Agata",17},
        {"Terra",20},
        {"Layer",15},
    };

    auto dst2 = from(src2).where([](const Man & man) { return man.age < 18; })
                        .orderBy([](const Man & man) { return man.age; })
                        .select( [](const Man & man) { return man.name; })
                        .toStdVector();

    ofLogNotice("ofApp") << "dst2: " << ofToString(dst2);
}

// Result:
// [notice ] ofApp: dst: {6, 10}
// [notice ] ofApp: dst2: {Kevin, Layer, Agata}


LICENSE



NOTE: No specific copyright is claimed for this repository changes (for oF binding), but the Apache License 2.0 or MIT License can be applied if necessary.

Get this addon

HTTPS
SSH