Fluent C++ is a library that can be used to express information in a functional way that allows for easy auto-complete and shorter expressions.
std::vector<int> xs;
for (int x = 0; x < 1000; x++) xs.push_back(x);
fcpp::query(xs)
.where(EXPR(x, x > 500))
.shuffle()
- Go to the release you want to install.
- Download the
fluentcpp-<tag>.tar.gz
file. - Decompress the file in the directory
tar -xvzf fluentcpp-<tag>.tar.gz
. - Run the install command
sudo ./install.sh
. - The library files are now installed on your system and can be used as in the examples.
If you just want to build the source code and not install it, you can run these commands instead.
Two types of builds:
one for local debugging and library generation,
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug # Builds and tests
cmake --build . --config Debug --target fluentcpp
and the other for all release assets.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug # Builds, tests and creates documentation
cmake --build . --config Debug --target fluentcpp
Lastly, to install the library on the system for use.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --target fluentcpp
make install
This will install artifacts in the /usr/local/lib/fluentcpp
and /usr/local/include/fluentcpp
directories so that they can be referenced as the usage example below (i.e. #include <fluentcpp/query.h
.
Find more in the examples folder.
#include <fluentcpp/query.h>
#include <iostream>
#include <vector>
int main()
{
// @todo Add descriptions and use cases.
std::vector<int> xs;
for (int x = 0; x < 1000; x++) xs.push_back(x);
fcpp::query(xs)
.where(EXPR(x, x > 500))
.shuffle()
.skip(10)
.select(EXPR(x, x % 10))
.distinct()
.order_by(EXPR(x, x))
.branch(EXPR(x, x > 5))
.when_true([](auto q)
{ return q.select(EXPR(x, x + 100)); })
.when_false([](auto q)
{ return q.select(EXPR(x, x - 100)); })
.merge()
.select(EXPR(x, std::get<0>(x)))
.action([](auto x)
{ std::cout << x; });
}