cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
String.cpp File Reference
#include <stdio.h>
#include <unistd.h>
#include <codecvt>
#include <cstdint>
#include <locale>
#include <unordered_set>
#include "CepGen/Core/ParametersList.h"
#include "CepGen/Utils/Message.h"
#include "CepGen/Utils/String.h"
#include <cstring>
+ Include dependency graph for String.cpp:

Go to the source code of this file.

Namespaces

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

Macros

#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define DEF_COLOUR(col)
 
#define DEF_MODIFIER(mod)
 

Functions

std::regex kFloatRegex ("[+-]?[0-9]*\\.?[0-9]+([eEdD][+-]?[0-9]+)?", std::regex_constants::extended)
 
std::string yesno (bool test)
 Human-readable boolean printout Boldify a string for TTY-type output streams.
 
template<>
std::string boldify (std::string str)
 String implementation of the boldification procedure.
 
template<>
std::string boldify (const char *str)
 C-style character array implementation of the boldification procedure.
 
template<>
std::string boldify (unsigned long ui)
 Unsigned long integer implementation of the boldification procedure.
 
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 parseSpecialChars (const std::string &)
 Transform all emoji-like special characters into their LaTeX representation.
 
std::string sanitise (const std::string &)
 Replace all unsafe characters to build a computer-readable (and filename-safe) string.
 
std::string timeAs (const std::string &fmt)
 Return the formatted date/time now.
 
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.
 
template<>
std::string toString (const std::wstring &str)
 Convert a wide characters to a standard characters string.
 
template<>
std::string toString (const ParametersList &params)
 Specialisation of string conversion of parameters list.
 
template<>
std::string toString (const Limits &lim)
 Specialisation of string conversion of limits.
 
std::wstring toWstring (const std::string &str)
 Convert a standard characters to a wide characters string.
 
template<>
std::string toString (const double &val)
 
std::string toCamelCase (const std::string &, bool lower=true)
 Convert any case into a camelCase string.
 
std::string randomString (size_t size)
 Generate a random string of a given size.
 
std::string s (const std::string &, float, bool=true)
 Add a trailing "s" when needed.
 
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 std::vector< T > &, const std::string &)
 Merge a collection of a printable type in a single string.
 
template std::string merge< std::string > (const std::vector< std::string > &, const std::string &)
 
template std::string merge< Limits > (const std::vector< Limits > &, const std::string &)
 
template std::string merge< unsigned short > (const std::vector< unsigned short > &, const std::string &)
 
template std::string merge< int > (const std::vector< int > &, const std::string &)
 
template std::string merge< unsigned long long > (const std::vector< unsigned long long > &, const std::string &)
 
template std::string merge< double > (const std::vector< double > &, const std::string &)
 
template std::string merge< ParametersList > (const std::vector< ParametersList > &, const std::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 std::string merge< double > (const std::vector< std::vector< double > > &, const std::string &)
 
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.
 
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.
 
std::string toUpper (const std::string &)
 Capitalise a string.
 
std::string toLower (const std::string &)
 Lowercase version of a string.
 
template<typename T >
void normalise (std::vector< T > &coll)
 Remove duplicates and sort a collection.
 
template void normalise (std::vector< std::string > &)
 
std::string ltrim (const std::string &str)
 Trim leading spaces.
 
std::string rtrim (const std::string &str)
 Trim trailing spaces.
 
std::string strip (const std::string &)
 Strip all special characters from string.
 
std::string demangle (const char *)
 Demangle a type id if possible.
 
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.
 
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.
 
std::ostream & operator<< (std::ostream &os, const Colour &col)
 
std::ostream & operator<< (std::ostream &os, const Modifier &mod)
 

Macro Definition Documentation

◆ DEF_COLOUR

#define DEF_COLOUR (   col)
Value:
case Colour::col: \
return os << colourise(TOSTRING(col), Colour::col);
#define TOSTRING(x)
Definition String.cpp:383

Definition at line 384 of file String.cpp.

◆ DEF_MODIFIER

#define DEF_MODIFIER (   mod)
Value:
case Modifier::mod: \
return os << colourise(TOSTRING(mod), Colour::none, Modifier::mod);

Definition at line 387 of file String.cpp.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Definition at line 382 of file String.cpp.

◆ TOSTRING

#define TOSTRING (   x)    STRINGIFY(x)

Definition at line 383 of file String.cpp.