Setup

Install

The source is available here:

This is a header-only library; building by default will build examples. Installation is also useful.

$ git clone https://github.com/rpav/cpp-pipedream.git
$ cd cpp-pipedream
$ mkdir build; cd build
$ cmake ..
$ make install

Additionally, tests and docs are possible, if Doxygen or BUILD_TESTING is enabled in CMake.

Examples and Tests

Many of the examples in this documentation are available in the examples/ directory. These will build by default.

Tests will not build by default, but you can enable them with -DBUILD_TESTING=ON as appropriate to cmake, and run with ctest or make test etc. Tests are in t/.

Project Inclusion

If you use cmake, and ran make install (or equivalent) you should be able to simply pull in pipedream and use it.

From examples/CMakeLists.txt:

cmake_minimum_required(VERSION 3.11)
project(pipedream_examples)

set(CMAKE_CXX_STANDARD 17)

#find_package(pipedream REQUIRED)

add_executable(setup_example setup_example.cpp)
target_link_libraries(setup_example
    PRIVATE pipedream)

From examples/setup_example.cpp:

#include <iostream>
#include <piped.hpp>

//using namespace piped;              // Useful, or you can alias
namespace pd = piped;
using namespace piped::operators;

int main() {
    auto g = pd::from_to(1,10) | pd::filter([](auto i) { return i % 2; });

    for(auto i : g)
        std::cout << i << std::endl;
}

Building and running this should produce the expected results:

$ cd examples
$ mkdir build; cd build
$ cmake ..
  <output>
$ make setup_example
  <output>
$ ./setup_example
1
3
5
7
9
$

On Headers

To get everything from pipedream ("piped" for short):

#include <piped.hpp>

However, this pulls in a number of things you may not want, such as <regex>, which only apply to certain operations. You can instead pull in separate headers if you choose:

#include <piped/string.hpp>

For the purposes of this documentation, examples will just #include <piped.hpp>.

On Namespaces

A basic example:

#include <vector>
#include <piped.hpp>

using namespace piped;

auto v = from_to(0,5) | collect<std::vector>

You are not required, of course, to dump this namespace entirely the global namespace. The alternative:

using namespace piped::operators;   // Only the definitions for operator| and |=
namespace pd = piped;

auto v = pd::from_to(0,5) | pd::collect<std::vector>

But for the purposes of this documentation, for brevity and clarity, I will assume we have using namespace piped;.