SyTen
output.h File Reference

Output formatting and helper functions. More...

#include <algorithm>
#include <complex>
#include <iomanip>
#include <limits>
#include <type_traits>
#include <boost/lexical_cast.hpp>
#include "inc/util/shift_args.h"
#include "inc/util/types.h"
#include "inc/util/closeness.h"
#include "inc/util/thresholds.h"
#include "inc/util/time_output.h"
#include "inc/util/scalars.h"
#include "inc/util/vectors.h"
+ Include dependency graph for output.h:
+ This graph shows which files directly or indirectly include this file:

Classes

struct  syten::NOut
 The NOut struct is an ostream that does not output anything. More...
 
struct  syten::Excp::ReadParseError
 Thrown if an error occurs during the parsing with write() More...
 

Namespaces

 syten
 The topmost namespace for this project.
 
 syten::Excp
 Namespace for exceptions otherwise polluting the global syten:: namespace.
 

Functions

std::string syten::concatArg (int argc, char **argv)
 Concatenate elements argv[1…argv-1] into a string separated by spaces. More...
 
template<>
std::string syten::describe_scalar_type< double > ()
 Specialisation of describe_scalar_type() for doubles. More...
 
template<>
std::string syten::describe_scalar_type< float > ()
 Specialisation of describe_scalar_type() for floats. More...
 
template<>
std::string syten::describe_scalar_type< std::complex< double > > ()
 Specialisation of describe_scalar_type() for complex doubles. More...
 
template<>
std::string syten::describe_scalar_type< std::complex< float > > ()
 Specialisation of describe_scalar_type() for complex floats. More...
 
std::ostreamsyten::getErr (bool b)
 Returns std::cerr if b is true, otherwise a dummy output stream. More...
 
std::ostreamsyten::getOut (bool b)
 Returns std::cout if b is true, otherwise a dummy output stream. More...
 
template<typename T >
syten::lexical_cast (std::string const &s)
 Casts the string s to type T, wrapper around boost::lexical_cast<> to silence GCC warning. More...
 
template<typename T >
syten::lexical_cast (const char *const s, std::size_t const n)
 Casts the string [s,s+n] to type T, wrapper around boost::lexical_cast<> to silence GCC warning. More...
 
template<class T >
constexpr auto syten::ostreamshiftable ()
 constexpr function which returns true if a T const& object is shiftable into a std::ostream&. More...
 
template<class T >
constexpr auto syten::ostreamshiftable_imp (int) -> decltype(std::declval< std::ostream &>()<< std::declval< T >(), std::true_type
 Implementation helper for ostreamshiftable(). More...
 
template<class T >
constexpr auto syten::ostreamshiftable_imp (...) -> std::false_type
 Implementation helper for ostreamshiftable(). More...
 
void syten::progress (std::uint64_t i, bool quiet, std::string s="", bool use_error=true)
 Outputs a single character to std::cerr unless quiet. More...
 
template<typename First , typename... Rest>
void syten::read (std::istream &in, First const &f, Rest const &... r)
 Reads a series of values from the provided input stream. More...
 
template<typename T , typename std::enable_if< is_number< T >::value, int >::type = 0>
void syten::read (std::istream &in, T &x)
 Reads a non-complex scalar value from in and stores it in x More...
 
template<typename T >
void syten::read (std::istream &in, std::complex< T > &x)
 Reads a complex scalar value from in and stores it in x More...
 
std::string syten::stripChars (std::string const &input, std::string const &to_remove=" /:")
 Returns the string input with all characters contained in to_remove removed. More...
 
std::string syten::stripEnd (std::string const &a, std::string const &to_strip)
 Strips all occurences of to_strip from the end of a, if possible. More...
 
template<typename Int , typename std::enable_if< std::is_integral< Int >::value, int >::type = 0>
char syten::to_letter (Int const value)
 Given an integral value i, returns the corresponding character from the range [A…Z] taking i%26 More...
 
template<typename Type >
Type syten::to_lower (Type const &in)
 Applies tolower() to each element of the input and returns the output. More...
 
template<typename T >
std::string syten::to_string_def (T const &arg)
 Returns a string representation of the double-representation with default formatting. More...
 
template<typename T >
std::string syten::to_string_def (std::complex< T > const &arg)
 Returns a string representation of the double-representation with default formatting. More...
 
template<typename T >
std::string syten::to_string_rd (T const &arg, int precision=3)
 Returns a string representation of the double-representation of the argument with the given precision applied. More...
 
template<typename T >
std::string syten::to_string_real (T const &arg, int precision=3)
 Write the real part of the argument and the imaginary part only if it is nonzero. More...
 
template<typename T >
std::string syten::to_string_real_def (T const &arg)
 Write the real part of the argument and the imaginary part only if it is nonzero with default formatting. More...
 
template<typename First , typename... Rest>
void syten::write (std::ostream &out, First const &f, Rest const &... r)
 Writes a series of values to the provided output stream. More...
 
template<typename T , typename std::enable_if< is_number< T >::value, int >::type = 0>
void syten::write (std::ostream &out, T const &t)
 Writes a scalar value at the required precision to the specified stream. More...
 

Variables

Output manipulators. Implemented because libstdc++ doesn't have them yet.
constexpr OutFix syten::outFix = OutFix()
 When shifted into an ostream str, changes the output formatting to fixed-point by calling str.setf(std::ios_base::fixed, std::ios_base::floatfield). More...
 
constexpr OutDef syten::outDef = OutDef()
 When shifted into an ostream str, changes the output formatting to the default format by calling str.unsetf(std::ios_base::floatfield). More...
 
constexpr OutSci syten::outSci = OutSci()
 When shifted into an ostream str, changes the output formatting to scientific by calling str.setf(std::ios_base::scientific, std::ios_base::floatfield). More...
 
constexpr OutHex syten::outHex = OutHex()
 When shifted into an ostream str, changes the output formatting to hexadecimal by calling str.setf(std::ios_base::fixed | std::ios_base::scientific, std::ios_base::floatfield). More...
 

Detailed Description

Output formatting and helper functions.