Stride Reference Manual  - generated for commit 9643b11
stride::util Namespace Reference

Utilities for the project. More...

Namespaces

 detail
 
 ii_detail
 

Classes

struct  BoxPlotData
 BoxPlotData calculates total, minimum, maximum, median, lower and upper quartile of the values in the vector. More...
 
class  ConfigInfo
 Config information. More...
 
class  CSV
 A collection of CSVRow elements. More...
 
class  CSVRow
 Row in CSV file. More...
 
class  Exception
 Basic exception class: needed to prevent clang-tidy warning "thrown exception type is not nothrow copy constructible". More...
 
class  FileSys
 Utilities for interaction with filesystem. More...
 
struct  is_iterator
 When it 's not an iterator. More...
 
struct  is_iterator< T, ii_detail::void_t< typename std::iterator_traits< T >::iterator_category > >
 When it is an iterator. More...
 
class  LogUtils
 Utilities for logging (spdlog). More...
 
class  Rn
 Manages random number generation in parallel (OpenMP) calculations. More...
 
struct  RnInfo
 Information on random number management state. More...
 
class  RnMan
 
class  RunConfigManager
 Produce run config ptree. More...
 
class  SegmentedVector
 Container that stores objects "almost contiguously" (in a chain of blocks) and guarantees that pointers/iterators are not invalidated when the container grows. More...
 
class  SliceIndexer
 Datastructure to index a container (supporting RandomAccessIterators) with slices. More...
 
class  Stopwatch
 Provides a stopwatch interface to time: it accumulates time between start/stop pairs. More...
 
class  Subject
 Template for Subject/Observer (or Publish/Subscribe). More...
 
class  SVIterator
 Implementation of iterator for SegmentedVector. More...
 
class  TimeStamp
 Provides wall-clock time stamp using the time call. More...
 
struct  TimeToString
 Utilities to tag clocks and to reformat number of ticks to a string. More...
 

Functions

std::string AssertMessage (const char *condition, const std::string &message, const std::shared_ptr< spdlog::logger > &logger, const char *file, int line)
 
std::ofstream & operator<< (std::ofstream &ofs, const CSV &csv)
 
template<>
std::string CSVRow::GetValue< std::string > (size_t index) const
 specialization for string More...
 
template<>
std::string CSVRow::GetValue< std::string > (const std::string &label) const
 specialization for string More...
 
std::ostream & operator<< (std::ostream &os, const CSVRow &row)
 
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
safe_cast (const std::string &val)
 Converts a string to an arithmetic type, in a safe manner. More...
 
template<class Sequence >
Sequence ToSequence (const boost::property_tree::ptree &ptree)
 
template<class T , std::size_t N>
std::array< T, N > ToArray (const boost::property_tree::ptree &ptree)
 
template<class Ptree >
Ptree Merge (const Ptree &pt1, const Ptree &pt2)
 
std::ostream & operator<< (std::ostream &os, const RnInfo &info)
 
template<typename T , size_t N = 512, bool Safe = true>
bool operator== (const SegmentedVector< T, N, Safe > &lhs, const SegmentedVector< T, N, Safe > &rhs)
 Helper function for equality test (equal size and all elements equal). More...
 
template<typename T , size_t N = 512, bool Safe = true>
bool operator!= (const SegmentedVector< T, N, Safe > &lhs, const SegmentedVector< T, N, Safe > &rhs)
 Helper function for inequality test (unequal size or not all elements equal). More...
 
template<typename T >
SliceIndexer< T > make_slice_indexer (T &t)
 
template<typename T >
std::ostream & operator<< (std::ostream &oss, Stopwatch< T > const &stopwatch)
 Insert accumulated time into output stream without altering stopwatch state. More...
 
bool CheckAllDigits (const std::string &s)
 All characters in string are digits (or string is empty) More...
 
template<typename T >
FromString (const std::string &s)
 Builds a value of type T representation from a string. More...
 
