Orxonox  0.0.5 Codename: Arcturus
Namespaces | Functions | Variables
StringUtils.cc File Reference

Implementation of several string manipulation functions. More...

#include "StringUtils.h"
#include <algorithm>
#include <cctype>
#include <ctime>
#include <memory>
#include "Convert.h"
#include "Math.h"

Namespaces

 orxonox
 Die Wagnis Klasse hat die folgenden Aufgaben:
 

Functions

std::string orxonox::addSlashes (const std::string &str)
 Adds backslashes to the given string which makes special chars visible. More...
 
std::string orxonox::getComment (const std::string &str)
 If the string contains a comment, the comment gets returned (including the comment symbol and white spaces in front of it), an empty string otherwise. More...
 
unsigned int orxonox::getLevenshteinDistance (const std::string &str1, const std::string &str2)
 Calculates the Levenshtein distance between two strings. More...
 
std::string orxonox::getLowercase (const std::string &str)
 Returns a copy of the given string where all chars are converted to lowercase. More...
 
size_t orxonox::getNextCommentPosition (const std::string &str, size_t start)
 Returns the beginning of the next comment including whitespaces in front of the comment symbol. More...
 
size_t orxonox::getNextQuote (const std::string &str, size_t start)
 Returns the position of the next quotation mark in the string, starting with start. More...
 
std::string orxonox::getStringBetweenQuotes (const std::string &str)
 If the string contains something like '..."between quotaton marks"...' then 'between quotaton marks' gets returned, otherwise "". More...
 
std::string orxonox::getStripped (const std::string &str)
 Returns a copy of a string without whitespaces. More...
 
std::string orxonox::getTimestamp (void)
 Get a timestamp for the current time instant. More...
 
std::string orxonox::getUniqueNumberString ()
 Returns a string of a unique number. This function is guaranteed to never return the same string twice. More...
 
std::string orxonox::getUppercase (const std::string &str)
 Returns a copy of the given string where all chars are converted to uppercase. More...
 
bool orxonox::hasComment (const std::string &str)
 Returns true if the string contains a comment, introduced by #, %, ; or //. More...
 
bool orxonox::hasStringBetweenQuotes (const std::string &str)
 Returns true if the string contains something like '..."between quotaton marks"...'. More...
 
bool orxonox::isBetweenQuotes (const std::string &str, size_t pos)
 Returns true if pos is between two quotation marks. More...
 
bool orxonox::isComment (const std::string &str)
 Determines if a string is a comment (starts with a comment-symbol). More...
 
bool orxonox::isEmpty (const std::string &str)
 Determines if a string is empty (contains only whitespaces). More...
 
void orxonox::lowercase (std::string *str)
 Replaces each char between A and Z with its lowercase equivalent. More...
 
int orxonox::nocaseCmp (const std::string &s1, const std::string &s2)
 Compares two strings ignoring different casing. More...
 
int orxonox::nocaseCmp (const std::string &s1, const std::string &s2, size_t len)
 Compares the first len chars of two strings ignoring different casing. More...
 
std::string orxonox::removeSlashes (const std::string &str)
 Removes backslashes from the given string. More...
 
std::string orxonox::removeTrailingWhitespaces (const std::string &str)
 Returns a copy of a string without trailing whitespaces. More...
 
size_t orxonox::replaceCharacters (std::string &str, char target, char replacement)
 Replaces individual charaters. More...
 
void orxonox::strip (std::string *str)
 Removes all whitespaces from a string. More...
 
std::string orxonox::stripEnclosingBraces (const std::string &str)
 Removes enclosing braces '{' and '}' (the braces must be exactly on the beginning and the end of the string). More...
 
std::string orxonox::stripEnclosingQuotes (const std::string &str)
 Removes enclosing quotation marks if available (including whitespaces at the outside of the quotation marks). More...
 
void orxonox::uppercase (std::string *str)
 Replaces each char between a and z with its uppercase equivalent. More...
 
void orxonox::vectorize (const std::string &str, char delimiter, std::vector< std::string > *output)
 Splits a given string by a delimiter and stores it in an output vector. See SubString for a more sophisticated implementation. More...
 

Variables

std::string orxonox::BLANKSTRING
 A blank string (""). Used to return a blank string by reference. More...
 

Detailed Description

Implementation of several string manipulation functions.