scc 2025.09
SystemC components library
util Namespace Reference

SCC common utilities. More...

Classes

struct  BitFieldMember
 bit field element More...
class  BitFieldArray
 array of bit field elements More...
class  delegate
class  delegate< R(A...)>
 A fast alternative to std::function with improved performance. More...
struct  ihex_parser
 A utility class for parsing Intel Hex (IHEX) files. More...
struct  LoggerDelegate
class  InstanceLogger
 InstanceLogger - an instance based logger facade which falls back to the logging based global c++ logger. More...
class  IoRedirector
 allows to capture the strings written to std::cout and std::cerr (MT-safe) More...
class  lz4c_steambuf
class  lz4d_streambuf
class  MT19937
 a Mersenne-Twister pseudo random number generator More...
class  pool_allocator
 a generic pool allocator singleton not being MT-safe More...
class  stl_pool_allocator
class  range_lut
 range based lookup table More...
class  ring_buffer
 Circular buffer. More...
class  sparse_array_b
 a sparse array suitable for large sizes More...
class  sparse_array
 a sparse array suitable for large sizes with compile time constants for performance More...
struct  thread_pool
 a simple thread pool More...
class  thread_syncronizer
 executes a function syncronized in another thread More...
class  watchdog
 a watch dog based on https://github.com/didenko/TimeoutGuard More...

Functions

template<typename T, typename... Args>
std::unique_ptr< T > make_unique (Args &&... args)
template<size_t N>
constexpr size_t find_first (std::bitset< N > &bits)
template<typename T>
leftmost_one (T n)
constexpr size_t uCount (uint32_t u)
constexpr size_t bit_count (uint32_t u)
template<typename T>
CONSTEXPR std::enable_if< std::is_integral< T >::value, T >::type rotl (T n, unsigned int c)
template<typename T>
CONSTEXPR std::enable_if< std::is_integral< T >::value, T >::type rotr (T n, unsigned int c)
CONSTEXPR unsigned ilog2 (uint32_t val)
CONSTEXPR bool hasOddParity (uint32_t u)
std::vector< std::string > split (const std::string &s, char separator)
template<typename Range, typename Value = typename Range::value_type>
std::string join (Range const &elements, char const *const delimiter)
template<typename Input, typename Output, typename Value = typename Output::value_type>
void split (char delimiter, Output &output, Input const &input)
std::string & ltrim (std::string &str, const std::string &chars="\t\n\v\f\r ")
std::string & rtrim (std::string &str, const std::string &chars="\t\n\v\f\r ")
std::string & trim (std::string &str, const std::string &chars="\t\n\v\f\r ")
std::string str_tolower (std::string str)
std::string str_toupper (std::string str)
bool iequals (const std::string &a, const std::string &b)
 compare two string ignoring case
bool ends_with (std::string const &value, std::string const &ending)
std::string padded (std::string str, size_t width, bool show_ellipsis=true)
 pad a string to a given length by either cutting of the overflow or inserting an ellipsis
bool file_exists (const std::string &name)
template<class T>
dir_name (T const &path, T const &delims="/\\")
template<class T>
base_name (T const &path, T const &delims="/\\")
template<class T>
remove_ext (T const &filename)
std::string glob_to_regex (std::string val)
template<typename T>
std::ostream & operator<< (std::ostream &os, range_lut< T > &lut)
std::string strprintf (const std::string format,...)
 allocate and print to a string buffer

Detailed Description

SCC common utilities.

The SystemC Components library (SCC) common utilities.

SCC common utilities

Function Documentation

◆ base_name()

template<class T>
T util::base_name ( T const & path,
T const & delims = "/\\" )
inline

return file name portion of a given path (as string)

Parameters
path
delimsthe path delimiters to use
Returns

Definition at line 434 of file ities.h.

◆ bit_count()

size_t util::bit_count ( uint32_t u)
inlineconstexpr

Definition at line 208 of file ities.h.

◆ dir_name()

template<class T>
T util::dir_name ( T const & path,
T const & delims = "/\\" )
inline

return directory name portion of a given path (as string)

Parameters
path
delimsthe path delimiters to use
Returns

Definition at line 424 of file ities.h.

◆ ends_with()

bool util::ends_with ( std::string const & value,
std::string const & ending )
inline

Definition at line 382 of file ities.h.

◆ file_exists()

bool util::file_exists ( const std::string & name)
inline

checks if a file exists

Parameters
namethe file name
Returns
true if file exists and can be opened

Definition at line 414 of file ities.h.

◆ find_first()

template<size_t N>
size_t util::find_first ( std::bitset< N > & bits)
constexpr

Definition at line 191 of file ities.h.

◆ glob_to_regex()

