![]() |
open_iA 2021.08
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
|
#include "iAbase_export.h"#include "iALog.h"#include <QString>#include <QStringList>#include <QVariant>#include <QVector>#include <cassert>Classes | |
| struct | iAConverter< T > |
| Class for converting a variable of the type QString to the templated type. More... | |
| struct | iAConverter< double > |
| struct | iAConverter< int > |
| struct | iAConverter< unsigned short > |
Functions | |
| template<typename T > | |
| QString | arrayToString (T const *arr, size_t size, QString const &sep=" ") |
| Convert a given array with specified number of elements to a string representation. More... | |
| iAbase_API QString | dblToStringWithUnits (double value, double switchFactor=999) |
| returns the value converted to string, with units (K, M, G, T, P) applied for every 10³ factor over 1000 More... | |
| iAbase_API int | digitsAfterComma (double resolvableDiff) |
| Get the number of digits required after the comma, given the difference to other values it should be distinguishable from. More... | |
| iAbase_API QString | greatestCommonPrefix (QString const &str1, QString const &str2) |
| iAbase_API int | greatestCommonPrefixLength (QString const &str1, QString const &str2) |
| Find the (length of the) greatest common prefix of the two given strings. More... | |
| iAbase_API QString | greatestCommonSuffix (QString const &str1, QString const &str2) |
| iAbase_API int | greatestCommonSuffixLength (QString const &str1, QString const &str2) |
| template<template< typename... > class Container, typename Element , typename FnType > | |
| QString | joinAsString (Container< Element > const &vec, QString const &joinStr, FnType lambda) |
| join any list as string - the conversion of the single items happens via the passed-in lambda FnType is something like a function taking an Element parameter and has a QString(-compatible) return type; tried QString fct(Element const &) but it doesn't work as expected More... | |
| template<template< typename... > class Container, typename Element > | |
| QString | joinNumbersAsString (Container< Element > const &vec, QString const &joinStr) |
| join an iterable collection of numeric elements to a string More... | |
| iAbase_API QString | joinQVariantAsString (QVector< QVariant > const &vec, QString const &joinStr) |
| iAbase_API QString | padOrTruncate (QString const &str, int size) |
| Pads or truncates the given string to the given size. More... | |
| iAbase_API QString | quoteString (QString const &str) |
| iAbase_API int | requiredDigits (double value) |
| Get the number of digits required for the given number (before the comma). More... | |
| iAbase_API QStringList | splitPossiblyQuotedString (QString const &str) |
| split a string at the space characters, while correctly treating quoted elements More... | |
| template<typename T > | |
| bool | stringToArray (QString const &str, T *arr, int expectedSize, QString const &sep=" ") |
| Convert a given string representation to an array of given type with given number of elements. More... | |
| template<typename ContainerT , typename ElementT > | |
| ContainerT | stringToVector (QString const &listAsString, QString const &separator=",", int maxItems=std::numeric_limits< int >::max(), bool warnWhenInvalid=true) |
| iAbase_API QString | stripHTML (QString const &html) |
| strip HTML tags from the given string More... | |
| template<typename T , typename TVal , int Nval> | |
| void | valuesFromString (T &val, QString const &str, QString const &sep=" ") |
| Split a string with multiple values, and put values into a container. More... | |
| QString arrayToString | ( | T const * | arr, |
| size_t | size, | ||
| QString const & | sep = " " |
||
| ) |
Convert a given array with specified number of elements to a string representation.
| iAbase_API QString dblToStringWithUnits | ( | double | value, |
| double | switchFactor = 999 |
||
| ) |
returns the value converted to string, with units (K, M, G, T, P) applied for every 10³ factor over 1000
| value | the value to convert to a string |
| switchFactor | the multiple of the "base unit" under which to switch to next lower unit; example: if value = 0.101 and switchFactor is at default 100, the returned string will be "0.1" with the same value and a switchFactor of 102 (or any other value larger than 101), the result will be 101m |
| iAbase_API int digitsAfterComma | ( | double | resolvableDiff | ) |
Get the number of digits required after the comma, given the difference to other values it should be distinguishable from.
TODO: introduce "number of relevant digits" parameter / automatic determination? e.g. 9.125 -> 3, 9.98 -> 2, 9.5 -> 1; but what about e.g. 9.995 (->close enough to 10 to discard after comma?) Examples: resolvableDiff result >= 10 0 9.9999 - 1.0 0-1 (0 if resolvableDiff is exactly 1,6,4,... depending on whether resolvableDiff is 1.2,6.323, or ) 0.9999 - 0.1 1-2 (depending on whether resolvableDiff is 0.15,0.22,0.9333,... or exactly 0.1,0.4,...) 0.0999 - 0.01 2-3 0.0099 - 0.001 3-4
| iAbase_API QString greatestCommonPrefix | ( | QString const & | str1, |
| QString const & | str2 | ||
| ) |
| iAbase_API int greatestCommonPrefixLength | ( | QString const & | str1, |
| QString const & | str2 | ||
| ) |
Find the (length of the) greatest common prefix of the two given strings.
example: str1 ="BaseMethod", str2="BaseMember" => result: "BaseMe"
| iAbase_API QString greatestCommonSuffix | ( | QString const & | str1, |
| QString const & | str2 | ||
| ) |
| iAbase_API int greatestCommonSuffixLength | ( | QString const & | str1, |
| QString const & | str2 | ||
| ) |
| QString joinAsString | ( | Container< Element > const & | vec, |
| QString const & | joinStr, | ||
| FnType | lambda | ||
| ) |
join any list as string - the conversion of the single items happens via the passed-in lambda FnType is something like a function taking an Element parameter and has a QString(-compatible) return type; tried QString fct(Element const &) but it doesn't work as expected
| QString joinNumbersAsString | ( | Container< Element > const & | vec, |
| QString const & | joinStr | ||
| ) |
join an iterable collection of numeric elements to a string
works similar to QString::join, but on arbitrary iterable collection types containing items which can be converted to QString via QString::number.
| vec | the collection of elements to be joined |
| joinStr | the string to be used in between the elements of the string |
| iAbase_API QString joinQVariantAsString | ( | QVector< QVariant > const & | vec, |
| QString const & | joinStr | ||
| ) |
| iAbase_API QString padOrTruncate | ( | QString const & | str, |
| int | size | ||
| ) |
Pads or truncates the given string to the given size.
If the string given in name is longer than the specified size, the string is truncated to size-2 and ".." is appended, otherwise it is filled with spaces to be exactly size long
| str | the string to be padded or truncated |
| size | the size that the return string should have |
| iAbase_API QString quoteString | ( | QString const & | str | ) |
| iAbase_API int requiredDigits | ( | double | value | ) |
Get the number of digits required for the given number (before the comma).
| iAbase_API QStringList splitPossiblyQuotedString | ( | QString const & | str | ) |
split a string at the space characters, while correctly treating quoted elements
Example: the string '"a rabbit" and "a horse"' would be split into three elements: "a rabbit", "and", "a horse" (the quotes are stripped from the elements). Note that only the double-quote character is considered as a quote by this function.
| str | the string to split |
| bool stringToArray | ( | QString const & | str, |
| T * | arr, | ||
| int | expectedSize, | ||
| QString const & | sep = " " |
||
| ) |
Convert a given string representation to an array of given type with given number of elements.
| ContainerT stringToVector | ( | QString const & | listAsString, |
| QString const & | separator = ",", |
||
| int | maxItems = std::numeric_limits<int>::max(), |
||
| bool | warnWhenInvalid = true |
||
| ) |
| iAbase_API QString stripHTML | ( | QString const & | html | ) |
strip HTML tags from the given string
| html | a string potentially containing HTML tags |
| void valuesFromString | ( | T & | val, |
| QString const & | str, | ||
| QString const & | sep = " " |
||
| ) |
Split a string with multiple values, and put values into a container.
| val | a container (required to have an operator[] to set elements). |
| str | the string to be split. |
| sep | the separator between values. |