43 #ifndef BPP_TEXT_TEXTTOOLS_H
44 #define BPP_TEXT_TEXTTOOLS_H
63 bool isEmpty(
const std::string& s);
69 std::string
toUpper(
const std::string& s);
75 std::string
toLower(
const std::string& s);
138 bool isDecimalNumber(
const std::string& s,
char dec =
'.',
char scientificNotation =
'e');
155 std::ostringstream oss;
168 std::ostringstream oss;
169 oss << std::setprecision(precision) << t;
180 std::istringstream iss(s);
192 int toInt(
const std::string& s,
char scientificNotation =
'e');
201 double toDouble(
const std::string& s,
char dec =
'.',
char scientificNotation =
'e');
208 T
to(
const std::string& s)
210 std::istringstream iss(s);
224 std::string
resizeRight(
const std::string& s,
size_t newSize,
char fill =
' ');
233 std::string
resizeLeft(
const std::string& s,
size_t newSize,
char fill =
' ');
241 std::vector<std::string>
split(
const std::string& s,
size_t n);
253 std::string
removeSubstrings(
const std::string& s,
char blockBeginning,
char blockEnding);
269 std::string
removeSubstrings(
const std::string& s,
char blockBeginning,
char blockEnding,
270 std::vector<std::string>& exceptionsBeginning,
271 std::vector<std::string>& exceptionsEnding);
280 std::string
removeChar(
const std::string& s,
char c);
289 std::size_t
count(
const std::string& s,
const std::string& pattern);
298 bool startsWith(
const std::string& s,
const std::string& pattern);
307 bool endsWith(
const std::string& s,
const std::string& pattern);
316 bool hasSubstring(
const std::string& s,
const std::string& pattern);
325 void replaceAll(std::string& target,
const std::string& query,
const std::string& replacement);
int toInt(const std::string &s, char scientificNotation)
Convert from string to int.
std::string removeWhiteSpaces(const std::string &s)
Remove all white spaces characters in a string.
double toDouble(const std::string &s, char dec, char scientificNotation)
Convert from string to double.
T to(const std::string &s)
Template to string conversion.
std::string resizeLeft(const std::string &s, std::size_t newSize, char fill)
std::string removeSurroundingWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning and the end of a string.
std::string toUpper(const std::string &s)
Make the string uppercase.
bool isWhiteSpaceCharacter(char c)
Tell if a character is a white space or not.
bool hasSubstring(const std::string &s, const std::string &pattern)
Tell is a string contains a certain motif.
std::string removeSubstrings(const std::string &s, char blockBeginning, char blockEnding)
Remove substrings from a string. All substrings beginning with blockBeginning and ending with blockEn...
std::string removeLastNewLines(const std::string &s)
Remove all new line characters at the end of a string.
bool 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.
std::vector< std::string > split(const std::string &s, std::size_t n)
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.
T fromString(const std::string &s)
General template method to convert from string.
bool isDecimalInteger(const std::string &s, char scientificNotation)
Tell is a given character string describes a decimal integer. FIXME: for now, this parser will not re...
bool startsWith(const std::string &s, const std::string &pattern)
Tell is a string begins with a certain motif.
std::string removeChar(const std::string &s, char c)
Remove all occurences of a character in a string.
bool endsWith(const std::string &s, const std::string &pattern)
Tell is a string ends with a certain motif.
std::string removeNewLines(const std::string &s)
Remove all new line characters in a string.
std::string toLower(const std::string &s)
Make the string lowercase.
bool isDecimalNumber(char c)
Tell is a given character describes a decimal number.
std::string removeFirstWhiteSpaces(const std::string &s)
Remove all white spaces characters at the beginning of a string.
std::string toString(T t)
General template method to convert to a string.
std::string resizeRight(const std::string &s, std::size_t newSize, char fill)
std::string removeLastWhiteSpaces(const std::string &s)
Remove all white spaces characters at the end of a string.
bool isNewLineCharacter(char c)
Tell if a character is a new line character or not.
std::size_t count(const std::string &s, const std::string &pattern)
Count the occurences of a given pattern in a string.