scc 2026.07
SystemC components library
util Namespace Reference

SCC common utilities. More...

Namespaces

namespace  ihex
 A utility class for parsing Intel Hex (IHEX) files.

Classes

struct  BitFieldMember
 bit field element More...
class  BitFieldArray
 array of bit field elements More...
class  bzip2_streambuf
class  bzip2_stream
class  delegate
class  delegate< R(A...)>
 A fast alternative to std::function with improved performance. More...
class  gzip_streambuf
class  gzip_stream
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
 a sparse array suitable for large sizes 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...
class  xz_streambuf
class  xz_stream
class  zstd_streambuf
class  zstd_stream

Enumerations

enum class  file_type_e {
  PLAIN , GZIP , BZIP2 , XZ ,
  ZSTD
}

Functions

uint64_t load_elf_file (std::string const &name, std::function< bool(uint64_t, uint64_t, const uint8_t *)> cb, uint8_t expected_elf_class, uint16_t expected_elf_machine)
std::unordered_map< std::string, uint64_t > read_elf_symbols (std::string const &name, uint8_t expected_elf_class, uint16_t expected_elf_machine)
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)
file_type_e detect_file_type (const std::string &path)
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

Enumeration Type Documentation

◆ file_type_e

enum class util::file_type_e
strong

Definition at line 550 of file ities.h.

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 451 of file ities.h.

◆ bit_count()

size_t util::bit_count ( uint32_t u)
inlineconstexpr

Definition at line 225 of file ities.h.

◆ detect_file_type()

file_type_e util::detect_file_type ( const std::string & path)
inline

Definition at line 552 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 441 of file ities.h.

◆ ends_with()

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

Definition at line 399 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 431 of file ities.h.

◆ find_first()

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

Definition at line 208 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 474 of file ities.h.

◆ hasOddParity()

CONSTEXPR bool util::hasOddParity ( uint32_t u)
inline

Definition at line 272 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 385 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 252 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 306 of file ities.h.

◆ leftmost_one()

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

Definition at line 212 of file ities.h.

◆ load_elf_file()

uint64_t util::load_elf_file ( std::string const & name,
std::function< bool(uint64_t, uint64_t, const uint8_t *)> cb,
uint8_t expected_elf_class,
uint16_t expected_elf_machine )

Definition at line 7 of file elf.cpp.

◆ 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 338 of file ities.h.

◆ make_unique()

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

Definition at line 196 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 413 of file ities.h.

◆ read_elf_symbols()

std::unordered_map< std::string, uint64_t > util::read_elf_symbols ( std::string const & name,
uint8_t expected_elf_class,
uint16_t expected_elf_machine )

Definition at line 37 of file elf.cpp.

◆ 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 460 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 233 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 240 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 348 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 322 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 281 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 364 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 373 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 358 of file ities.h.

◆ uCount()

size_t util::uCount ( uint32_t u)
inlineconstexpr

Definition at line 224 of file ities.h.