├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── clang-format.bash ├── img └── logo.png ├── include └── pipeline │ ├── details.hpp │ ├── fn.hpp │ ├── for_each.hpp │ ├── fork_into.hpp │ ├── from.hpp │ ├── pipe_pair.hpp │ ├── pipeline.hpp │ └── unzip_into.hpp ├── pipeline.pc.in ├── pipelineConfig.cmake.in ├── samples ├── CMakeLists.txt ├── for_each.cpp ├── for_each_return.cpp ├── fork_into.cpp ├── fork_into_variant.cpp ├── pipe_reference.cpp ├── pipe_simple.cpp ├── unzip_into.cpp ├── unzip_into_return.cpp └── unzip_into_single_functor.cpp ├── single_include.json ├── single_include └── pipeline │ └── pipeline.hpp └── utils └── amalgamate ├── CHANGES.md ├── LICENSE.md ├── README.md ├── amalgamate.py └── config.json /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | .vscode/ 28 | # Uncomment if you have tasks that create the project's static files in wwwroot 29 | #wwwroot/ 30 | 31 | # MSTest test Results 32 | [Tt]est[Rr]esult*/ 33 | [Bb]uild[Ll]og.* 34 | 35 | # NUNIT 36 | *.VisualState.xml 37 | TestResult.xml 38 | 39 | # Build Results of an ATL Project 40 | [Dd]ebugPS/ 41 | [Rr]eleasePS/ 42 | dlldata.c 43 | 44 | # DNX 45 | project.lock.json 46 | project.fragment.lock.json 47 | artifacts/ 48 | 49 | *_i.c 50 | *_p.c 51 | *_i.h 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.tmp_proj 66 | *.log 67 | *.vspscc 68 | *.vssscc 69 | .builds 70 | *.pidb 71 | *.svclog 72 | *.scc 73 | 74 | # Chutzpah Test files 75 | _Chutzpah* 76 | 77 | # Visual C++ cache files 78 | ipch/ 79 | *.aps 80 | *.ncb 81 | *.opendb 82 | *.opensdf 83 | *.sdf 84 | *.cachefile 85 | *.VC.db 86 | *.VC.VC.opendb 87 | 88 | # Visual Studio profiler 89 | *.psess 90 | *.vsp 91 | *.vspx 92 | *.sap 93 | 94 | # TFS 2012 Local Workspace 95 | $tf/ 96 | 97 | # Guidance Automation Toolkit 98 | *.gpState 99 | 100 | # ReSharper is a .NET coding add-in 101 | _ReSharper*/ 102 | *.[Rr]e[Ss]harper 103 | *.DotSettings.user 104 | 105 | # JustCode is a .NET coding add-in 106 | .JustCode 107 | 108 | # TeamCity is a build add-in 109 | _TeamCity* 110 | 111 | # DotCover is a Code Coverage Tool 112 | *.dotCover 113 | 114 | # NCrunch 115 | _NCrunch_* 116 | .*crunch*.local.xml 117 | nCrunchTemp_* 118 | 119 | # MightyMoose 120 | *.mm.* 121 | AutoTest.Net/ 122 | 123 | # Web workbench (sass) 124 | .sass-cache/ 125 | 126 | # Installshield output folder 127 | [Ee]xpress/ 128 | 129 | # DocProject is a documentation generator add-in 130 | DocProject/buildhelp/ 131 | DocProject/Help/*.HxT 132 | DocProject/Help/*.HxC 133 | DocProject/Help/*.hhc 134 | DocProject/Help/*.hhk 135 | DocProject/Help/*.hhp 136 | DocProject/Help/Html2 137 | DocProject/Help/html 138 | 139 | # Click-Once directory 140 | publish/ 141 | 142 | # Publish Web Output 143 | *.[Pp]ublish.xml 144 | *.azurePubxml 145 | # TODO: Comment the next line if you want to checkin your web deploy settings 146 | # but database connection strings (with potential passwords) will be unencrypted 147 | #*.pubxml 148 | *.publishproj 149 | 150 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 151 | # checkin your Azure Web App publish settings, but sensitive information contained 152 | # in these scripts will be unencrypted 153 | PublishScripts/ 154 | 155 | # NuGet Packages 156 | *.nupkg 157 | # The packages folder can be ignored because of Package Restore 158 | **/packages/* 159 | # except build/, which is used as an MSBuild target. 160 | !**/packages/build/ 161 | # Uncomment if necessary however generally it will be regenerated when needed 162 | #!**/packages/repositories.config 163 | # NuGet v3's project.json files produces more ignoreable files 164 | *.nuget.props 165 | *.nuget.targets 166 | 167 | # Microsoft Azure Build Output 168 | csx/ 169 | *.build.csdef 170 | 171 | # Microsoft Azure Emulator 172 | ecf/ 173 | rcf/ 174 | 175 | # Windows Store app package directories and files 176 | AppPackages/ 177 | BundleArtifacts/ 178 | Package.StoreAssociation.xml 179 | _pkginfo.txt 180 | 181 | # Visual Studio cache files 182 | # files ending in .cache can be ignored 183 | *.[Cc]ache 184 | # but keep track of directories ending in .cache 185 | !*.[Cc]ache/ 186 | 187 | # Others 188 | ClientBin/ 189 | ~$* 190 | *~ 191 | *.dbmdl 192 | *.dbproj.schemaview 193 | *.jfm 194 | *.pfx 195 | *.publishsettings 196 | node_modules/ 197 | orleans.codegen.cs 198 | 199 | # Since there are multiple workflows, uncomment next line to ignore bower_components 200 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 201 | #bower_components/ 202 | 203 | # RIA/Silverlight projects 204 | Generated_Code/ 205 | 206 | # Backup & report files from converting an old project file 207 | # to a newer Visual Studio version. Backup files are not needed, 208 | # because we have git ;-) 209 | _UpgradeReport_Files/ 210 | Backup*/ 211 | UpgradeLog*.XML 212 | UpgradeLog*.htm 213 | 214 | # SQL Server files 215 | *.mdf 216 | *.ldf 217 | 218 | # Business Intelligence projects 219 | *.rdl.data 220 | *.bim.layout 221 | *.bim_*.settings 222 | 223 | # Microsoft Fakes 224 | FakesAssemblies/ 225 | 226 | # GhostDoc plugin setting file 227 | *.GhostDoc.xml 228 | 229 | # Node.js Tools for Visual Studio 230 | .ntvs_analysis.dat 231 | 232 | # Visual Studio 6 build log 233 | *.plg 234 | 235 | # Visual Studio 6 workspace options file 236 | *.opt 237 | 238 | # Visual Studio LightSwitch build output 239 | **/*.HTMLClient/GeneratedArtifacts 240 | **/*.DesktopClient/GeneratedArtifacts 241 | **/*.DesktopClient/ModelManifest.xml 242 | **/*.Server/GeneratedArtifacts 243 | **/*.Server/ModelManifest.xml 244 | _Pvt_Extensions 245 | 246 | # Paket dependency manager 247 | .paket/paket.exe 248 | paket-files/ 249 | 250 | # FAKE - F# Make 251 | .fake/ 252 | 253 | # JetBrains Rider 254 | .idea/ 255 | *.sln.iml 256 | 257 | # CodeRush 258 | .cr/ 259 | 260 | # Python Tools for Visual Studio (PTVS) 261 | __pycache__/ 262 | *.pyc 263 | 264 | # CMake build directory 265 | build 266 | 267 | # Cppcheck build directory 268 | analysis-cppcheck-build-dir 269 | 270 | # Ideas directory 271 | ideas 272 | 273 | desktop.iniimages/ 274 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | 3 | if(DEFINED PROJECT_NAME) 4 | set(PIPELINE_SUBPROJECT ON) 5 | endif() 6 | 7 | if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12") 8 | project(pipeline VERSION 1.0.0 LANGUAGES CXX 9 | HOMEPAGE_URL "https://github.com/p-ranav/pipeline" 10 | DESCRIPTION "Pipelines for Modern C++") 11 | elseif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9") 12 | project(pipeline VERSION 1.0.0 LANGUAGES CXX 13 | DESCRIPTION "Pipelines for Modern C++") 14 | else() 15 | project(pipeline VERSION 1.0.0 LANGUAGES CXX) 16 | endif() 17 | 18 | if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") 19 | include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") 20 | conan_basic_setup() 21 | endif() 22 | 23 | option(PIPELINE_BUILD_TESTS "Build pipeline tests + enable CTest") 24 | option(PIPELINE_SAMPLES "Build pipeline samples") 25 | 26 | include(CMakePackageConfigHelpers) 27 | include(GNUInstallDirs) 28 | 29 | find_package(Threads REQUIRED) 30 | 31 | add_library(pipeline INTERFACE) 32 | add_library(pipeline::pipeline ALIAS pipeline) 33 | 34 | target_compile_features(pipeline INTERFACE cxx_std_17) 35 | target_include_directories(pipeline INTERFACE 36 | $ 37 | $) 38 | target_link_libraries(pipeline INTERFACE Threads::Threads) 39 | 40 | if(PIPELINE_SAMPLES) 41 | add_subdirectory(samples) 42 | endif() 43 | 44 | if(NOT PIPELINE_SUBPROJECT) 45 | configure_package_config_file(pipelineConfig.cmake.in 46 | ${CMAKE_CURRENT_BINARY_DIR}/pipelineConfig.cmake 47 | INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pipeline) 48 | write_basic_package_version_file(pipelineConfigVersion.cmake 49 | COMPATIBILITY AnyNewerVersion) 50 | 51 | configure_file(pipeline.pc.in pipeline.pc @ONLY) 52 | 53 | install(TARGETS pipeline EXPORT pipelineTargets) 54 | install(EXPORT pipelineTargets 55 | FILE pipelineTargets.cmake 56 | NAMESPACE pipeline:: 57 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pipeline) 58 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pipelineConfig.cmake 59 | ${CMAKE_CURRENT_BINARY_DIR}/pipelineConfigVersion.cmake 60 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pipeline) 61 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pipeline.pc 62 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 63 | install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/pipeline 64 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 65 | USE_SOURCE_PERMISSIONS 66 | PATTERN "*.hpp") 67 | install(FILES LICENSE LICENSE.termcolor 68 | DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/pipeline) 69 | 70 | if(EXISTS "${PROJECT_SOURCE_DIR}/.gitignore") 71 | # Simple glob to regex conversion (.gitignore => CPACK_SOURCE_IGNORE_FILES) 72 | file(READ ".gitignore" DOT_GITIGNORE) 73 | string(REPLACE ";" "RANDOMSEQUENCE" DOT_GITIGNORE "${DOT_GITIGNORE}") 74 | string(REPLACE "\n" ";" DOT_GITIGNORE "${DOT_GITIGNORE}") 75 | string(REPLACE "RANDOMSEQUENCE" "\\;" DOT_GITIGNORE "${DOT_GITIGNORE}") 76 | foreach(IGNORE_LINE ${DOT_GITIGNORE}) 77 | if(NOT IGNORE_LINE OR IGNORE_LINE MATCHES "^#") 78 | continue() 79 | endif() 80 | string(REPLACE "\\" "\\\\" IGNORE_LINE "${IGNORE_LINE}") 81 | string(REPLACE "." "\\\\." IGNORE_LINE "${IGNORE_LINE}") 82 | string(REPLACE "*" ".*" IGNORE_LINE "${IGNORE_LINE}") 83 | string(REPLACE "+" "\\\\+" IGNORE_LINE "${IGNORE_LINE}") 84 | list(APPEND CPACK_SOURCE_IGNORE_FILES "${IGNORE_LINE}") 85 | endforeach() 86 | endif() 87 | 88 | # extra ignored files 89 | list(APPEND CPACK_SOURCE_IGNORE_FILES 90 | .editorconfig 91 | .git 92 | .gitignore 93 | .travis.yml 94 | .appveyor.yml 95 | ) 96 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") 97 | set(CPACK_GENERATOR "TGZ;TXZ") 98 | set(CPACK_SOURCE_GENERATOR "TGZ;TXZ") 99 | include(CPack) 100 | endif() 101 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Contributions are welcomed. Open a pull-request or an issue. 3 | 4 | ## Code of conduct 5 | This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code. 6 | 7 | [code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Pranav 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | ## Getting Started 6 | 7 | `pipeline` is a `C++17` header-only template library that lets you setup data processsing pipelines. Simply include `` and you're good to go. There is also a single_include version in `single_include/`. 8 | 9 | Let's start with the simple pipeline below. Wrap your functions using `pipeline::fn` and create a pipeline using the pipe (`|`) operator. Then simply call the pipeline to execute a sequence of functions. 10 | 11 | ```cpp 12 | #include 13 | #include 14 | using namespace pipeline; 15 | 16 | int main() { 17 | auto add_2 = fn([](auto a, auto b) { return a + b; }); 18 | auto print = fn([](auto result) { std::cout << result << "\n"; }); 19 | 20 | auto pipeline = add_2 | print; 21 | 22 | pipeline(2, 3); // 5 23 | } 24 | ``` 25 | 26 | ## Building Samples 27 | 28 | ```bash 29 | git clone https://github.com/p-ranav/pipeline 30 | cd pipeline 31 | mkdir build && cd build 32 | cmake -DPIPELINE_SAMPLES=ON .. 33 | make 34 | ``` 35 | 36 | ## Generating Single Header 37 | 38 | ```bash 39 | python3 utils/amalgamate/amalgamate.py -c single_include.json -s . 40 | ``` 41 | 42 | ## Contributing 43 | Contributions are welcome, have a look at the [CONTRIBUTING.md](CONTRIBUTING.md) document for more information. 44 | 45 | ## License 46 | The project is available under the [MIT](https://opensource.org/licenses/MIT) license. 47 | -------------------------------------------------------------------------------- /clang-format.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | find ./include ./samples/ ./single_include -type f \( -iname \*.cpp -o -iname \*.hpp \) | xargs clang-format -style="{ColumnLimit : 100}" -i 3 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-ranav/pipeline/31fffe6af101da57513eebca7518b1e434f5de87/img/logo.png -------------------------------------------------------------------------------- /include/pipeline/details.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace pipeline { 5 | 6 | template class pipe_pair; 7 | 8 | template class fork_into; 9 | 10 | namespace details { 11 | 12 | // is_tuple constexpr check 13 | template struct is_tuple : std::false_type {}; 14 | template struct is_tuple> : std::true_type {}; 15 | 16 | template class Ref> 17 | struct is_specialization : std::false_type {}; 18 | 19 | template