User Guide
|
Utility classes and function implementation. More...
Utility classes and function implementation.
Classes | |
class | nmodl::utils::SingletonRandomString< SIZE > |
Singleton class for random strings. More... | |
struct | nmodl::utils::PerfStat |
Helper class to collect performance statistics. More... | |
class | nmodl::utils::TableData |
Class to construct and pretty-print tabular data. More... | |
Enumerations | |
enum | nmodl::utils::UseNumbersInString : bool { nmodl::utils::WithNumbers = true, nmodl::utils::WithoutNumbers = false } |
Enum to wrap bool variable to select if random string should have numbers or not. More... | |
enum | nmodl::stringutils::text_alignment { nmodl::stringutils::text_alignment::left, nmodl::stringutils::text_alignment::right, nmodl::stringutils::text_alignment::center } |
text alignment when printing in the tabular form More... | |
Functions | |
template<typename Iter , typename Cont > | |
bool | nmodl::utils::is_last (Iter iter, const Cont &cont) |
Check if the iterator is pointing to last element in the container. More... | |
std::string | nmodl::utils::generate_random_string (int len, UseNumbersInString use_numbers) |
Generate random std::string of length len based on a uniform distribution. More... | |
static std::string | nmodl::stringutils::ltrim (std::string text) |
static std::string | nmodl::stringutils::rtrim (std::string text) |
static std::string | nmodl::stringutils::trim (std::string text) |
static std::string | nmodl::stringutils::remove_character (std::string text, const char c) |
Remove all occurrences of a given character in a text. More... | |
static std::string | nmodl::stringutils::trim_newline (std::string text) |
static std::string | nmodl::stringutils::escape_quotes (const std::string &text) |
Escape double-quote in a text, useful for JSON pretty printer. More... | |
static std::vector< std::string > | nmodl::stringutils::split_string (const std::string &text, char delimiter) |
Split a text in a list of words, using a given delimiter character. More... | |
static bool | nmodl::stringutils::ends_with (const std::string &haystack, const std::string &needle) |
Check if haystack ends with needle . More... | |
static bool | nmodl::stringutils::starts_with (const std::string &haystack, const std::string &needle) |
Check if haystack starts with needle . More... | |
static std::string | nmodl::stringutils::align_text (const std::string &text, int width, text_alignment type) |
Aligns a text within a field of width width. More... | |
static std::string | nmodl::stringutils::tolower (std::string text) |
To lower case. More... | |
std::string | nmodl::stringutils::to_string (double value, const std::string &format_spec="{:.16g}") |
Convert double value to string without trailing zeros. More... | |
std::string | nmodl::stringutils::join_arguments (const std::string &lhs, const std::string &rhs) |
Joint two (list of) arguments. More... | |
Variables | |
static constexpr char | nmodl::utils::envpathsep {':'} |
The character conventionally used by the operating system to separate search path components. More... | |
|
strong |
text alignment when printing in the tabular form
Enumerator | |
---|---|
left | |
right | |
center |
Definition at line 35 of file string_utils.hpp.
enum nmodl::utils::UseNumbersInString : bool |
Enum to wrap bool variable to select if random string should have numbers or not.
Enumerator | |
---|---|
WithNumbers | |
WithoutNumbers |
Definition at line 51 of file common_utils.hpp.
|
inlinestatic |
Aligns a text within a field of width width.
text | the string to manipulate |
width | the width of the field |
type | the kind of alignment Left, Right, or Center |
left and right spacing
count excess room to pad
if odd #, add one more space
Definition at line 167 of file string_utils.hpp.
|
inlinestatic |
Check if haystack
ends with needle
.
The empty string is a suffix of every string.
Definition at line 135 of file string_utils.hpp.
|
inlinestatic |
Escape double-quote in a text, useful for JSON pretty printer.
text | the string to manipulate |
don't break here as we want to append actual character
Definition at line 92 of file string_utils.hpp.
std::string nmodl::utils::generate_random_string | ( | const int | len, |
UseNumbersInString | use_numbers | ||
) |
Generate random std::string of length len based on a uniform distribution.
Definition at line 27 of file common_utils.cpp.
bool nmodl::utils::is_last | ( | Iter | iter, |
const Cont & | cont | ||
) |
Check if the iterator is pointing to last element in the container.
Definition at line 37 of file common_utils.hpp.
std::string nmodl::stringutils::join_arguments | ( | const std::string & | lhs, |
const std::string & | rhs | ||
) |
Joint two (list of) arguments.
The tricks is to not add a ',' when either side is empty.
Definition at line 30 of file string_utils.cpp.
|
inlinestatic |
text | the string to manipulate |
Definition at line 41 of file string_utils.hpp.
|
inlinestatic |
Remove all occurrences of a given character in a text.
text | the string to manipulate |
c | the character to remove |
Definition at line 73 of file string_utils.hpp.
|
inlinestatic |
text | the string to manipulate |
Definition at line 51 of file string_utils.hpp.
|
inlinestatic |
Split a text in a list of words, using a given delimiter character.
text | the string to manipulate |
delimiter | the delimiter character |
Definition at line 116 of file string_utils.hpp.
|
inlinestatic |
Check if haystack
starts with needle
.
The empty string is a prefix of every string.
Definition at line 154 of file string_utils.hpp.
std::string nmodl::stringutils::to_string | ( | double | value, |
const std::string & | format_spec = "{:.16g}" |
||
) |
Convert double value to string without trailing zeros.
When we use std::to_string with double value 1 then it gets printed as 1.000000
. This is not convenient for testing and testing/validation. To avoid this issue, we use to_string for integer values and stringstream for the rest.
Definition at line 18 of file string_utils.cpp.
|
inlinestatic |
To lower case.
text | the string to manipulate |
Definition at line 198 of file string_utils.hpp.
|
inlinestatic |
text | the string to manipulate |
Definition at line 63 of file string_utils.hpp.
|
inlinestatic |
text | the string to manipulate |
Definition at line 83 of file string_utils.hpp.
|
staticconstexpr |
The character conventionally used by the operating system to separate search path components.
Definition at line 46 of file common_utils.hpp.