Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
string_util.h File Reference
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cctype>
#include <cstdio>
#include <cassert>
#include "hash_function.h"
#include "common/ug_config.h"
#include "stringify.h"

Go to the source code of this file.

Namespaces

namespace  ug
 the ug namespace
 

Functions

UG_API void ug::AppendCounterToString (std::string &str, std::string indicator, int counter, int maxCounter=-1)
 appends a counter number to a string
 
UG_API std::string ug::AppendSpacesToString (std::string &str, int totalLength)
 padding a string with spaces to predefined length
 
UG_API std::string ug::ConfigShift (std::string s)
 returns a "shifted" string one-line strings are not shifted two line strings are shifted like this: input: "MyLine1\nMyLine2\n" Output: "\n | MyLine1\n | MyLine2" note that they get an additional
at the beginning, and doubled
and
at the end are removed, so you can use ConfigShift like this
 
UG_API bool ug::Contains (const std::string &str, const std::string &search)
 Checks whether given string contains a specified substring.
 
UG_API std::string ug::FilenameAndPathWithoutExtension (std::string str)
 returns the best guess of the filename and path from given string
 
UG_API std::string ug::FilenameWithoutExtension (std::string str)
 returns the best guess of the filename from given string
 
UG_API std::string ug::FilenameWithoutPath (const std::string &str)
 returns best guess of a filename from a given string
 
UG_API std::vector< std::string > ug::FindDuplicates (const std::vector< std::string > &vec)
 Finds and returns all duplicate elements of given vector.
 
string ug::GetBytesSizeString (size_t s, int length)
 
std::string::size_type ug::GetDirectorySeperatorPos (const std::string &str)
 determines last occurrence of '/' or '\'
 
string ug::GetFileLine (const char *filename, size_t line)
 get a specific line of a file
 
string ug::GetFileLines (const char *filename, size_t fromline, size_t toline, bool includeLineNumbers)
 get some specified lines of a file
 
UG_API std::string ug::GetFilenameExtension (const std::string &str)
 returns the best guess of a file extensions from given string
 
template<typename... Args>
std::string ug::GetStringPrintf (const char *format, Args... args)
 
template<>
UG_API size_t ug::hash_key (const std::string &str)
 creates a hash key from a string value
 
UG_API bool ug::IsLonger (const std::string &a, const std::string &b)
 checks whether second string is longer than first string
 
UG_API size_t ug::LevenshteinDistance (const std::string &s1, const std::string &s2)
 Calculate Levenshtein Distance of to strings.
 
int ug::NumberOfDigits (int n)
 returns the number of digits of an integer (expressed with base 10)
 
const char * ug::OnOffString (bool b)
 
template<typename T >
std::string ug::OstreamShift (const T &t)
 
UG_API std::string ug::PathFromFilename (const std::string &str)
 returns best guess of a path without a filename from a given string
 
void ug::RemoveWhitespaceFromString (std::string &string)
 removes all white space from a string, also within the string
 
string ug::repeat (char c, int nr)
 Builds a string with specified repetitions of given character.
 
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.
 
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
 
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
 
UG_API bool ug::StartsWith (const std::string &str, const std::string &search)
 checks whether a given string starts with a specified substring
 
vector< string > ug::TokenizeString (const char *str, const char delimiter=',')
 splits the string into parts based on a separating character
 
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
 
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
 
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
 
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
 
UG_API std::string ug::ToLower (std::string str)
 Returns a lower case version of the specified string.
 
template<typename T >
std::string ug::ToString (const T &t)
 Convert a object supporting 'std::cout << obj' to a string.
 
UG_API std::string ug::ToUpper (std::string str)
 Returns an upper case version of the specified string.
 
UG_API std::string ug::TrimString (const std::string &str)
 removes all white space from the front and end of a string
 
const char * ug::TrueFalseString (bool b)
 
bool ug::WildcardMatch (const char *str, const char *pattern)
 wildcard matches like bla.* or *.bla or t?st
 
UG_API std::string ug::XMLStringEscape (std::string s)
 returns a string suitable for XML files this functions escapes the characters <, >, ', " and &