open_iA  2019.12
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
Classes | Functions
iAStringHelper.h File Reference
#include "open_iA_Core_export.h"
#include <QStringList>
#include <QVector>
#include <cassert>
Include dependency graph for iAStringHelper.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  iAConverter< T >
 Class for converting a variable of the type QString to the templated type. More...
 
struct  iAConverter< double >
 
struct  iAConverter< int >
 

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...
 
open_iA_Core_API 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...
 
open_iA_Core_API QString greatestCommonPrefix (QString const &str1, QString const &str2)
 
open_iA_Core_API int greatestCommonPrefixLength (QString const &str1, QString const &str2)
 Find the (length of the) greatest common prefix of the two given strings. More...
 
open_iA_Core_API QString greatestCommonSuffix (QString const &str1, QString const &str2)
 
open_iA_Core_API int greatestCommonSuffixLength (QString const &str1, QString const &str2)
 
template<template< typename... > class Container, typename Element >
QString join (Container< Element > const &vec, QString const &joinStr)
 join an iterable collection of numeric elements to a string More...
 
open_iA_Core_API QString padOrTruncate (QString const &str, int size)
 Pads or truncates the given string to the given size. More...
 
open_iA_Core_API QString quoteString (QString const &str)
 
open_iA_Core_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, size_t size, QString const &sep=" ")
 Convert a given string representation to an array of given type with given number of elements. More...
 
open_iA_Core_API QString stripHTML (QString const &html)
 strip HTML tags from the given string More...
 

Function Documentation

◆ arrayToString()

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.

◆ dblToStringWithUnits()

open_iA_Core_API 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()

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

◆ greatestCommonPrefixLength()

open_iA_Core_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"

◆ greatestCommonSuffix()

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

◆ greatestCommonSuffixLength()

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

◆ join()

template<template< typename... > class Container, typename Element >
QString join ( 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.

Parameters
vecthe collection of elements to be joined
joinStrthe string to be used in between the elements of the string
Returns
a string joining all elements of the given collection together

◆ padOrTruncate()

open_iA_Core_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

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()

open_iA_Core_API QString quoteString ( QString const &  str)

◆ splitPossiblyQuotedString()

open_iA_Core_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.

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

◆ stringToArray()

template<typename T >
bool stringToArray ( QString const &  str,
T *  arr,
size_t  size,
QString const &  sep = " " 
)

Convert a given string representation to an array of given type with given number of elements.

◆ stripHTML()

open_iA_Core_API 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