35 #ifndef OPENMS_DATASTRUCTURES_STRING_H    36 #define OPENMS_DATASTRUCTURES_STRING_H    39 #include <OpenMS/OpenMSConfig.h>    90     OPENMS_DLLAPI 
String(
const std::string& s);
    92     OPENMS_DLLAPI 
String(
const QString& s);
    94     OPENMS_DLLAPI 
String(
const char* s);
    96     OPENMS_DLLAPI 
String(
const char c);
    98     OPENMS_DLLAPI 
String(
const char* s, SizeType length);
   100     OPENMS_DLLAPI 
String(
size_t len, 
char c);
   102     template <
class InputIterator>
   103     String(InputIterator first, InputIterator last) :
   104       std::string(first, last)
   110     OPENMS_DLLAPI 
String(
int i);
   112     OPENMS_DLLAPI 
String(
unsigned int i);
   114     OPENMS_DLLAPI 
String(
short int i);
   116     OPENMS_DLLAPI 
String(
short unsigned int i);
   118     OPENMS_DLLAPI 
String(
long int i);
   120     OPENMS_DLLAPI 
String(
long unsigned int i);
   122     OPENMS_DLLAPI 
String(
long long unsigned int i);
   124     OPENMS_DLLAPI 
String(
long long signed int i);
   126     OPENMS_DLLAPI 
String(
float f);
   128     OPENMS_DLLAPI 
String(
double d);
   130     OPENMS_DLLAPI 
String(
long double ld);
   139     OPENMS_DLLAPI 
bool hasPrefix(
const String& 
string) 
const;
   143     OPENMS_DLLAPI 
bool hasSuffix(
const String& 
string) 
const;
   146     OPENMS_DLLAPI 
bool hasSubstring(
const String& 
string) 
const;
   149     OPENMS_DLLAPI 
bool has(
Byte byte) 
const;
   161     OPENMS_DLLAPI String 
prefix(SizeType length) 
const;
   168     OPENMS_DLLAPI String 
suffix(SizeType length) 
const;
   176     OPENMS_DLLAPI String 
prefix(
Int length) 
const;
   184     OPENMS_DLLAPI String 
suffix(
Int length) 
const;
   191     OPENMS_DLLAPI String 
prefix(
char delim) 
const;
   198     OPENMS_DLLAPI String 
suffix(
char delim) 
const;
   212     OPENMS_DLLAPI String 
substr(
size_t pos = 0, 
size_t n = npos) 
const;
   221     OPENMS_DLLAPI String 
chop(
Size n) 
const;
   232     OPENMS_DLLAPI String& 
reverse();
   236     OPENMS_DLLAPI String& 
trim();
   268     OPENMS_DLLAPI String& 
toUpper();
   271     OPENMS_DLLAPI String& 
toLower();
   277     OPENMS_DLLAPI String& 
substitute(
char from, 
char to);
   280     OPENMS_DLLAPI String& 
substitute(
const String& from, 
const String& to);
   283     OPENMS_DLLAPI String& 
remove(
char what);
   311     OPENMS_DLLAPI 
float toFloat() 
const;
   318     OPENMS_DLLAPI 
double toDouble() 
const;
   328     OPENMS_DLLAPI String 
operator+(
int i) 
const;
   331     OPENMS_DLLAPI String 
operator+(
unsigned int i) 
const;
   333     OPENMS_DLLAPI String 
operator+(
short int i) 
const;
   335     OPENMS_DLLAPI String 
operator+(
short unsigned int i) 
const;
   337     OPENMS_DLLAPI String 
operator+(
long int i) 
const;
   339     OPENMS_DLLAPI String 
operator+(
long unsigned int i) 
const;
   341     OPENMS_DLLAPI String 
operator+(
long long unsigned int i) 
const;
   343     OPENMS_DLLAPI String 
operator+(
float f) 
const;
   345     OPENMS_DLLAPI String 
operator+(
double d) 
const;
   347     OPENMS_DLLAPI String 
operator+(
long double ld) 
const;
   349     OPENMS_DLLAPI String 
operator+(
char c) 
const;
   351     OPENMS_DLLAPI String 
operator+(
const char* s) 
const;
   353     OPENMS_DLLAPI String 
operator+(
const String& s) 
const;
   355     OPENMS_DLLAPI String 
operator+(
const std::string& s) 
const;
   364     OPENMS_DLLAPI String& 
operator+=(
unsigned int i);
   366     OPENMS_DLLAPI String& 
operator+=(
short int i);
   368     OPENMS_DLLAPI String& 
operator+=(
short unsigned int i);
   372     OPENMS_DLLAPI String& 
operator+=(
long unsigned int i);
   374     OPENMS_DLLAPI String& 
operator+=(
long long unsigned int i);
   380     OPENMS_DLLAPI String& 
operator+=(
long double d);
   384     OPENMS_DLLAPI String& 
operator+=(
const char* s);
   386     OPENMS_DLLAPI String& 
operator+=(
const String& s);
   388     OPENMS_DLLAPI String& 
operator+=(
const std::string& s);
   392     OPENMS_DLLAPI 
static String 
random(
UInt length);
   395     OPENMS_DLLAPI 
static String 
number(
double d, 
UInt n);
   420     OPENMS_DLLAPI 
bool split(
const char splitter, std::vector<String>& substrings, 
bool quote_protect = 
false) 
const;
   433     OPENMS_DLLAPI 
