Fluent C++ :: Readme
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()
Installing
- 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.
Building
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
Usage Examples
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; });
}
Dependencies
Queryable< T > query(std::vector< T > items)
Queries the sequence of items using a vector.
Definition: query.h:618
#define EXPR(...)
Syntactic sugar for terse expressions using pass by value.
Definition: query.h:67