ug4
|
Functions | |
UG_API void | ug::AppendCounterToString (std::string &str, std::string indicator, int counter, int maxCounter=-1) |
appends a counter number to a string More... | |
UG_API std::string | ug::AppendSpacesToString (std::string &str, int totalLength) |
padding a string with spaces to predefined length More... | |
UG_API bool | ug::Contains (const std::string &str, const std::string &search) |
Checks whether given string contains a specified substring. More... | |
UG_API std::string | ug::FilenameAndPathWithoutExtension (std::string str) |
returns the best guess of the filename and path from given string More... | |
UG_API std::string | ug::FilenameWithoutExtension (std::string str) |
returns the best guess of the filename from given string More... | |
UG_API std::string | ug::FilenameWithoutPath (const std::string &str) |
returns best guess of a filename from a given string More... | |
UG_API std::vector< std::string > | ug::FindDuplicates (const std::vector< std::string > &vec) |
Finds and returns all duplicate elements of given vector. More... | |
std::string::size_type | ug::GetDirectorySeperatorPos (const std::string &str) |
determines last occurrence of '/' or '\' More... | |
string | ug::GetFileLine (const char *filename, size_t line) |
get a specific line of a file More... | |
string | ug::GetFileLines (const char *filename, size_t fromline, size_t toline, bool includeLineNumbers) |
get some specified lines of a file More... | |
UG_API std::string | ug::GetFilenameExtension (const std::string &str) |
returns the best guess of a file extensions from given string More... | |
template<> | |
UG_API size_t | ug::hash_key (const std::string &str) |
creates a hash key from a string value More... | |
UG_API bool | ug::IsLonger (const std::string &a, const std::string &b) |
checks whether second string is longer than first string More... | |
UG_API size_t | ug::LevenshteinDistance (const std::string &s1, const std::string &s2) |
Calculate Levenshtein Distance of to strings. More... | |
int | ug::NumberOfDigits (int n) |
returns the number of digits of an integer (expressed with base 10) More... | |
UG_API std::string | ug::PathFromFilename (const std::string &str) |
returns best guess of a path without a filename from a given string More... | |
void | ug::RemoveWhitespaceFromString (std::string &string) |
removes all white space from a string, also within the string More... | |
string | ug::repeat (char c, int nr) |
Builds a string with specified repetitions of given character. More... | |
UG_API std::string | ug::ReplaceAll (std::string target, const std::string &oldstr, const std::string &newstr) |
Substitutes substrings of given string with other substrings. More... | |
UG_API std::string | ug::SnipString (const std::string &str, size_t totalSize, size_t replaceLast=0, const char replace='.') |
creates a truncated string and may add truncation symbol at end More... | |
UG_API std::string | ug::SnipStringFront (const std::string &str, size_t totalSize, size_t replaceFront=0, const char replace='.') |
creates a truncated string and may add truncation symbol at front More... | |
UG_API bool | ug::StartsWith (const std::string &str, const std::string &search) |
checks whether a given string starts with a specified substring More... | |
vector< string > | ug::TokenizeString (const char *str, const char delimiter=',') |
splits the string into parts based on a separating character More... | |
UG_API std::vector< std::string > | ug::TokenizeString (const std::string &str, const char delimiter=',') |
splits the string into parts based on a separating character More... | |
UG_API void | ug::TokenizeString (const std::string &str, std::vector< std::string > &vToken, const char delimiter=',') |
splits the string into parts based on a separating char More... | |
UG_API std::vector< std::string > | ug::TokenizeTrimString (const std::string &str, const char delimiter=',') |
splits the string into trimmed parts based on a separating char More... | |
UG_API void | ug::TokenizeTrimString (const std::string &str, std::vector< std::string > &vToken, const char delimiter=',') |
splits the string into trimmed parts based on a separating char More... | |
UG_API std::string | ug::ToLower (std::string str) |
Returns a lower case version of the specified string. More... | |
template<typename T > | |
std::string | ug::ToString (const T &t) |
Convert a object supporting 'std::cout << obj ' to a string. More... | |
UG_API std::string | ug::ToUpper (std::string str) |
Returns an upper case version of the specified string. More... | |
UG_API std::string | ug::TrimString (const std::string &str) |
removes all white space from the front and end of a string More... | |
bool | ug::WildcardMatch (const char *str, const char *pattern) |
wildcard matches like bla.* or *.bla or t?st More... | |
UG_API std::string | ug::XMLStringEscape (std::string s) |
returns a string suitable for XML files this functions escapes the characters <, >, ', " and & More... | |
UG_API void ug::AppendCounterToString | ( | std::string & | str, |
std::string | indicator, | ||
int | counter, | ||
int | maxCounter = -1 |
||
) |
appends a counter number to a string
This functions appends to a string a counter preceded by some indicator. If a maxCounter
is passed, the field is adjusted to the maximum needed width and additional space is filled by zeros.
[in,out] | str | string to append the counter |
[in] | indicator | some string preceding the counter |
[in] | counter | counter added |
[in] | maxCounter | maximum counter to be added |
UG_API std::string ug::AppendSpacesToString | ( | std::string & | str, |
int | totalLength | ||
) |
padding a string with spaces to predefined length
Appends spaces to the given string so that the resulting string has a predefined length of totalLength
[in] | str | string to be padded |
[in] | totalLength | desired total length of the string |
UG_API bool ug::Contains | ( | const std::string & | str, |
const std::string & | search | ||
) |
Checks whether given string contains a specified substring.
Checks whether str
contains search
.
[in] | str | string |
[in] | search | string to search for |
true
if str
contains search
; false
otherwise UG_API std::string ug::FilenameAndPathWithoutExtension | ( | std::string | str | ) |
returns the best guess of the filename and path from given string
returns the part of the string without extension (e.g. /sw/bla.txt
-> bla
)
[in] | str | to retrieve filename from |
UG_API std::string ug::FilenameWithoutExtension | ( | std::string | str | ) |
returns the best guess of the filename from given string
returns the part of the string without path and extension (e.g. /sw/bla.txt
-> bla
)
[in] | str | to retrieve filename from |
UG_API std::string ug::FilenameWithoutPath | ( | const std::string & | str | ) |
returns best guess of a filename from a given string
returns the part of the string after the last '/' or '\' character (e.g. /sw/bla.txt
-> bla.txt
)
[in] | str | to retrieve the filename from |
UG_API std::vector<std::string> ug::FindDuplicates | ( | const std::vector< std::string > & | vec | ) |
Finds and returns all duplicate elements of given vector.
Searches for duplicates in the specified vector and returns a vector containing all elements that occur multiple times.
[in] | vec | vector to analyze |
std::string::size_type ug::GetDirectorySeperatorPos | ( | const std::string & | str | ) |
determines last occurrence of '/' or '\'
[in] | str | string to lock in |
str
; returns std::string::npos
if none are found UG_API std::string ug::GetFileLine | ( | const char * | filename, |
size_t | line | ||
) |
get a specific line of a file
filename | file name |
line | line number to extract |
References ug::GetFileLines().
Referenced by ug::bridge::FunctionInfo(), ug::bridge::GetLuaFileAndLine(), ug::bridge::GetLuaLine(), ug::bridge::LuaCurrentLine(), ug::bridge::LuaGetScriptFunctionString(), ug::bridge::LuaStackTraceString(), and ug::script::UpdateDepth().
UG_API std::string ug::GetFileLines | ( | const char * | filename, |
size_t | fromline, | ||
size_t | toline, | ||
bool | includeLineNumbers | ||
) |
get some specified lines of a file
[in] | filename | file name |
[in] | fromline | line number to start from |
[in] | toline | line number to stop at |
[in] | includeLineNumbers | if true, add the line number in front of each line and a tab. |
References PROFILE_FUNC.
Referenced by ug::bridge::LUACompiler::createC(), ug::script::DebugList(), ug::GetFileLine(), ug::GetFileLinesParallel(), and ug::LUAParserClass::parse_luaFunction_StackTop().
UG_API std::string ug::GetFilenameExtension | ( | const std::string & | str | ) |
returns the best guess of a file extensions from given string
returns the extension of the filename (e.g. /sw/bla.txt
-> txt
). Everything after the last dot ('.') of str
is considered the file extension.
[in] | str | to retrieve file extension from |
UG_API size_t ug::hash_key | ( | const std::string & | str | ) |
creates a hash key from a string value
this template function creates a hash key for a string value
[in] | str | string to create hash for |
key
UG_API bool ug::IsLonger | ( | const std::string & | a, |
const std::string & | b | ||
) |
checks whether second string is longer than first string
This can be used to get the longest string in a vector of strings:
int maxLength = (*max_element(vecStr.begin(), vecStr.end(), IsLonger)).size();
[in] | a | |
[in] | b |
true
if b
is longer then a
; false
otherwise UG_API size_t ug::LevenshteinDistance | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
Calculate Levenshtein Distance of to strings.
Levenshtein distance calculates the minimum number of edits to transform one string into the other with allowable edit operations insertion, deletion, or substitution of a single character.
[in] | s1 | string 1 |
[in] | s2 | string 2 |
UG_API int ug::NumberOfDigits | ( | int | n | ) |
returns the number of digits of an integer (expressed with base 10)
Determines the number of digits for the passed base-10 number. A minus sign is ignored.
[in] | n | number to count the number of digits |
Referenced by ug::AppendCounterToString(), and ug::operator<<().
UG_API std::string ug::PathFromFilename | ( | const std::string & | str | ) |
returns best guess of a path without a filename from a given string
returns the part of the string before the last '/' or '\' character (e.g. /sw/bla.txt
-> /sw/
)
[in] | str | to retrieve the filename from |
UG_API void ug::RemoveWhitespaceFromString | ( | std::string & | string | ) |
removes all white space from a string, also within the string
[in,out] | string | the string to modify |
Referenced by ug::check_subset_strings(), ug::IElemAssembleFuncs< IElemDisc< TDomain >, TDomain >::clear_add_fct(), ug::ExplicitGridFunctionVector< TGridFunction >::ExplicitGridFunctionVector(), ug::GridFunctionVectorData< TGridFunction >::GridFunctionVectorData(), ug::InitLinearManifoldSubsetHandler(), ug::OutNormCmp< TDomain >::OutNormCmp(), ug::IElemDiscBase< TDomain >::set_subsets(), and ug::SubsetIndicatorUserData< TDomain >::SubsetIndicatorUserData().
UG_API std::string ug::repeat | ( | char | c, |
int | nr | ||
) |
Builds a string with specified repetitions of given character.
[in] | c | the character |
[in] | nr | number of times to repeat c |
nr
times c
Referenced by ug::LUAParserClass::createC(), ug::LUAParserClass::createRT(), ug::script::LuaCallHook(), ug::bridge::LuaPrintTable(), ug::AlgebraicConvCheck< TVector >::post(), ug::StdConvCheck< TVector >::post(), ug::CompositeConvCheck< TVector, TDomain >::post(), ug::IApproximationSpace::print_layout_statistic(), ug::AlgebraicConvCheck< TVector >::print_offset(), ug::StdConvCheck< TVector >::print_offset(), ug::CompositeConvCheck< TVector, TDomain >::print_offset(), ug::IApproximationSpace::print_statistic(), ug::PrintDoFCount(), ug::AlgebraicConvCheck< TVector >::start(), ug::CompositeConvCheck< TVector, TDomain >::start(), ug::StdConvCheck< TVector >::start_defect(), and ug::Table< T >::stream().
UG_API std::string ug::ReplaceAll | ( | std::string | target, |
const std::string & | oldstr, | ||
const std::string & | newstr | ||
) |
Substitutes substrings of given string with other substrings.
Replaces each substring of target
string that is equal to oldstr
with newstr
[in] | target | string to modify |
[in] | oldstr | string to raplace |
[in] | newstr | replacement string |
target
string where all occurences of oldstr
are replaced with newstr
. UG_API std::string ug::SnipString | ( | const std::string & | str, |
size_t | totalSize, | ||
size_t | replaceLast = 0 , |
||
const char | replace = '.' |
||
) |
creates a truncated string and may add truncation symbol at end
[in] | string | the string to modify |
[in] | totalSize | the total size of snippet |
[in] | replaceLast | the number of last chars to be replaced by symbol |
[in] | replace | the replace symbol |
UG_API std::string ug::SnipStringFront | ( | const std::string & | str, |
size_t | totalSize, | ||
size_t | replaceFront = 0 , |
||
const char | replace = '.' |
||
) |
creates a truncated string and may add truncation symbol at front
[in] | string | the string to modify |
[in] | totalSize | the total size of snippet |
[in] | replaceLast | the number of last chars to be replaced by symbol |
[in] | replace | the replace symbol |
UG_API bool ug::StartsWith | ( | const std::string & | str, |
const std::string & | search | ||
) |
checks whether a given string starts with a specified substring
Checks whether str
starts with search
.
[in] | str | string |
[in] | search | string to search for |
true
if str
starts with search
; false
otherwise UG_API std::vector< std::string > ug::TokenizeString | ( | const char * | str, |
const char | delimiter = ',' |
||
) |
splits the string into parts based on a separating character
returns the string parts using a separator char in order to indicate parts
[in] | str | original string |
[in] | delimiter | char used as separator |
References ug::TokenizeString().
UG_API std::vector<std::string> ug::TokenizeString | ( | const std::string & | str, |
const char | delimiter = ',' |
||
) |
splits the string into parts based on a separating character
returns the string parts using a separator char in order to indicate parts
[in] | str | original string |
[in] | delimiter | char used as separator |
UG_API void ug::TokenizeString | ( | const std::string & | str, |
std::vector< std::string > & | vToken, | ||
const char | delimiter = ',' |
||
) |
splits the string into parts based on a separating char
the string parts using a separator char in order to indicate parts
vToken
will get deleted [in] | str | original string |
[in,out] | vToken | tokenized parts |
[in] | delimiter | char used as separator |
UG_API std::vector<std::string> ug::TokenizeTrimString | ( | const std::string & | str, |
const char | delimiter = ',' |
||
) |
splits the string into trimmed parts based on a separating char
returns the string parts separated by delimiter
and trims all parts
[in] | str | original string |
[in] | delimiter | char used as separator |
UG_API void ug::TokenizeTrimString | ( | const std::string & | str, |
std::vector< std::string > & | vToken, | ||
const char | delimiter = ',' |
||
) |
splits the string into trimmed parts based on a separating char
places the generated tokens in the given vector.
vToken
will get deleted [in] | str | original string |
[in,out] | vToken | tokenized parts |
[in] | delimiter | char used as separator |
UG_API std::string ug::ToLower | ( | std::string | str | ) |
Returns a lower case version of the specified string.
[in] | str | string to convert |
|
inline |
Convert a object supporting 'std::cout << obj
' to a string.
T | type of the object; must support std::ostream operator<<() |
[in] | t | object to convert to string |
std::cout
) Referenced by ug::AssembledMultiGridCycle< TDomain, TAlgebra >::log_debug_data(), ug::operator<<(), ug::StringTableStream::operator<<(), ug::StringTableStream::repeat_col(), ug::StringTableStream::set(), and ug::StdTransfer< TDomain, TAlgebra >::write_debug().
UG_API std::string ug::ToUpper | ( | std::string | str | ) |
Returns an upper case version of the specified string.
[in] | str | string to convert |
UG_API std::string ug::TrimString | ( | const std::string & | str | ) |
removes all white space from the front and end of a string
[in] | string | the string to modify |
UG_API bool ug::WildcardMatch | ( | const char * | str, |
const char * | pattern | ||
) |
wildcard matches like bla.* or *.bla or t?st
[in] | str | a string |
[in] | pattern | a pattern with wildcards * or ? |
References UG_ASSERT.
Referenced by ug::bridge::RegisterBridge_Misc(), and ug::DebugIDManager::set_debug_level().
UG_API std::string ug::XMLStringEscape | ( | std::string | s | ) |
returns a string suitable for XML files this functions escapes the characters <, >, ', " and &
[in] | s |
this function replaces XML special characters with their escaped versions: & -> & " -> " ' -> "' < -> <
-> >
s | a normal text |