ptc-print
A C++17 header-only library for custom printing to the output stream (inspired by the Python print function).
Classes | Public Member Functions | List of all members
ptc::Print< T_str > Struct Template Reference

Class used to construct the print function. More...

#include <print.hpp>

Classes

struct  select_cout
 Struct used to define a way to template the choice of the "std::cout" object in order to be "std::cout" for "char" type or "std::wcout" for "wchar_t" type. More...
 

Public Member Functions

 Print ()
 Default constructor of the Print class. It initializes the basic class members and enable (if required) performance improvements.. More...
 
template<class T >
void setEnd (const T &end_val)
 Setter used to set the value of the "end" variable. Templated type is required in order to allow also char variables. More...
 
template<class T >
void setSep (const T &sep_val)
 Setter used to set the value of the "sep" variable. Templated type is required in order to allow also char variables. More...
 
void setFlush (const bool &flush_val)
 Setter used to set the value of the "flush" variable. Templated type is required in order to allow also char variables. More...
 
template<class T >
void setPattern (const T &pattern_val)
 Setter used to set the value of the "pattern" variable. Templated type is required in order to allow also char variables. More...
 
template<class T , class... Args>
void operator() (T &&first, Args &&... args) const
 Frontend implementation of the () operator overload to print to the output stream. The backend implementation is called in the required variation. More...
 
template<class... Args>
const std::basic_string< T_str > operator() (mode &&first, Args &&... args) const
 Frontend implementation of the () operator overload to initialize its content with an std::string object. The backend implementation is called in the required variation. This overload is required in order to hide the output of the "print_backend" function during the initialization. More...
 
void operator() (std::basic_ostream< T_str > &os=select_cout< T_str >::cout) const
 Template operator redefinition used to print an empty line on the screen. This is the no argument case overload. Can be used with "ptc::print()" or "ptc::print( ostream_name )". More...
 

Detailed Description

template<class T_str>
struct ptc::Print< T_str >

Class used to construct the print function.

Template Parameters
T_strThe type of the string objects defined inside the struct. This template is used in case you are dealing with std::string or std::wstring objects.

Constructor & Destructor Documentation

◆ Print()

template<class T_str >
ptc::Print< T_str >::Print ( )
inlineexplicit

Default constructor of the Print class. It initializes the basic class members and enable (if required) performance improvements..

Member Function Documentation

◆ operator()() [1/3]

template<class T_str >
template<class... Args>
const std::basic_string<T_str> ptc::Print< T_str >::operator() ( mode &&  first,
Args &&...  args 
) const
inline

Frontend implementation of the () operator overload to initialize its content with an std::string object. The backend implementation is called in the required variation. This overload is required in order to hide the output of the "print_backend" function during the initialization.

Template Parameters
ArgsGeneric type of all the other objects to be passed to the backend implementation.
Parameters
firstFirst object to be passed to the backend implementation.
argsThe list of all the other objects to be passed to the backend implementation.
Returns
const std::basic_string<T_str> The whole print content in string format.

◆ operator()() [2/3]

template<class T_str >
void ptc::Print< T_str >::operator() ( std::basic_ostream< T_str > &  os = select_cout<T_str>::cout) const
inline

Template operator redefinition used to print an empty line on the screen. This is the no argument case overload. Can be used with "ptc::print()" or "ptc::print( ostream_name )".

Parameters
osThe stream in which you want to print the output.

◆ operator()() [3/3]

template<class T_str >
template<class T , class... Args>
void ptc::Print< T_str >::operator() ( T &&  first,
Args &&...  args 
) const
inline

Frontend implementation of the () operator overload to print to the output stream. The backend implementation is called in the required variation.

Template Parameters
TGeneric type of first object to be passed as argument to the backend implementation.
ArgsGeneric type of all the other objects to be passed to the backend implementation.
Parameters
firstFirst object to be passed to the backend implementation.
argsThe list of all the other objects to be passed to the backend implementation.

◆ setEnd()

template<class T_str >
template<class T >
void ptc::Print< T_str >::setEnd ( const T &  end_val)
inline

Setter used to set the value of the "end" variable. Templated type is required in order to allow also char variables.

Template Parameters
TThe type of the expression inserted to set the value of "end" variable.
Parameters
end_valThe inserted expression used to set the value of "end" variable.

◆ setFlush()

template<class T_str >
void ptc::Print< T_str >::setFlush ( const bool &  flush_val)
inline

Setter used to set the value of the "flush" variable. Templated type is required in order to allow also char variables.

Parameters
flush_valThe inserted expression used to set the value of the "flush" variable.

◆ setPattern()

template<class T_str >
template<class T >
void ptc::Print< T_str >::setPattern ( const T &  pattern_val)
inline

Setter used to set the value of the "pattern" variable. Templated type is required in order to allow also char variables.

Template Parameters
TThe type of the expression inserted to set the value of "pattern" variable.
Parameters
pattern_valThe inserted expression used to set the value of "pattern" variable.

◆ setSep()

template<class T_str >
template<class T >
void ptc::Print< T_str >::setSep ( const T &  sep_val)
inline

Setter used to set the value of the "sep" variable. Templated type is required in order to allow also char variables.

Template Parameters
TThe type of the expression inserted to set the value of "sep" variable.
Parameters
end_valThe inserted expression used to set the value of "sep" variable.

The documentation for this struct was generated from the following file: