open_iA  2020.04
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
Functions
iAStringHelper.cpp File Reference
#include "iAStringHelper.h"
#include <QRegularExpression>
Include dependency graph for iAStringHelper.cpp:

Functions

QString dblToStringWithUnits (double value)
 returns the value converted to string, with units (K, M, G, T, P) applied for every 10³ factor over 1000 More...
 
QString greatestCommonPrefix (QString const &str1, QString const &str2)
 
int greatestCommonPrefixLength (QString const &str1, QString const &str2)
 Find the (length of the) greatest common prefix of the two given strings. More...
 
QString greatestCommonSuffix (QString const &str1, QString const &str2)
 
int greatestCommonSuffixLength (QString const &str1, QString const &str2)
 
QString padOrTruncate (QString const &str, int size)
 Pads or truncates the given string to the given size. More...
 
QString quoteString (QString const &str)
 
QStringList splitPossiblyQuotedString (QString const &str)
 split a string at the space characters, while correctly treating quoted elements More...
 
QString stripHTML (QString const &html)
 strip HTML tags from the given string More...
 

Function Documentation

◆ dblToStringWithUnits()

QString dblToStringWithUnits ( double  value)

returns the value converted to string, with units (K, M, G, T, P) applied for every 10³ factor over 1000

◆ greatestCommonPrefix()

QString greatestCommonPrefix ( QString const &  str1,
QString const &  str2 
)

◆ greatestCommonPrefixLength()

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"

◆ greatestCommonSuffix()

QString greatestCommonSuffix ( QString const &  str1,
QString const &  str2 
)

◆ greatestCommonSuffixLength()

int greatestCommonSuffixLength ( QString const &  str1,
QString const &  str2 
)

◆ padOrTruncate()

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

Parameters
strthe string to be padded or truncated
sizethe size that the return string should have
Returns
a string of exactly the given size, padded or truncated from the given name

◆ quoteString()

QString quoteString ( QString const &  str)

◆ splitPossiblyQuotedString()

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.

Parameters
strthe string to split
Returns
a list of strings split up at the whitespaces

◆ stripHTML()

QString stripHTML ( QString const &  html)

strip HTML tags from the given string

Parameters
htmla string potentially containing HTML tags
Returns
the input string with all HTML tags (<xyz>, </xyz>, <xyz/>) removed