std::vector< std::string > Split (const std::string &s, const std::string &delimiters)
 Split a string (in order of occurence) by splitting it on the given delimiters. More...
 
std::vector< std::string > Tokenize (const std::string &str, const std::string &delimiters)
 Tokenize a string (in order of occurence) with the given delimiters. More...
 
template<typename T >
std::string ToString (const T &value)
 Builds a string representation of a value of type T. More...
 
template<>
std::string ToString< std::string > (const std::string &value)
 
template<typename It >
std::vector< std::string > ToString (typename std::enable_if<!std::is_same< typename It::value_type, std::string >::value, It >::type first, It last)
 Stringify values (that are not strings) in a range and put them in a vector. More...
 
template<typename It >
std::vector< std::string > ToString (typename std::enable_if< std::is_same< typename It::value_type, std::string >::value, It >::type first, It last)
 Stringify values (that are strings - so no-op) in a range and put them in a vector. More...
 
template<typename T >
std::string ToString (const T &value, int width, char fill= ' ')
 Builds a string representation with minimum width of a value of type T. More...
 
std::string ToLower (const std::string &source)
 Builds a string with lower case characters only. More...
 
std::string ToUpper (const std::string &source)
 Builds a string with upper case characters only. More...
 
std::string TrimRight (const std::string &source, const std::string &t=" ")
 Trim characters at right end of string. More...
 
std::string TrimLeft (const std::string &source, const std::string &t=" ")
 Trim characters at left end of string. More...
 
std::string Trim (const std::string &source, const std::string &t=" ")
 Trim characters at both ends of string. More...
 
template<typename T >
std::string intToDottedString (const T &value)
 
template<typename T , std::size_t N, bool Safe, typename P = const T*, typename R = const T&, bool is_const_iterator = true>
SVIterator< T, N, Safe, P, R, is_const_iterator > operator+ (std::ptrdiff_t i, SVIterator< T, N, Safe, P, R, is_const_iterator > p)
 
template<typename T , std::size_t N, bool Safe, typename P = const T*, typename R = const T&, bool is_const_iterator = true>
SVIterator< T, N, Safe, P, R, is_const_iterator > operator- (std::ptrdiff_t i, SVIterator< T, N, Safe, P, R, is_const_iterator > p)
 
std::ostream & operator<< (std::ostream &os, TimeStamp t)
 TimeStamp helper inserts string representation in output stream. More...
 

Detailed Description

Utilities for the project.

Function Documentation

std::string stride::util::AssertMessage ( const char *  condition,
const std::string &  message,
const std::shared_ptr< spdlog::logger > &  logger,
const char *  file,
int  line 
)
inline

Definition at line 33 of file Assert.h.

std::ofstream& stride::util::operator<< ( std::ofstream &  ofs,
const CSV csv 
)
inline

Definition at line 134 of file CSV.h.

References stride::util::CSV::WriteLabels(), and stride::util::CSV::WriteRows().

Here is the call graph for this function:

template<>
std::string stride::util::CSVRow::GetValue< std::string > ( size_t  index) const

specialization for string

Declaration of specialization.

Definition at line 54 of file CSVRow.cpp.

References stride::util::CSV::GetColumnCount(), stride::util::CSVRow::m_parent, stride::util::CSVRow::m_values, and ToString().

Here is the call graph for this function:

template<>
std::string stride::util::CSVRow::GetValue< std::string > ( const std::string &  label) const

specialization for string

Declaration of specialization.

Definition at line 64 of file CSVRow.cpp.

References stride::util::CSV::GetIndexForLabel(), stride::util::CSVRow::GetValue(), and stride::util::CSVRow::m_parent.

Here is the call graph for this function:

std::ostream& stride::util::operator<< ( std::ostream &  os,
const CSVRow row 
)

Definition at line 72 of file CSVRow.cpp.

