Skip to content

A header-only template library for convenient debugging of variables

Notifications You must be signed in to change notification settings

Silvan-K/easy-print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easyPrint: header-only printing library

Provides a simple function that allows the user to conveniently print variables and STL containers without explicitly looping over them. Designed to behave similarly to python's print function.

CI status

Build, test, and install

To install this project under the $PREFIX (which is set to $HOME/.local/ in this example):

# Clone repo
git@github.com:Silvan-K/easy-print.git && cd easy-print

# Configure build
export $PREFIX=$HOME/.local
mkdir build && cd build && cmake ../ -DCMAKE_INSTALL_PREFIX=$PREFIX

# Build, install, test
cmake --build .
cmake --install .
ctest --test-dir tests

The above commands install the header easyPrint.hpp in $PREFIX/include/.

Using the library

To use this library in a hypothetical cmake target MyTarget, please add the following lines to your cmake file:

find_package(easyPrint CONFIG REQUIRED)
target_link_libraries(MyTarget easyPrint)

This sets the required include path to easyPrint automatically. In your code for MyTarget, you can then use the library as follows:

#include "easyPrint.hpp"
#include <vector>
#include <array>

std::vector<std::vector<int>> nested_vec{std::vector<int>{1,2,3,4},
                                         std::vector<int>{5,6,7}};

easyPrint::print("Some vector", std::vector<int>{1,2,3},
                 "followed by an int", 12,
                 "and another vector", std::vector<double>(3,12.0),
                 "and a nested vector", nested_vec,
                 "and an empty vector", std::vector<double>(),
                 "and an array", std::array<double, 3>());
                 
easyPrint::printErr(12, "<- this number will end up in stderr");

About

A header-only template library for convenient debugging of variables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published