C++Spec 1.0.0
BDD testing for C++
Loading...
Searching...
No Matches
CppSpec::Pretty Class Reference

A helper base class that assists in pretty-printing various objects. More...

#include <pretty_matchers.hpp>

Inheritance diagram for CppSpec::Pretty:

Public Member Functions

std::string name (const std::string &name) const
 
std::string name_to_sentence (const std::string &name) const
 
template<typename O>
std::string inspect_object (const O &o)
 Generate a string of the class and data of an object.
 

Static Public Member Functions

static std::string split_words (const std::string &sym)
 
static std::string underscore (const std::string &camel_cased_word)
 
static std::string last (const std::string &s, char delim)
 
static std::string improve_hash_formatting (const std::string &inspect_string)
 
template<Util::is_streamable T>
static std::string to_word (const T &item)
 Formats an object as a string when operator<< is available.
 
template<typename T>
static std::string to_word (const T &item)
 
template<typename T>
static std::string to_word_type (const T &item)
 
template<typename A, typename E>
static std::string to_word (const Matchers::MatcherBase< A, E > &matcher)
 
template<class T>
static std::string to_sentence (const T &item)
 Take a single object and format it as a sentance.
 
template<class T>
static std::string to_sentence (const std::vector< T > &words)
 
template<typename T>
static std::string inspect_object (const T &object)
 
template<>
std::string to_word (const bool &item)
 
template<>
std::string inspect_object (const char *const &o)
 Specialization for C-style strings.
 

Public Attributes

std::string _name
 

Detailed Description

A helper base class that assists in pretty-printing various objects.

This class provides helper string manipulation functions that are used to generate human-readable information and output.

Member Function Documentation

◆ inspect_object() [1/2]

template<>
std::string CppSpec::Pretty::inspect_object ( const char *const & o)
inlinestatic

Specialization for C-style strings.

Parameters
othe input string
Returns
the generated string

◆ inspect_object() [2/2]

template<typename O>
std::string CppSpec::Pretty::inspect_object ( const O & o)
inline

Generate a string of the class and data of an object.

Parameters
othe object to inspect
Returns
the generated string

◆ to_sentence() [1/2]

template<typename T>
std::string CppSpec::Pretty::to_sentence ( const std::vector< T > & objects)
inlinestatic

Takes a vector of objects and formats them as an English style list (i.e. "a, b, and c")

Parameters
wordsthe collection of objects to be processed
Returns
a human-readable comma-delimited list

◆ to_sentence() [2/2]

template<typename T>
std::string CppSpec::Pretty::to_sentence ( const T & item)
inlinestatic

Take a single object and format it as a sentance.

Parameters
itemthe object to be processed
Returns
a human-readable representation of the object (as a list)

◆ to_word() [1/2]

template<typename A, typename E>
std::string CppSpec::Pretty::to_word ( const Matchers::MatcherBase< A, E > & matcher)
inlinestatic

Formats a Matcher as a string

Unlike the generic to_word(), this is specialized for Matchers, which have a custom description associated with them for better information.

Parameters
matcherthe matcher to process
Returns
a string representation of the Matcher

◆ to_word() [2/2]

template<typename T>
std::string CppSpec::Pretty::to_word ( const T & item)
inlinestatic

Formats an object as a string when operator<< is available.

Formats an object as a string when there is no operator<<.

In reality, this uses the << operator, simply providing a way to convert the object to a string without having to deal with stringstreams.

Parameters
itemthe object to be processed
Returns
the string representation
Parameters
itemthe object to be processed
Returns
the string representation

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