References stride::util::CSVRow::m_values.

template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0>
T stride::util::safe_cast ( const std::string &  val)
inline

Converts a string to an arithmetic type, in a safe manner.

Converts a string to a type.

Exceptions
bad_lexical_castif val can't be converted to a double or int
bad_numeric_castif val can't be converted to T
Template Parameters
Tthe type to safe cast to
Parameters
valthe value to cast
Returns
Exceptions
bad_lexical_castif val can't be converted to T
Template Parameters
Tthe type to safe cast to
Parameters
valthe value to cast
Returns

Definition at line 74 of file CSVRow.h.

Referenced by stride::util::CSVRow::GetValue().

Here is the caller graph for this function:

template<class Sequence >
Sequence stride::util::ToSequence ( const boost::property_tree::ptree &  ptree)

Definition at line 49 of file PtreeUtils.h.

template<class T , std::size_t N>
std::array<T, N> stride::util::ToArray ( const boost::property_tree::ptree &  ptree)

Definition at line 61 of file PtreeUtils.h.

template<class Ptree >
Ptree stride::util::Merge ( const Ptree &  pt1,
const Ptree &  pt2 
)

Definition at line 78 of file PtreeUtils.h.

std::ostream& stride::util::operator<< ( std::ostream &  os,
const RnInfo info 
)
inline
template<typename T , size_t N = 512, bool Safe = true>
bool stride::util::operator== ( const SegmentedVector< T, N, Safe > &  lhs,
const SegmentedVector< T, N, Safe > &  rhs 
)
inline

Helper function for equality test (equal size and all elements equal).

Definition at line 365 of file SegmentedVector.h.

References stride::util::SegmentedVector< T, N, Safe >::cbegin(), and stride::util::SegmentedVector< T, N, Safe >::cend().

Referenced by operator!=().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T , size_t N = 512, bool Safe = true>
bool stride::util::operator!= ( const SegmentedVector< T, N, Safe > &  lhs,
const SegmentedVector< T, N, Safe > &  rhs 
)
inline

Helper function for inequality test (unequal size or not all elements equal).

Definition at line 374 of file SegmentedVector.h.

References operator==().

Here is the call graph for this function:

template<typename T >
SliceIndexer<T> stride::util::make_slice_indexer ( T &  t)

Definition at line 97 of file SliceIndexer.h.

template<typename T >
std::ostream& stride::util::operator<< ( std::ostream &  oss,
Stopwatch< T > const &  stopwatch 
)

Insert accumulated time into output stream without altering stopwatch state.

Definition at line 125 of file Stopwatch.h.

bool stride::util::CheckAllDigits ( const std::string &  s)
inline

All characters in string are digits (or string is empty)

Definition at line 36 of file StringUtils.h.

Referenced by stride::util::Rn< E >::Initialize().

Here is the caller graph for this function:

template<typename T >
T stride::util::FromString ( const std::string &  s)
inline

Builds a value of type T representation from a string.

Definition at line 49 of file StringUtils.h.

Referenced by stride::util::RunConfigManager::AddGeoPopConfig(), and stride::util::RunConfigManager::Create().

Here is the caller graph for this function:

std::vector<std::string> stride::util::Split ( const std::string &  s,
const std::string &  delimiters 
)
inline

Split a string (in order of occurence) by splitting it on the given delimiters.

Definition at line 58 of file StringUtils.h.

Referenced by stride::util::Rn< E >::Initialize(), stride::DefaultPopBuilder::MakePersons(), and stride::util::CSV::ReadFromStream().

Here is the caller graph for this function:

std::vector<std::string> stride::util::Tokenize ( const std::string &  str,
const std::string &  delimiters 
)
inline

Tokenize a string (in order of occurence) with the given delimiters.

Multiple consecutive delimiters do NOT define "empty" tokens; they are skipped.

Definition at line 67 of file StringUtils.h.

Referenced by main().

