| OpenMS 2.5.0

Classes | Static Public Member Functions | Static Private Attributes | List of all members
StringUtils Class Reference

`#include <OpenMS/DATASTRUCTURES/StringUtils.h>`

## Classes

struct | real_policies_NANfixed_

## Static Public Member Functions

static String | numberLength (double d, UInt n)
| Functions. More...
static String | number (double d, UInt n)
static String & | fillLeft (String &this_s, char c, UInt size)
static String & | fillRight (String &this_s, char c, UInt size)
static bool | hasPrefix (const String &this_s, const String &string)
static bool | hasSuffix (const String &this_s, const String &string)
static bool | hasSubstring (const String &this_s, const String &string)
static bool | has (const String &this_s, Byte byte)
static String | prefix (const String &this_s, size_t length)
static String | suffix (const String &this_s, size_t length)
static String | prefix (const String &this_s, Int length)
static String | suffix (const String &this_s, Int length)
static String | prefix (const String &this_s, char delim)
static String | suffix (const String &this_s, char delim)
static String | substr (const String &this_s, size_t pos, size_t n)
static String | chop (const String &this_s, Size n)
static String & | trim (String &this_s)
static String & | quote (String &this_s, char q, String::QuotingMethod method)
static String & | unquote (String &this_s, char q, String::QuotingMethod method)
static String & | simplify (String &this_s)
static String | random (UInt length)
static String & | reverse (String &this_s)
static bool | split (const String &this_s, const char splitter, std::vector< String > &substrings, bool quote_protect)
static bool | split (const String &this_s, const String &splitter, std::vector< String > &substrings)
static bool | split_quoted (const String &this_s, const String &splitter, std::vector< String > &substrings, char q, String::QuotingMethod method)
static QString | toQString (const String &this_s)
static Int | toInt (const String &this_s)
static float | toFloat (const String &this_s)
static double | toDouble (const String &s)
| convert String (leading and trailing whitespace allowed) to double More...
template<typename IteratorT >
static bool | extractDouble (IteratorT &begin, const IteratorT &end, double &target)
static String & | toUpper (String &this_s)
static String & | firstToUpper (String &this_s)
static String & | toLower (String &this_s)
static String & | substitute (String &this_s, char from, char to)
static String & | substitute (String &this_s, const String &from, const String &to)
static String & | remove (String &this_s, char what)
static String & | ensureLastChar (String &this_s, char end)
static String & | removeWhitespaces (String &this_s)

## Static Private Attributes

static boost::spirit::qi::real_parser< double, real_policies_NANfixed_< double > > | parse_double_
static boost::spirit::qi::real_parser< float, real_policies_NANfixed_< float > > | parse_float_

## Member Function Documentation

## ◆ chop()

static String chop | ( | const String & | this_s,
|  | Size | n
| ) |  |

inline static

## ◆ ensureLastChar()

static String& ensureLastChar | ( | String & | this_s,
|  | char | end
| ) |  |

inline static

References String::hasSuffix().

## ◆ extractDouble()

static bool extractDouble | ( | IteratorT & | begin,
|  | const IteratorT & | end,
|  | double & | target
| ) |  |

inline static

Reads a double from an iterator position. The begin iterator is modified (advanced) if parsing was successful. The `target` only contains a valid result if the functions returns true (i.e. parsing succeeded). Whitespaces before and after the double are NOT consumed!

## ◆ fillLeft()

static String& fillLeft | ( | String & | this_s,
|  | char | c,
|  | UInt | size
| ) |  |

inline static

References OpenMS::Constants::c.

## ◆ fillRight()

static String& fillRight | ( | String & | this_s,
|  | char | c,
|  | UInt | size
| ) |  |

inline static

References OpenMS::Constants::c.

## ◆ firstToUpper()

static String& firstToUpper | ( | String & | this_s | ) |

inline static

## ◆ has()

static bool has | ( | const String & | this_s,
|  | Byte | byte
| ) |  |

inline static

## ◆ hasPrefix()

static bool hasPrefix | ( | const String & | this_s,
|  | const String & | string
| ) |  |

inline static

## ◆ hasSubstring()

static bool hasSubstring | ( | const String & | this_s,
|  | const String & | string
| ) |  |

inline static

## ◆ hasSuffix()

static bool hasSuffix | ( | const String & | this_s,
|  | const String & | string
| ) |  |

inline static

## ◆ number()

static String number | ( | double | d,
|  | UInt | n
| ) |  |

inline static

## ◆ numberLength()

