dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Utility.hpp File Reference

Miscellaneous small utility helpers (strings, parsing, formatting). More...

Include dependency graph for Utility.hpp:

Go to the source code of this file.

Functions

std::vector< std::string > dfx::Utils::split (std::string const &str, std::string_view sep=" ", bool skipEmpty=true, bool shouldTrim=false)
 Split a string into substrings separated by sep.
std::vector< std::string_view > dfx::Utils::splitView (std::string_view str, std::string_view sep=" ", bool skipEmpty=true, bool shouldTrim=false)
 Split a string view into substring views separated by sep.
std::string dfx::Utils::toLower (std::string_view str)
 Convert a string to lower case.
std::string dfx::Utils::toUpper (std::string_view str)
 Convert a string to upper case.
std::string & dfx::Utils::ltrim (std::string &s) noexcept
 Trim leading whitespace from a string in-place.
std::string & dfx::Utils::rtrim (std::string &s) noexcept
 Trim trailing whitespace from a string in-place.
std::string & dfx::Utils::trim (std::string &s) noexcept
 Trim leading and trailing whitespace from a string in-place.
std::string_view & dfx::Utils::trimView (std::string_view &str) noexcept
 Trim leading and trailing whitespace from a string view by adjusting its boundaries.
template<typename T1, typename T2>
bool dfx::Utils::isOneOf (T1 val, std::initializer_list< T2 const > list)
 Test whether val is equal to one of the elements in list.
template<typename T1, typename T2>
bool dfx::Utils::isOneOf (T1 val, std::span< T2 const > list)
 Test whether val is equal to one of the elements in list.
std::string dfx::Utils::formatBytes (std::uint64_t byteCount, std::size_t precision=2)
 Format a byte count as a human-readable string.
std::optional< bool > dfx::Utils::boolFromString (std::string_view str) noexcept
 Parse a boolean value from text.
std::string_view dfx::Utils::boolToString (bool value) noexcept
 Convert a boolean value to a stable textual representation.
std::string_view dfx::Utils::strsignal (int sig) noexcept
 Convert a signal number to a stringified version.

Detailed Description

Miscellaneous small utility helpers (strings, parsing, formatting).

This header groups small helpers commonly used across the project:

  • String splitting and timming (owning and view-based)
  • Human-readable formatting for byte sizes
  • Parsing/formatting of boolean values
  • ...

The functions here are intentionally lightweight and dependency-free.