|
bpp-core
2.2.0
|
Some utilitary functions that work on strings. More...
#include <Bpp/Text/TextTools.h>
Static Public Member Functions | |
| static bool | isEmpty (const std::string &s) |
| Tell if a string is empty. More... | |
| static std::string | toUpper (const std::string &s) |
| Make the string uppercase. More... | |
| static std::string | toLower (const std::string &s) |
| Make the string lowercase. More... | |
| static bool | isWhiteSpaceCharacter (char c) |
| Tell if a character is a white space or not. More... | |
| static std::string | removeWhiteSpaces (const std::string &s) |
| Remove all white spaces characters in a string. More... | |
| static std::string | removeFirstWhiteSpaces (const std::string &s) |
| Remove all white spaces characters at the beginning of a string. More... | |
| static std::string | removeLastWhiteSpaces (const std::string &s) |
| Remove all white spaces characters at the end of a string. More... | |
| static std::string | removeSurroundingWhiteSpaces (const std::string &s) |
| Remove all white spaces characters at the beginning and the end of a string. More... | |
| static bool | isNewLineCharacter (char c) |
| Tell if a character is a new line character or not. More... | |
| static std::string | removeNewLines (const std::string &s) |
| Remove all new line characters in a string. More... | |
| static std::string | removeLastNewLines (const std::string &s) |
| Remove all new line characters at the end of a string. More... | |
| static bool | isDecimalNumber (char c) |
| Tell is a given character describes a decimal number. More... | |
| static bool | isDecimalNumber (const std::string &s, char dec='.', char scientificNotation='e') |
| Tell is a given character string describes a decimal number. More... | |
| static bool | isDecimalInteger (const std::string &s, char scientificNotation='e') |
| Tell is a given character string describes a decimal integer. More... | |
| template<class T > | |
| static std::string | toString (T t) |
| General template method to convert to a string. More... | |
| template<class T > | |
| static std::string | toString (T t, int precision) |
| Template string conversion. More... | |
| template<class T > | |
| static T | fromString (const std::string &s) |
| General template method to convert from string. More... | |
| static std::string | toString (int i) |
| Convert from int to string. More... | |
| static std::string | toString (char c) |
| Convert from char to string. More... | |
| static std::string | toString (double d, int precision=6) |
| Convert from double to string. More... | |
| static int | toInt (const std::string &s, char scientificNotation='e') throw (Exception) |
| Convert from string to int. More... | |
| static double | toDouble (const std::string &s, char dec='.', char scientificNotation='e') throw (Exception) |
| Convert from string to double. More... | |
| template<class T > | |
| static T | to (const std::string &s) |
| Template to string conversion. More... | |
| 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 the end. More... | |
| 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 the beginning. More... | |
| static std::vector< std::string > | split (const std::string &s, size_t n) |
| Split a string into parts of size 'n'. More... | |
| static std::string | removeSubstrings (const std::string &s, char blockBeginning, char blockEnding) throw (Exception) |
| Remove substrings from a string. More... | |
| static std::string | removeSubstrings (const std::string &s, char blockBeginning, char blockEnding, std::vector< std::string > &exceptionsBeginning, std::vector< std::string > &exceptionsEnding) throw (Exception) |
| Remove substrings from a string, unless they match some specific substrings. More... | |
| static std::string | removeChar (const std::string &s, char c) |
| Remove all occurences of a character in a string. More... | |
| static unsigned int | count (const std::string &s, const std::string &pattern) |
| Count the occurences of a given pattern in a string. More... | |
| static bool | startsWith (const std::string &s, const std::string &pattern) |
| Tell is a string begins with a certain motif. More... | |
| static bool | endsWith (const std::string &s, const std::string &pattern) |
| Tell is a string ends with a certain motif. More... | |
| static bool | hasSubstring (const std::string &s, const std::string &pattern) |
| Tell is a string contains a certain motif. More... | |
| 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. More... | |
Some utilitary functions that work on strings.
Definition at line 58 of file TextTools.h.
|
static |
Count the occurences of a given pattern in a string.
| s | The string to search. |
| pattern | The pattern to use (this is a mere string, not a regexp!). |
Definition at line 473 of file TextTools.cpp.
Referenced by bpp::NestedStringTokenizer::NestedStringTokenizer().
|
static |
Tell is a string ends with a certain motif.
| s | The string to search. |
| pattern | The pattern to use (this is a mere string, not a regexp!). |
Definition at line 496 of file TextTools.cpp.
|
inlinestatic |
General template method to convert from string.
| s | The string to convert. |
Definition at line 217 of file TextTools.h.
|
static |
Tell is a string contains a certain motif.
| s | The string to search. |
| pattern | The pattern to use (this is a mere string, not a regexp!). |
Definition at line 505 of file TextTools.cpp.
|
static |
Tell is a given character string describes a decimal integer.
NB: for now, this parser will not recognize thousands delimiters, and not the scientific notation neither.
| s | The string to parse. |
| scientificNotation | character to use for scientific notation (typically 'e' or 'E'). |
Definition at line 247 of file TextTools.cpp.
|
static |
Tell is a given character describes a decimal number.
| c | The character to check. |
Definition at line 205 of file TextTools.cpp.
|
static |
Tell is a given character string describes a decimal number.
NB: for now, this parser will not recognize thousands delimiters, and not the scientific notation neither.
| s | The string to parse. |
| dec | The decimal separator. |
| scientificNotation | character to use for scientific notation (typically 'e' or 'E'). |
Definition at line 216 of file TextTools.cpp.
|
static |
Tell if a string is empty.
A string is considered to be 'empty' if it is only made of white spaces.
| s | The string to check. |
Definition at line 52 of file TextTools.cpp.
Referenced by bpp::ApplicationTools::getMatrixParameter(), bpp::FileTools::getNextLine(), bpp::ApplicationTools::getVectorParameter(), bpp::ApplicationTools::parameterExists(), bpp::KeyvalTools::parseProcedure(), bpp::BppODiscreteDistributionFormat::read(), and bpp::DataTable::read().
|
static |
Tell if a character is a new line character or not.
| c | The character to check. |
Definition at line 160 of file TextTools.cpp.
|
static |
Tell if a character is a white space or not.
| c | The character to check. |
Definition at line 89 of file TextTools.cpp.
|
static |
Remove all occurences of a character in a string.
| s | The string to parse. |
| c | The character to remove. |
Definition at line 452 of file TextTools.cpp.
|
static |
Remove all white spaces characters at the beginning of a string.
| s | The string to parse. |
Definition at line 121 of file TextTools.cpp.
Referenced by bpp::KeyvalTools::parseProcedure().
|
static |
Remove all new line characters at the end of a string.
| s | The string to parse. |
Definition at line 189 of file TextTools.cpp.
|
static |
Remove all white spaces characters at the end of a string.
| s | The string to parse. |
Definition at line 137 of file TextTools.cpp.
|
static |
Remove all new line characters in a string.
| s | The string to parse. |
Definition at line 168 of file TextTools.cpp.
|
static | ||||||||||||||||||||||||
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.
| s | The string to parse. |
| blockBeginning | The character specifying the beginning of each block. |
| blockEnding | The character specifying the end of each block. |
| Exception | If some blocks are not well formed. |
Definition at line 359 of file TextTools.cpp.
|
static | ||||||||||||||||||||||||||||||||
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.
| s | The string to parse. |
| blockBeginning | The character specifying the beginning of each block. |
| blockEnding | The character specifying the end of each block. |
| exceptionsBeginning | A vector containing all strings specifying the beginning of blocks that should not be removed. |
| exceptionsEnding | A vector containing all strings specifying the ending of blocks that should not be removed. |
| Exception | If some blocks are not well formed. |
Definition at line 391 of file TextTools.cpp.
|
static |
Remove all white spaces characters at the beginning and the end of a string.
| s | The string to parse. |
Definition at line 153 of file TextTools.cpp.
Referenced by bpp::KeyvalTools::multipleKeyvals().
|
static |
Remove all white spaces characters in a string.
| s | The string to parse. |
Definition at line 100 of file TextTools.cpp.
|
static |
Replacement of all non-overlapping occurrences of a certain motif in a string.
| target | String to be modified |
| query | The motif to look for |
| replacement | The replacement string |
Definition at line 519 of file TextTools.cpp.
|
static |
Send a string of size 'newSize', which is a copy of 's' truncated or filled with character 'fill' at the beginning.
| s | The string to parse. |
| newSize | The new string size. |
| fill | The character to use to fill the string id length < newSize. |
Definition at line 334 of file TextTools.cpp.
Referenced by bpp::ApplicationTools::displayGauge().
|
static |
Send a string of size 'newSize', which is a copy of 's' truncated or filled with character 'fill' at the end.
| s | The string to parse. |
| newSize | The new string size. |
| fill | The character to use to fill the string id length < newSize. |
Definition at line 324 of file TextTools.cpp.
Referenced by bpp::ApplicationTools::displayGauge(), and bpp::ApplicationTools::displayResult().
|
static |
Split a string into parts of size 'n'.
The last part may contain < n chars.
| s | The string to parse. |
| n | The number of tokens. |
Definition at line 344 of file TextTools.cpp.
|
static |
Tell is a string begins with a certain motif.
| s | The string to search. |
| pattern | The pattern to use (this is a mere string, not a regexp!). |
Definition at line 487 of file TextTools.cpp.
Referenced by bpp::AbstractParametrizable::getParameterNameWithoutNamespace(), bpp::AbstractParametrizable::setNamespace(), and bpp::AbstractParameterAliasable::setNamespace().
|
inlinestatic |
Template to string conversion.
| s | The string to parse. |
Definition at line 278 of file TextTools.h.
|
static | ||||||||||||||||||||||||
Convert from string to double.
| s | The string to parse. |
| dec | The decimal separator. |
| scientificNotation | character to use for scientific notation (typically 'e' or 'E'). |
| Exception | if the string does not specify a valid number. |
Definition at line 313 of file TextTools.cpp.
Referenced by bpp::ApplicationTools::getDoubleParameter(), bpp::NumCalcApplicationTools::getVector(), bpp::BppODiscreteDistributionFormat::read(), and bpp::IntervalConstraint::readDescription().
|
static | ||||||||||||||||||||
Convert from string to int.
| s | The string to parse. |
| scientificNotation | character to use for scientific notation (typically 'e' or 'E'). |
| Exception | if the string does not specify a valid number. |
Definition at line 302 of file TextTools.cpp.
Referenced by bpp::ApplicationTools::getIntParameter(), bpp::NumCalcApplicationTools::getVector(), bpp::BppODiscreteDistributionFormat::read(), and bpp::NumCalcApplicationTools::seqFromString().
|
static |
Make the string lowercase.
| s | The string to analyse. |
Definition at line 77 of file TextTools.cpp.
|
inlinestatic |
General template method to convert to a string.
| t | The object to convert. |
Definition at line 189 of file TextTools.h.
Referenced by bpp::ParametrizableCollection< N >::addObject(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::DirichletDiscreteDistribution::applyParameters(), bpp::AutoCorrelationTransitionMatrix::AutoCorrelationTransitionMatrix(), bpp::SvgGraphicDevice::colorToText(), bpp::RescaledHmmLikelihood::computeForward_(), bpp::ContingencyTableTest::ContingencyTableTest(), bpp::DirichletDiscreteDistribution::DirichletDiscreteDistribution(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayUnlimitedGauge(), bpp::GoldenSectionSearch::doInit(), bpp::BrentOneDimension::doInit(), bpp::NewtonOneDimension::doStep(), bpp::SvgGraphicDevice::drawCircle(), bpp::SvgGraphicDevice::drawLine(), bpp::SvgGraphicDevice::drawRect(), bpp::SvgGraphicDevice::drawText(), bpp::XFigGraphicDevice::drawText(), bpp::EigenValue< Real >::EigenValue(), bpp::PgfGraphicDevice::end(), bpp::AutoCorrelationTransitionMatrix::fireParameterChanged(), bpp::FullHmmTransitionMatrix::fireParameterChanged(), bpp::SimpleDiscreteDistribution::fireParameterChanged(), bpp::MixtureOfDiscreteDistributions::fireParameterChanged(), bpp::Simplex::fireParameterChanged(), bpp::FullHmmTransitionMatrix::FullHmmTransitionMatrix(), bpp::ApplicationTools::getBooleanParameter(), bpp::XFigColorManager::getColor(), bpp::IntervalConstraint::getDescription(), bpp::ApplicationTools::getDoubleParameter(), bpp::AbstractFontManager< int >::getFont(), bpp::ApplicationTools::getIntParameter(), bpp::ApplicationTools::getMatrixParameter(), bpp::ApplicationTools::getParameter(), bpp::NumCalcApplicationTools::getParameterGrid(), bpp::AbstractDiscreteDistribution::getValueCategory(), bpp::ApplicationTools::getVectorParameter(), bpp::ReparametrizationFunctionWrapper::init_(), bpp::BppODiscreteDistributionFormat::initialize_(), bpp::MixtureOfDiscreteDistributions::MixtureOfDiscreteDistributions(), bpp::AbstractOptimizer::printPoint(), bpp::BppODiscreteDistributionFormat::read(), bpp::SimpleDiscreteDistribution::restrictToConstraint(), bpp::PgfGraphicDevice::setCurrentBackgroundColor(), bpp::PgfGraphicDevice::setCurrentForegroundColor(), bpp::PgfGraphicDevice::setCurrentLayer(), bpp::AbstractGraphicDevice::setCurrentLineType(), bpp::PgfGraphicDevice::setCurrentLineType(), bpp::XFigGraphicDevice::setCurrentLineType(), bpp::Simplex::setFrequencies(), bpp::FullHmmTransitionMatrix::setTransitionProbabilities(), bpp::SimpleDiscreteDistribution::SimpleDiscreteDistribution(), bpp::Simplex::Simplex(), bpp::RGBColor::toString(), bpp::Number< unsigned int >::toString(), bpp::Font::toString(), bpp::Range< T >::toString(), and bpp::BppODiscreteDistributionFormat::write().
|
inlinestatic |
Template string conversion.
| t | The object to convert. |
| precision | To use (for numbers). |
Definition at line 204 of file TextTools.h.
|
static |
Convert from int to string.
| i | The integer to convert. |
Definition at line 275 of file TextTools.cpp.
|
static |
Convert from char to string.
| c | The character to convert. |
Definition at line 284 of file TextTools.cpp.
|
static |
Convert from double to string.
| d | The double to convert. |
| precision | To use (for numbers). |
Definition at line 293 of file TextTools.cpp.
|
static |
Make the string uppercase.
| s | The string to analyse. |
Definition at line 65 of file TextTools.cpp.