cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
String.h File Reference
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
+ Include dependency graph for String.h:

Go to the source code of this file.

Namespaces

namespace  cepgen
 Common namespace for this Monte Carlo generator.
 
namespace  cepgen::utils
 Collection of utilities.
 

Enumerations

enum class  Colour {
  none = -1 , reset = 0 , black = 30 , red = 31 ,
  green = 32 , yellow = 33 , blue = 34 , magenta = 35 ,
  cyan = 36 , white = 37
}
 TTY-type enumeration of colours. More...
 
enum struct  Modifier : int16_t {
  none = -1 , reset = 0 , bold = 1 , dimmed = 1 << 1 ,
  italic = 1 << 2 , underline = 1 << 3 , blink = 1 << 4 , reverse = 1 << 6
}
 

Functions

template<typename T >
std::string toString (const T &obj)
 Transform any type into a string.
 
template<>
std::string toString (const Limits &)
 Specialisation of string conversion of limits.
 
template<>
std::string toString (const ParametersList &)
 Specialisation of string conversion of parameters list.
 
template<>
std::string toString (const std::string &obj)
 Trivial specialisation of string conversion of string.
 
template<>
std::string toString (const double &)
 
template<>
std::string toString (const std::wstring &)
 Convert a wide characters to a standard characters string.
 
std::wstring toWstring (const std::string &str)
 Convert a standard characters to a wide characters string.
 
std::string toCamelCase (const std::string &, bool lower=true)
 Convert any case into a camelCase string.
 
bool isInt (const std::string &)
 Check if a string is also an integer.
 
bool isFloat (const std::string &)
 Check if a string is also a floating point number.
 
template<typename... Args>
std::string format (const std::string &fmt, Args... args)
 Format a string using a printf style format descriptor.
 
template<typename... Args>
std::string format (const std::wstring &fmt, Args... args)
 Format a wide string using a printf style format descriptor.
 
std::string demangle (const char *)
 Demangle a type id if possible.
 
std::string timeAs (const std::string &fmt)
 Return the formatted date/time now.
 
std::string yesno (bool test)
 Human-readable boolean printout Boldify a string for TTY-type output streams.
 
template<typename T >
std::string boldify (T str)
 
std::ostream & operator<< (std::ostream &os, const Colour &col)
 
std::ostream & operator<< (std::ostream &os, const Modifier &mod)
 
Modifier operator| (const Modifier &lhs, const Modifier &rhs)
 
std::string colourise (const std::string &, const Colour &, const Modifier &=Modifier::none)
 Colourise a string for TTY-type output streams.
 
std::string sanitise (const std::string &)
 Replace all unsafe characters to build a computer-readable (and filename-safe) string.
 
std::string parseSpecialChars (const std::string &)
 Transform all emoji-like special characters into their LaTeX representation.
 
size_t replaceAll (std::string &str, const std::string &from, const std::string &to)
 Replace all occurrences of a text by another.
 
std::string replaceAll (const std::string &str, const std::string &from, const std::string &to)
 Replace all occurrences of a text by another.
 
std::string replaceAll (const std::string &str, const std::vector< std::pair< std::string, std::string > > &keys)
 Replace all occurrences of multiple texts by others.
 
std::vector< std::string > split (const std::string &, char, bool trim=false)
 Split a string according to a separation character.
 
template<typename T >
std::string merge (const T &val, const std::string &)
 Merge a a printable type in a single string.
 
template<typename T >
std::string merge (const std::vector< T > &, const std::string &)
 Merge a collection of a printable type in a single string.
 
template<typename T >
std::string merge (const std::vector< std::vector< T > > &, const std::string &)
 Merge a collection of collections of a printable type in a single string.
 
template<typename T , size_t N>
std::string merge (const std::array< T, N > &arr, const std::string &delim)
 Merge a collection of a printable type in a single string.
 
std::string merge (const std::string &val, const std::string &)
 Trivial dimension-1 "merger" for string input.
 
std::string merge (const ParametersList &, const std::string &)
 Trivial dimension-1 "merger" for parameters list input.
 
std::string merge (const Limits &, const std::string &)
 Trivial dimension-1 "merger" for limits input.
 
std::string toUpper (const std::string &)
 Capitalise a string.
 
std::string toLower (const std::string &)
 Lowercase version of a string.
 
std::vector< std::string > between (const std::string &str, const std::string &beg, const std::string &end)
 Get a (list of) substring(s) between two characters chains.
 
std::string s (const std::string &, float, bool=true)
 Add a trailing "s" when needed.
 
template<class T >
std::string repr (const std::vector< T > &vec, const std::function< std::string(const T &)> &printer, const std::string &sep=",")
 Helper to print a vector.
 
template<class T >
std::string repr (const std::vector< T > &vec, const std::string &sep=",")
 Helper to print a vector.
 
std::string randomString (size_t size)
 Generate a random string of a given size.
 
std::string ltrim (const std::string &str)
 Trim leading spaces.
 
std::string rtrim (const std::string &str)
 Trim trailing spaces.
 
std::string trim (const std::string &str)
 Trim leading and trailing spaces.
 
std::string strip (const std::string &)
 Strip all special characters from string.
 
bool startsWith (const std::string &, const std::string &)
 Check if a string starts with a given token.
 
bool endsWith (const std::string &, const std::string &)
 Check if a string ends with a given token.
 
std::string describeError (int errnum)
 Describe an error code.