35 #ifndef OPENMS_DATASTRUCTURES_STRING_H
36 #define OPENMS_DATASTRUCTURES_STRING_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);
149 OPENMS_DLLAPI
bool has(
Byte byte)
const;
212 OPENMS_DLLAPI
String substr(
size_t pos = 0,
size_t n = npos)
const;
283 OPENMS_DLLAPI
String&
remove(
char what);
311 OPENMS_DLLAPI
float toFloat()
const;
318 OPENMS_DLLAPI
double toDouble()
const;
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>
463 std::string::clear();
467 std::string::operator=(* first);
468 for (StringIterator it = ++first; it != last; ++it)
470 std::string::operator+=(glue + (*it));
478 #endif // OPENMS_DATASTRUCTURES_STRING_H
String chop(Size n) const
Returns a substring where n characters were removed from the end of the string.
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.
A more convenient string class.
Definition: String.h:57
String & toUpper()
Converts the string to uppercase.
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
String()
Default constructor.
String & ensureLastChar(char end)
Makes sure the string ends with the character end.
String & unquote(char q= '"', QuotingMethod method = ESCAPE)
Reverses changes made by the quote method.
bool has(Byte byte) const
true if String contains the byte, false otherwise
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
size_type SizeType
UInt type.
Definition: String.h:77
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
String & quote(char q= '"', QuotingMethod method = ESCAPE)
Wraps the string in quotation marks.
static String numberLength(double d, UInt n)
Returns a string with at maximum n characters for d.
double toDouble() const
Conversion to double.
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:57
String(InputIterator first, InputIterator last)
Constructor from a char range.
Definition: String.h:103
const_reverse_iterator ConstReverseIterator
Const reverse Iterator.
Definition: String.h:75
Int toInt() const
Conversion to int.
String & reverse()
inverts the direction of the string
String & toLower()
Converts the string to lowercase.
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
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.
String & fillLeft(char c, UInt size)
Adds c on the left side until the size of the string is size.
QString toQString() const
Conversion to Qt QString.
String & firstToUpper()
Converts the first letter of the string to uppercase.
const_iterator ConstIterator
Const Iterator.
Definition: String.h:71
QuotingMethod
How to handle embedded quotes when quoting strings.
Definition: String.h:80
static String random(UInt length)
returns a random string of the given length. It consists of [0-9a-zA-Z]
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return)
String prefix(SizeType length) const
returns the prefix of length length
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
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...
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:105
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...
float toFloat() const
Conversion to float.
String & operator+=(int i)
Sum operator for an integer.
String suffix(SizeType length) const
returns the suffix of length length
int Int
Signed integer type.
Definition: Types.h:96
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
static const String EMPTY
Empty string for comparisons.
Definition: String.h:63
reverse_iterator ReverseIterator
Reverse Iterator.
Definition: String.h:73
static String number(double d, UInt n)
returns a string for d with exactly n decimal places
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
iterator Iterator
Iterator.
Definition: String.h:69