43 #include "../Exceptions.h" 71 static bool isEmpty(
const std::string& s);
79 static std::string
toUpper(
const std::string& s);
87 static std::string
toLower(
const std::string& s);
171 static bool isDecimalNumber(
const std::string& s,
char dec =
'.',
char scientificNotation =
'e');
181 static bool isDecimalInteger(
const std::string& s,
char scientificNotation =
'e');
191 std::ostringstream oss;
206 std::ostringstream oss;
207 oss << std::setprecision(precision) << t;
219 std::istringstream iss(s);
239 static std::string
toString(
char c);
248 static std::string
toString(
double d,
int precision = 6);
258 static int toInt(
const std::string& s,
char scientificNotation =
'e') throw (
Exception);
269 static
double toDouble(const
std::
string& s,
char dec = '.',
char scientificNotation = 'e') throw (
Exception);
280 std::istringstream iss(s);
295 static std::string
resizeRight(
const std::string& s,
size_t newSize,
char fill =
' ');
306 static std::string
resizeLeft(
const std::string& s,
size_t newSize,
char fill =
' ');
317 static std::vector<std::string>
split(
const std::string& s,
size_t n);
332 static std::string
removeSubstrings(
const std::string& s,
char blockBeginning,
char blockEnding)
352 static std::string
removeSubstrings(
const std::string& s,
char blockBeginning,
char blockEnding, std::vector<std::string>& exceptionsBeginning, std::vector<std::string>& exceptionsEnding)
362 static std::string
removeChar(
const std::string& s,
char c);
371 static unsigned int count(
const std::string& s,
const std::string& pattern);
380 static bool startsWith(
const std::string& s,
const std::string& pattern);
389 static bool endsWith(
const std::string& s,
const std::string& pattern);
398 static bool hasSubstring(
const std::string& s,
const std::string& pattern);
407 static void replaceAll(std::string& target,
const std::string& query,
const std::string& replacement);
413 #endif //_TEXTTOOLS_H_ static T fromString(const std::string &s)
General template method to convert from string.
static bool isNewLineCharacter(char c)
Tell if a character is a new line character or not.
static std::string 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 ...
This class allows to perform a correspondence analysis.
static std::string 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 ...
static bool isDecimalNumber(char c)
Tell is a given character describes a decimal number.
static std::string toString(T t)
General template method to convert to a string.
static int toInt(const std::string &s, char scientificNotation='e')
Convert from string to int.
static unsigned int count(const std::string &s, const std::string &pattern)
Count the occurences of a given pattern in a string.
static bool startsWith(const std::string &s, const std::string &pattern)
Tell is a string begins with a certain motif.
static bool hasSubstring(const std::string &s, const std::string &pattern)
Tell is a string contains a certain motif.
static bool isEmpty(const std::string &s)
Tell if a string is empty.
static std::string removeSurroundingWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning and the end of a string.
static bool endsWith(const std::string &s, const std::string &pattern)
Tell is a string ends with a certain motif.
static std::string removeNewLines(const std::string &s)
Remove all new line characters in a string.
static T to(const std::string &s)
Template to string conversion.
static std::string removeWhiteSpaces(const std::string &s)
Remove all white spaces characters in a string.
static bool isDecimalInteger(const std::string &s, char scientificNotation='e')
Tell is a given character string describes a decimal integer.
static std::string removeFirstWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning of a string.
static std::string toString(T t, int precision)
Template string conversion.
static std::string removeLastWhiteSpaces(const std::string &s)
Remove all white spaces characters at the end of a string.
static std::string removeLastNewLines(const std::string &s)
Remove all new line characters at the end of a string.
static std::vector< std::string > split(const std::string &s, size_t n)
Split a string into parts of size 'n'.
static std::string removeSubstrings(const std::string &s, char blockBeginning, char blockEnding)
Remove substrings from a string.
static std::string removeChar(const std::string &s, char c)
Remove all occurences of a character in a string.
static std::string toUpper(const std::string &s)
Make the string uppercase.
static std::string toLower(const std::string &s)
Make the string lowercase.
static void 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.
Some utilitary functions that work on strings.
static double toDouble(const std::string &s, char dec='.', char scientificNotation='e')
Convert from string to double.
static bool isWhiteSpaceCharacter(char c)
Tell if a character is a white space or not.