static String numberLength | ( | double | d,
|  | UInt | n
| ) |  |

inline static

Functions.

References OpenMS::writtenDigits().

## ◆ prefix() [1/3]

static String prefix | ( | const String & | this_s,
|  | size_t | length
| ) |  |

inline static

References String::substr().

Referenced by DecoyHelper::findDecoyString().

## ◆ prefix() [2/3]

static String prefix | ( | const String & | this_s,
|  | Int | length
| ) |  |

inline static

References String::substr().

## ◆ prefix() [3/3]

static String prefix | ( | const String & | this_s,
|  | char | delim
| ) |  |

inline static

References String::substr().

## ◆ quote()

static String& quote | ( | String & | this_s,
|  | char | q,
|  | String::QuotingMethod | method
| ) |  |

inline static

References String::DOUBLE, String::ESCAPE, and String::substitute().

## ◆ random()

static String random | ( | UInt | length | ) |

inline static

## ◆ remove()

static String& remove | ( | String & | this_s,
|  | char | what
| ) |  |

inline static

## ◆ removeWhitespaces()

static String& removeWhitespaces | ( | String & | this_s | ) |

inline static

References OpenMS::Constants::c.

## ◆ reverse()

static String& reverse | ( | String & | this_s | ) |

inline static

## ◆ simplify()

static String& simplify | ( | String & | this_s | ) |

inline static

## ◆ split() [1/2]

static bool split | ( | const String & | this_s,
|  | const char | splitter,
|  | std::vector< String > & | substrings,
|  | bool | quote_protect
| ) |  |

inline static

References String::prefix(), String::substr(), String::suffix(), and String::trim().

## ◆ split() [2/2]

static bool split | ( | const String & | this_s,
|  | const String & | splitter,
|  | std::vector< String > & | substrings
| ) |  |

inline static

References String::substr().

## ◆ split_quoted()

static bool split_quoted | ( | const String & | this_s,
|  | const String & | splitter,
|  | std::vector< String > & | substrings,
|  | char | q,
|  | String::QuotingMethod | method
| ) |  |

inline static

References String::ESCAPE, String::NONE, and String::substr().

## ◆ substitute() [1/2]

static String& substitute | ( | String & | this_s,
|  | char | from,
|  | char | to
| ) |  |

inline static

## ◆ substitute() [2/2]

static String& substitute | ( | String & | this_s,
|  | const String & | from,
|  | const String & | to
| ) |  |

inline static

References String::concatenate(), and String::split().

## ◆ substr()

static String substr | ( | const String & | this_s,
|  | size_t | pos,
|  | size_t | n
| ) |  |

inline static

## ◆ suffix() [1/3]

static String suffix | ( | const String & | this_s,
|  | size_t | length
| ) |  |

inline static

References String::substr().

Referenced by DecoyHelper::findDecoyString().

## ◆ suffix() [2/3]

static String suffix | ( | const String & | this_s,
|  | Int | length
| ) |  |

inline static

References String::substr().

## ◆ suffix() [3/3]

static String suffix | ( | const String & | this_s,
|  | char | delim
| ) |  |

inline static

References String::substr().

## ◆ toDouble()

static double toDouble | ( | const String & | s | ) |

inline static

convert String (leading and trailing whitespace allowed) to double

`s` Input string which represents a double, e.g. " 12.3 "

Returns
  A double representation of `s`

Exceptions

  Exception::ConversionError | if the string is not completely explained by the double (whitespaces are allowed)

## ◆ toFloat()

static float toFloat | ( | const String & | this_s | ) |

inline static

## ◆ toInt()

static Int toInt | ( | const String & | this_s | ) |

inline static

## ◆ toLower()

static String& toLower | ( | String & | this_s | ) |

inline static

## ◆ toQString()

static QString toQString | ( | const String & | this_s | ) |

inline static

## ◆ toUpper()

static String& toUpper | ( | String & | this_s | ) |

inline static

Referenced by PeptideIndexing::run().

## ◆ trim()

static String& trim | ( | String & | this_s | ) |

inline static

## ◆ unquote()

static String& unquote | ( | String & | this_s,
|  | char | q,
|  | String::QuotingMethod | method
| ) |  |

inline static

References String::DOUBLE, String::ESCAPE, String::substitute(), and String::substr().

## Member Data Documentation

## ◆ parse_double_

boost::spirit::qi::real_parser<double, real_policies_NANfixed_<double> > parse_double_

static private

## ◆ parse_float_

boost::spirit::qi::real_parser<float, real_policies_NANfixed_<float> > parse_float_

static private