Here is the caller graph for this function:

template<typename T >
std::string stride::util::ToString ( const T &  value)
inline

Builds a string representation of a value of type T.

Definition at line 90 of file StringUtils.h.

Referenced by stride::util::CSV::AddRow(), stride::util::CSV::CSV(), stride::util::CSVRow::CSVRow(), CSVRow::GetValue< std::string >(), and ToString().

Here is the caller graph for this function:

template<>
std::string stride::util::ToString< std::string > ( const std::string &  value)
inline

Definition at line 98 of file StringUtils.h.

template<typename It >
std::vector<std::string> stride::util::ToString ( typename std::enable_if<!std::is_same< typename It::value_type, std::string >::value, It >::type  first,
It  last 
)
inline

Stringify values (that are not strings) in a range and put them in a vector.

Definition at line 105 of file StringUtils.h.

References ToString().

Here is the call graph for this function:

template<typename It >
std::vector<std::string> stride::util::ToString ( typename std::enable_if< std::is_same< typename It::value_type, std::string >::value, It >::type  first,
It  last 
)
inline

Stringify values (that are strings - so no-op) in a range and put them in a vector.

Definition at line 117 of file StringUtils.h.

template<typename T >
std::string stride::util::ToString ( const T &  value,
int  width,
char  fill = ' ' 
)
inline

Builds a string representation with minimum width of a value of type T.

Definition at line 127 of file StringUtils.h.

std::string stride::util::ToLower ( const std::string &  source)
inline

Builds a string with lower case characters only.

Definition at line 135 of file StringUtils.h.

Referenced by stride::util::FileSys::Initialize(), and stride::DiseaseSeeder::Vaccinate().

Here is the caller graph for this function:

std::string stride::util::ToUpper ( const std::string &  source)
inline

Builds a string with upper case characters only.

Definition at line 144 of file StringUtils.h.

std::string stride::util::TrimRight ( const std::string &  source,
const std::string &  t = " " 
)
inline

Trim characters at right end of string.

Definition at line 153 of file StringUtils.h.

Referenced by Trim().

Here is the caller graph for this function:

std::string stride::util::TrimLeft ( const std::string &  source,
const std::string &  t = " " 
)
inline

Trim characters at left end of string.

Definition at line 160 of file StringUtils.h.

Referenced by Trim().

Here is the caller graph for this function:

std::string stride::util::Trim ( const std::string &  source,
const std::string &  t = " " 
)
inline

Trim characters at both ends of string.

Definition at line 167 of file StringUtils.h.

References TrimLeft(), and TrimRight().

Referenced by stride::util::CSVRow::CSVRow(), and stride::util::CSV::ReadFromStream().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
std::string stride::util::intToDottedString ( const T &  value)
inline

Definition at line 173 of file StringUtils.h.

Referenced by geopop::operator<<().

Here is the caller graph for this function:

template<typename T , std::size_t N, bool Safe, typename P = const T*, typename R = const T&, bool is_const_iterator = true>
SVIterator<T, N, Safe, P, R, is_const_iterator> stride::util::operator+ ( std::ptrdiff_t  i,
SVIterator< T, N, Safe, P, R, is_const_iterator >  p 
)

Definition at line 253 of file SVIterator.h.

template<typename T , std::size_t N, bool Safe, typename P = const T*, typename R = const T&, bool is_const_iterator = true>
SVIterator<T, N, Safe, P, R, is_const_iterator> stride::util::operator- ( std::ptrdiff_t  i,
SVIterator< T, N, Safe, P, R, is_const_iterator >  p 
)

Definition at line 261 of file SVIterator.h.

std::ostream& stride::util::operator<< ( std::ostream &  os,
TimeStamp  t 
)
inline

TimeStamp helper inserts string representation in output stream.

Definition at line 53 of file TimeStamp.h.

References stride::util::TimeStamp::ToString().

Here is the call graph for this function: