bpp-core3  3.0.0
TextTools.h File Reference
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
+ Include dependency graph for TextTools.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 bpp
 
 bpp::TextTools
 Some utilitary functions that work on strings.
 

Functions

bool bpp::TextTools::isEmpty (const std::string &s)
 Tell if a string is empty. A string is considered to be 'empty' if it is only made of white spaces. More...
 
std::string bpp::TextTools::toUpper (const std::string &s)
 Make the string uppercase. More...
 
std::string bpp::TextTools::toLower (const std::string &s)
 Make the string lowercase. More...
 
bool bpp::TextTools::isWhiteSpaceCharacter (char c)
 Tell if a character is a white space or not. More...
 
std::string bpp::TextTools::removeWhiteSpaces (const std::string &s)
 Remove all white spaces characters in a string. More...
 
std::string bpp::TextTools::removeFirstWhiteSpaces (const std::string &s)
 Remove all white spaces characters at the beginning of a string. More...
 
std::string bpp::TextTools::removeLastWhiteSpaces (const std::string &s)
 Remove all white spaces characters at the end of a string. More...
 
std::string bpp::TextTools::removeSurroundingWhiteSpaces (const std::string &s)
 Remove all white spaces characters at the beginning and the end of a string. More...
 
bool bpp::TextTools::isNewLineCharacter (char c)
 Tell if a character is a new line character or not. More...
 
std::string bpp::TextTools::removeNewLines (const std::string &s)
 Remove all new line characters in a string. More...
 
std::string bpp::TextTools::removeLastNewLines (const std::string &s)
 Remove all new line characters at the end of a string. More...
 
bool bpp::TextTools::isDecimalNumber (char c)
 Tell is a given character describes a decimal number. More...
 
bool bpp::TextTools::isDecimalNumber (const std::string &s, char dec='.', char scientificNotation='e')
 Tell is a given character string describes a decimal number. FIXME : for now, this parser will not recognize thousands delimiters, and not the scientific notation neither. More...
 
bool bpp::TextTools::isDecimalInteger (const std::string &s, char scientificNotation='e')
 Tell is a given character string describes a decimal integer. FIXME: for now, this parser will not recognize thousands delimiters, and not the scientific notation neither. More...
 
template<class T >
std::string bpp::TextTools::toString (T t)
 General template method to convert to a string. More...
 
template<class T >
std::string bpp::TextTools::toString (T t, int precision)
 Template string conversion. More...
 
template<class T >
bpp::TextTools::fromString (const std::string &s)
 General template method to convert from string. More...
 
int bpp::TextTools::toInt (const std::string &s, char scientificNotation='e')
 Convert from string to int. More...
 
double bpp::TextTools::toDouble (const std::string &s, char dec='.', char scientificNotation='e')
 Convert from string to double. More...
 
template<class T >
bpp::TextTools::to (const std::string &s)
 Template to string conversion. More...
 
std::string bpp::TextTools::resizeRight (const std::string &s, size_t newSize, char fill=' ')
 Send a string of size 'newSize', which is a copy of 's' truncated or filled with character 'fill' at the end. More...
 
std::string bpp::TextTools::resizeLeft (const std::string &s, size_t newSize, char fill=' ')
 Send a string of size 'newSize', which is a copy of 's' truncated or filled with character 'fill' at the beginning. More...
 
std::vector< std::string > bpp::TextTools::split (const std::string &s, size_t n)
 Split a string into parts of size 'n'. The last part may contain < n chars. More...
 
std::string bpp::TextTools::removeSubstrings (const std::string &s, char blockBeginning, char blockEnding)
 Remove substrings from a string. All substrings beginning with blockBeginning and ending with blockEnding will be removed. Nesting blocks are allowed, the most extern block will be removed. More...
 
std::string bpp::TextTools::removeSubstrings (const std::string &s, char blockBeginning, char blockEnding, std::vector< std::string > &exceptionsBeginning, std::vector< std::string > &exceptionsEnding)
 Remove substrings from a string, unless they match some specific substrings. All substrings beginning with blockBeginning and ending with blockEnding will be removed, except if they begin with a string included in the vector exceptionsBeginning or end with a string included in the vector exceptionsEnding. Nesting blocks are allowed, the most extern block will be removed. More...
 
std::string bpp::TextTools::removeChar (const std::string &s, char c)
 Remove all occurences of a character in a string. More...
 
std::size_t bpp::TextTools::count (const std::string &s, const std::string &pattern)
 Count the occurences of a given pattern in a string. More...
 
bool bpp::TextTools::startsWith (const std::string &s, const std::string &pattern)
 Tell is a string begins with a certain motif. More...
 
bool bpp::TextTools::endsWith (const std::string &s, const std::string &pattern)
 Tell is a string ends with a certain motif. More...
 
bool bpp::TextTools::hasSubstring (const std::string &s, const std::string &pattern)
 Tell is a string contains a certain motif. More...
 
void bpp::TextTools::replaceAll (std::string &target, const std::string &query, const std::string &replacement)
 Replacement of all non-overlapping occurrences of a certain motif in a string. More...