gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
util_functions.hpp File Reference

General small utility functions. More...

#include <vector>
#include <chrono>
#include <cmath>
#include "gambit/Utils/util_types.hpp"
#include "gambit/cmake/cmake_variables.hpp"
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include "mkpath/mkpath.h"
Include dependency graph for util_functions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Gambit::Utils::ci_less
 
struct  Gambit::Utils::ci_less::nocase_compare
 

Namespaces

 Gambit
 TODO: see if we can use this one:
 
 Gambit::Utils
 

Functions

template<typename T >
Gambit::byVal (T t)
 Redirection function to turn an lvalue into an rvalue, so that it is correctly passed by value when doing perfect forwarding with functor typecasting. More...
 
template<typename T >
int Gambit::sgn (T val)
 
template<typename T >
uintptr_t Gambit::memaddress_to_uint (T *ptr)
 Convert the memory address a pointer points to to an unsigned integer (The size of uintptr_t depends on system & ensures it is big enough to store memory addresses of the underlying setup) More...
 
EXPORT_SYMBOLS const str & Gambit::Utils::runtime_scratch ()
 Return the path the the run-specific scratch directory. More...
 
EXPORT_SYMBOLS std::vector< str > Gambit::Utils::delimiterSplit (str s, str delim)
 Split a string into a vector of strings, using a delimiter, and removing any whitespace around the delimiter. More...
 
EXPORT_SYMBOLS str Gambit::Utils::strip_leading_namespace (str s, str ns)
 Strips namespace from the start of a string, or after "const". More...
 
EXPORT_SYMBOLS str Gambit::Utils::replace_leading_namespace (str s, str ns, str ns_new)
 Replaces a namespace at the start of a string, or after "const". More...
 
EXPORT_SYMBOLS void Gambit::Utils::strip_whitespace_except_after_const (str &)
 Strip all whitespace except that following "const", in which case the whitespace is replaced by a single space. More...
 
EXPORT_SYMBOLS void Gambit::Utils::strip_parentheses (str &)
 Strips leading and/or trailing parentheses from a string. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::sspairset_contains (const str &, const std::set< sspair > &)
 Test if a set of str,str pairs contains any entry with first element matching a given string. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::sspairset_contains (const str &, const str &, const std::set< sspair > &)
 Tests if a set of str,str pairs contains an entry matching two given strings. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::sspairset_contains (const sspair &, const std::set< sspair > &)
 Tests if a set of str,str pairs contains an entry matching a given pair. More...
 
EXPORT_SYMBOLS str Gambit::Utils::str_fixed_len (str, int)
 Created a str of a specified length. More...
 
EXPORT_SYMBOLS void Gambit::Utils::strcpy2f (char *, int, str)
 Copy a str to a character array, stripping the null termination character. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::endsWith (const std::string &str, const std::string &suffix)
 Checks whether `str' ends with `suffix'. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::startsWith (const std::string &str, const std::string &prefix, bool case_sensitive=true)
 Checks whether `str' begins with `prefix'. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::iequals (const std::string &a, const std::string &b, bool case_sensitive=false)
 Perform a (possibly) case-insensitive string comparison. More...
 
EXPORT_SYMBOLS std::vector< std::string > Gambit::Utils::split (const std::string &input, const std::string &delimiter)
 Split string into vector of strings, using a delimiter string. More...
 
template<typename T , size_t N>
T * Gambit::Utils::beginA (T(&arr)[N])
 Get pointers to beginning and end of array. More...
 
template<typename T , size_t N>
T * Gambit::Utils::endA (T(&arr)[N])
 
template<class Set1 , class Set2 >
bool Gambit::Utils::is_disjoint (const Set1 &set1, const Set2 &set2)
 Test if two sets are disjoint (works on any sorted std container I think) More...
 
EXPORT_SYMBOLS const str & Gambit::Utils::ensure_path_exists (const str &)
 Ensure that a path exists (and then return the path, for chaining purposes) More...
 
EXPORT_SYMBOLS bool Gambit::Utils::file_exists (const std::string &filename)
 Check if a file exists. More...
 
EXPORT_SYMBOLS std::vector< str > Gambit::Utils::ls_dir (const str &dir)
 Return a vector of strings listing the contents of a directory (POSIX) More...
 
EXPORT_SYMBOLS str Gambit::Utils::dir_name (const str &path)
 Get directory name from full path+filename (POSIX) More...
 
EXPORT_SYMBOLS str Gambit::Utils::base_name (const str &path)
 Get file name from full path+filename (POSIX) More...
 
EXPORT_SYMBOLS int Gambit::Utils::remove_all_files_in (const str &dirname, bool error_if_absent=true)
 Delete all files in a directory (does not act recursively) More...
 
time_point Gambit::Utils::get_clock_now ()
 Get clock time. More...
 
EXPORT_SYMBOLS str Gambit::Utils::return_time_and_date (const time_point &in)
 Get date and time. More...
 
EXPORT_SYMBOLS bool Gambit::Utils::are_similar (const str &s1, const str &s2)
 Check if two strings are a "close" match Used for "did you mean?" type checking during command line argument processing. More...
 
bool Gambit::Utils::check1 (const str &s1, const str &s2)
 Sub-check for are_similar. More...
 
bool Gambit::Utils::check2 (const str &s1, const str &s2)
 Sub-check for are_similar. More...
 
EXPORT_SYMBOLS double Gambit::Utils::sqr (double a)
 returns square of double - saves tedious repetition More...
 
EXPORT_SYMBOLS bool Gambit::Utils::isInteger (const std::string &)
 Check if a string represents an integer From: http://stackoverflow.com/a/2845275/1447953. More...
 
template<typename T >
int Gambit::Utils::sgn (T val)
 Get the sign of a (hopefully numeric type) More...
 
template<typename... T>
void Gambit::Utils::dummy_function ()
 
template<typename T >
void Gambit::Utils::dummy_function (T one)
 
template<typename T1 , typename... T>
void Gambit::Utils::dummy_function (T1 first, T... args)
 

Variables

const str Gambit::Utils::buildtime_scratch = GAMBIT_DIR "/scratch/build_time/"
 Return the path to the build-time scratch directory. More...
 

Detailed Description

General small utility functions.


Authors (add name and date if you modify):

Author
Pat Scott (patsc.nosp@m.ott@.nosp@m.physi.nosp@m.cs.m.nosp@m.cgill.nosp@m..ca)
Date
2013 Apr, July, Aug, Dec
2014 Mar
2015 Apr
Author
Ben Farmer (benja.nosp@m.min..nosp@m.farme.nosp@m.r@mo.nosp@m.nash..nosp@m.edu..nosp@m.au)
Date
2013 May, June, July

Definition in file util_functions.hpp.