12 #include <string_view>
14 #include <rapidsmpf/utils/misc.hpp>
24 std::string
trim(std::string_view text);
241 template <
typename T>
243 std::stringstream sstream(text);
246 if (sstream.fail()) {
247 throw std::invalid_argument(
"cannot parse \"" + std::string{text} +
"\"");
RAPIDS Multi-Processor interfaces.
TrimZeroFraction
Control whether a zero fractional part is omitted when formatting values.
@ YES
Omit the fractional part when it consists only of zeros.
@ NO
Always keep the fractional part.
std::optional< std::string > parse_optional(std::string text)
Parse an optional string value.
std::int64_t parse_nbytes(std::string_view text)
Parse a human-readable byte count into an integer number of bytes.
std::size_t parse_nbytes_or_percent(std::string_view text, double total_bytes)
Parse a byte quantity or percentage into an absolute byte count.
std::vector< std::string > parse_string_list(std::string_view text, char delimiter=',')
Parse a delimited string into a list of trimmed substrings.
std::chrono::duration< double > Duration
Alias for a duration type representing time in seconds as a double.
std::string format_nbytes(double nbytes, int num_decimals=2, TrimZeroFraction trim_zero_fraction=TrimZeroFraction::YES)
Format a byte count as a human-readable string using IEC units.
std::string to_lower(std::string_view text)
Converts the specified string to lowercase.
std::size_t parse_nbytes_unsigned(std::string_view text)
Parse a human-readable byte count into a non-negative number of bytes.
std::string to_upper(std::string_view text)
Converts the specified string to uppercase.
Duration parse_duration(std::string_view text)
Parse a human-readable time duration into seconds.
std::string format_duration(double seconds, int precision=2, TrimZeroFraction trim_zero_fraction=TrimZeroFraction::YES)
Format a time duration as a human-readable string.
std::string trim(std::string_view text)
Trims whitespace from both ends of the specified string.
T parse_string(std::string const &text)
Specialization of parse_string for boolean values.