std::string util::glob_to_regex ( std::string val)
inline

converts a globbing string into a regular expression

The globbing supports ?,*,**, and character classes ([a-z] as well as [!a-z]). '.' acts as hierarchy delimiter and is only matched with ** Regular expression must start with a carret ('^') so that it can be identified as regex.

Parameters
filename
Returns

Definition at line 457 of file ities.h.

◆ hasOddParity()

CONSTEXPR bool util::hasOddParity ( uint32_t u)
inline

Definition at line 255 of file ities.h.

◆ iequals()

bool util::iequals ( const std::string & a,
const std::string & b )
inline

compare two string ignoring case

Parameters
astring a to compare
bstring b to compare
Returns
true if the are equal otherwise false

Definition at line 368 of file ities.h.

◆ ilog2()

CONSTEXPR unsigned util::ilog2 ( uint32_t val)
inline

get the log2 value fo an integer

Parameters
valthe value
Returns
the number of bit needed to hold the value val

Definition at line 235 of file ities.h.

◆ join()

template<typename Range, typename Value = typename Range::value_type>
std::string util::join ( Range const & elements,
char const *const delimiter )

note: delimiter cannot contain NUL characters

Definition at line 289 of file ities.h.

◆ leftmost_one()

template<typename T>
T util::leftmost_one ( T n)

Definition at line 195 of file ities.h.

◆ ltrim()

std::string & util::ltrim ( std::string & str,
const std::string & chars = "\t\n\v\f\r " )
inline

trim the left side of a given string

Parameters
strthe string to trim
charsset of chars to trim away
Returns

Definition at line 321 of file ities.h.

◆ make_unique()

template<typename T, typename... Args>
std::unique_ptr< T > util::make_unique ( Args &&... args)

Definition at line 179 of file ities.h.

◆ operator<<()

template<typename T>
std::ostream & util::operator<< ( std::ostream & os,
range_lut< T > & lut )

overloaded stream operator

Parameters
osthe output stream
lutthe lookup table to print
Returns
the stream

Definition at line 130 of file range_lut.h.

◆ padded()

std::string util::padded ( std::string str,
size_t width,
bool show_ellipsis = true )
inline

pad a string to a given length by either cutting of the overflow or inserting an ellipsis

Parameters
strstring to adjust
widthof the targeted field
show_ellipsisuse ellipsis (...) when shortening
Returns
string with the given length

Definition at line 396 of file ities.h.

◆ remove_ext()

template<class T>
T util::remove_ext ( T const & filename)
inline

return the base name (without extension) of a file name (as string)

Parameters
filename
Returns

Definition at line 443 of file ities.h.

◆ rotl()

template<typename T>
CONSTEXPR std::enable_if< std::is_integral< T >::value, T >::type util::rotl ( T n,
unsigned int c )

Definition at line 216 of file ities.h.

◆ rotr()

template<typename T>
CONSTEXPR std::enable_if< std::is_integral< T >::value, T >::type util::rotr ( T n,
unsigned int c )

Definition at line 223 of file ities.h.

◆ rtrim()

std::string & util::rtrim ( std::string & str,
const std::string & chars = "\t\n\v\f\r " )
inline

trim the right side of a given string

Parameters
strthe string to trim
charsset of chars to trim away
Returns

Definition at line 331 of file ities.h.

◆ split() [1/2]

template<typename Input, typename Output, typename Value = typename Output::value_type>
void util::split ( char delimiter,
Output & output,
Input const & input )

note: imput is assumed to not contain NUL characters

Definition at line 305 of file ities.h.

◆ split() [2/2]

std::vector< std::string > util::split ( const std::string & s,
char separator )
inline

split a given string using specified separator

Parameters
sthe string to split
separatorthe separator char
Returns
vector of splitted strings

Definition at line 264 of file ities.h.

◆ str_tolower()

std::string util::str_tolower ( std::string str)
inline

convert string to lower case

Parameters
strthe string to convert
Returns

Definition at line 347 of file ities.h.

◆ str_toupper()

std::string util::str_toupper ( std::string str)
inline

convert string to upper case

Parameters
strthe string to convert
Returns

Definition at line 356 of file ities.h.

◆ strprintf()

std::string util::strprintf ( const std::string format,
... )
inline

allocate and print to a string buffer

Definition at line 35 of file strprintf.h.

◆ trim()

std::string & util::trim ( std::string & str,
const std::string & chars = "\t\n\v\f\r " )
inline

trim the both sides of a given string

Parameters
strthe string to trim
charsset of chars to trim away
Returns

Definition at line 341 of file ities.h.

◆ uCount()

size_t util::uCount ( uint32_t u)
inlineconstexpr

Definition at line 207 of file ities.h.