SOFA API  ca665544
Open source framework for multi-physics simuation
sofa::helper::console Namespace Reference

Classes

struct  Foreground
 
struct  Background
 

Typedefs

template<typename T >
using enableStd = typename std::enable_if< std::is_same< T, sofa::helper::console::Style >::value||std::is_same< T, sofa::helper::console::Foreground::Normal >::value||std::is_same< T, sofa::helper::console::Foreground::Bright >::value||std::is_same< T, sofa::helper::console::Background::Normal >::value||std::is_same< T, sofa::helper::console::Background::Bright >::value, std::ostream & >::type
 

Enumerations

enum class  Status { Auto = 0 , On = 1 , Off = 2 }
 
enum class  Style {
  Reset = 0 , Bold = 1 , Dim = 2 , Italic = 3 ,
  Underline = 4 , Blink = 5 , Rblink = 6 , Reversed = 7 ,
  Conceal = 8 , Crossed = 9
}
 

Functions

void setStatus (Status status) noexcept
 
Status getStatus () noexcept
 
size_t getColumnCount ()
 
template<typename T >
enableStd< T > operator<< (std::ostream &os, const T &value)
 to use stream operator with a styled output on any system More...
 

Detailed Description

Utility that manages the output style of a stream into a terminal. It is based heavily on the work of https://github.com/agauniyal/rang

Typedef Documentation

◆ enableStd

template<typename T >
using sofa::helper::console::enableStd = typedef typename std::enable_if< std::is_same<T, sofa::helper::console::Style>::value || std::is_same<T, sofa::helper::console::Foreground::Normal>::value || std::is_same<T, sofa::helper::console::Foreground::Bright>::value || std::is_same<T, sofa::helper::console::Background::Normal>::value || std::is_same<T, sofa::helper::console::Background::Bright>::value, std::ostream &>::type

Enumeration Type Documentation

◆ Status

Enumerator
Auto 
On 
Off 

◆ Style

Enumerator
Reset 
Bold 
Dim 
Italic 
Underline 
Blink 
Rblink 
Reversed 
Conceal 
Crossed 

Function Documentation

◆ getColumnCount()

SOFA_HELPER_API size_t sofa::helper::console::getColumnCount ( )

◆ getStatus()

SOFA_HELPER_API Status sofa::helper::console::getStatus ( )
noexcept

◆ operator<<()

template<typename T >
enableStd<T> sofa::helper::console::operator<< ( std::ostream &  os,
const T &  value 
)
inline

to use stream operator with a styled output on any system

◆ setStatus()

SOFA_HELPER_API void sofa::helper::console::setStatus ( Status  status)
noexcept

Enable or disable colors in stdout / stderr.

This controls whether using styled values in streams will actually do anything. Passing Auto means that styled output will be used for the stream only if it hasn't been redirected (on Unix only). By default, colors are enabled if supported (auto).