bool split(
const String& splitter, std::vector<String>& substrings) 
const;
   449     OPENMS_DLLAPI 
bool split_quoted(
const String& splitter, std::vector<String>& substrings,
   457     template <
class StringIterator>
   458     void concatenate(StringIterator first, StringIterator last, 
const String& glue = 
"")
   463         std::string::clear();
   467       std::string::operator=(* first);
   468       for (StringIterator it = ++first; it != last; ++it)
   470         std::string::operator+=(glue + (*it));
   490     StringView(
const std::string& s) : begin_(s.data()), size_(s.size()) 
   502       if (size_ < other.
size_) 
return true;
   504       if (size_ > other.
size_) 
return false;
   507       const char * b = begin_;
   508       const char * bo = other.
begin_;
   510       for (
Size i = 0; i != size_; ++i, ++b, ++bo)
   512         if (*b < *bo) 
return true;
   513         if (*b > *bo) 
return false;
   522       if (!size_) 
return *
this;
   525       sv.
begin_ = begin_ + start_index;
   526       sv.
size_ = end_index - start_index + 1;
   539       if (!size_) 
return String();
   540       return String(begin_, begin_ + size_);
   550 #endif // OPENMS_DATASTRUCTURES_STRING_H String & simplify()
merges subsequent whitespaces to one blank character 
 
String & fillRight(char c, UInt size)
Adds c on the right side until the size of the string is size. 
 
QString toQString() const
Conversion to Qt QString. 
 
bool has(Byte byte) const
true if String contains the byte, false otherwise 
 
A more convenient string class. 
Definition: String.h:57
 
const char * begin_
Definition: String.h:544
 
String & quote(char q='"', QuotingMethod method = ESCAPE)
Wraps the string in quotation marks. 
 
String & toUpper()
Converts the string to uppercase. 
 
bool operator<(const StringView other) const
less operator 
Definition: String.h:500
 
Size size_
Definition: String.h:545
 
String()
Default constructor. 
 
String & ensureLastChar(char end)
Makes sure the string ends with the character end. 
 
unsigned int UInt
Unsigned integer type. 
Definition: Types.h:95
 
String & unquote(char q='"', QuotingMethod method = ESCAPE)
Reverses changes made by the quote method. 
 
iterator Iterator
Iterator. 
Definition: String.h:69
 
void concatenate(StringIterator first, StringIterator last, const String &glue="")
Concatenates all elements from first to last-1 and inserts glue between the elements. 
Definition: String.h:458
 
bool split_quoted(const String &splitter, std::vector< String > &substrings, char q='"', QuotingMethod method = ESCAPE) const 
Splits a string into substrings using splitter (the whole string) as delimiter, but does not split wi...
 
Main OpenMS namespace. 
Definition: FeatureDeconvolution.h:47
 
static String numberLength(double d, UInt n)
Returns a string with at maximum n characters for d. 
 
String getString() const
create String object from view 
Definition: String.h:537
 
Class to hold strings, numeric values, lists of strings and lists of numeric values. 
Definition: DataValue.h:57
 
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
 
String(InputIterator first, InputIterator last)
Constructor from a char range. 
Definition: String.h:103
 
QuotingMethod
How to handle embedded quotes when quoting strings. 
Definition: String.h:80
 
const_iterator ConstIterator
Const Iterator. 
Definition: String.h:71
 
String & reverse()
inverts the direction of the string 
 
String suffix(SizeType length) const
returns the suffix of length length 
 
Int toInt() const
Conversion to int. 
 
StringView(const StringView &s)
Definition: String.h:495
 
double toDouble() const
Conversion to double. 
 
StringView()
Definition: String.h:485
 
String & toLower()
Converts the string to lowercase. 
 
StringView substr(Size start_index, Size end_index) const
create view that references a substring of the original string 
Definition: String.h:520
 
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
 
String operator+(int i) const
Sum operator for an integer. 
 
float toFloat() const
Conversion to float. 
 
String & fillLeft(char c, UInt size)
Adds c on the left side until the size of the string is size. 
 
reverse_iterator ReverseIterator
Reverse Iterator. 
Definition: String.h:73
 
size_type SizeType
UInt type. 
Definition: String.h:77
 
String & firstToUpper()
Converts the first letter of the string to uppercase. 
 
static String random(UInt length)
returns a random string of the given length. It consists of [0-9a-zA-Z] 
 
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise 
 
size_t Size
Size type e.g. used as variable which can hold result of size() 
Definition: Types.h:128
 
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return) 
 
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise 
 
const_reverse_iterator ConstReverseIterator
Const reverse Iterator. 
Definition: String.h:75
 
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to. 
 
String prefix(SizeType length) const
returns the prefix of length length 
 
StringView(const std::string &s)
Definition: String.h:490
 
OPENMS_BYTE_TYPE Byte
Byte type. 
Definition: Types.h:112
 
String chop(Size n) const
Returns a substring where n characters were removed from the end of the string. 
 
String & operator+=(int i)
Sum operator for an integer. 
 
int Int
Signed integer type. 
Definition: Types.h:103
 
static const String EMPTY
Empty string for comparisons. 
Definition: String.h:63
 
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter. 
 
StringView provides a non-owning view on an existing string. 
Definition: String.h:480
 
Size size() const
size of view 
Definition: String.h:531
 
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise 
 
static String number(double d, UInt n)
returns a string for d with exactly n decimal places