38 #include <OpenMS/OpenMSConfig.h> 49 template <
typename FloatingPo
intType>
50 struct PrecisionWrapper;
95 OPENMS_DLLAPI
String(
const std::string& s);
97 OPENMS_DLLAPI
String(
const std::string_view& sv);
99 OPENMS_DLLAPI
String(
const QString& s);
101 OPENMS_DLLAPI
String(
const char* s);
103 OPENMS_DLLAPI
String(
const char c);
107 OPENMS_DLLAPI
String(
size_t len,
char c);
109 template <
class InputIterator>
110 String(InputIterator first, InputIterator last) :
111 std::string(first, last)
116 OPENMS_DLLAPI
String(
int i);
118 OPENMS_DLLAPI
String(
unsigned int i);
120 OPENMS_DLLAPI
String(
short int i);
122 OPENMS_DLLAPI
String(
short unsigned int i);
124 OPENMS_DLLAPI
String(
long int i);
126 OPENMS_DLLAPI
String(
long unsigned int i);
128 OPENMS_DLLAPI
String(
long long unsigned int i);
130 OPENMS_DLLAPI
String(
long long signed int i);
132 OPENMS_DLLAPI
String(
float f,
bool full_precision =
true);
134 OPENMS_DLLAPI
String(
double d,
bool full_precision =
true);
136 OPENMS_DLLAPI
String(
long double ld,
bool full_precision =
true);
155 OPENMS_DLLAPI
bool has(
Byte byte)
const;
222 OPENMS_DLLAPI
String substr(
size_t pos = 0,
size_t n = npos)
const;
255 OPENMS_DLLAPI
bool isQuoted(
char q =
'"');
302 OPENMS_DLLAPI
String&
remove(
char what);
351 OPENMS_DLLAPI
float toFloat()
const;
358 OPENMS_DLLAPI
double toDouble()
const;
460 OPENMS_DLLAPI
bool split(
const char splitter, std::vector<String>& substrings,
bool quote_protect =
false)
const;
473 OPENMS_DLLAPI
bool split(
const String& splitter, std::vector<String>& substrings)
const;
489 OPENMS_DLLAPI
bool split_quoted(
const String& splitter, std::vector<String>& substrings,
497 template <
class StringIterator>
503 std::string::clear();
507 std::string::operator=(*first);
508 for (StringIterator it = ++first; it != last; ++it)
510 std::string::operator+=(glue + (*it));
523 return std::hash<string>()(static_cast<string>(s));
String & operator=(const String &)=default
Assignment operator.
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:58
String & quote(char q='"', QuotingMethod method = ESCAPE)
Wraps the string in quotation marks.
String & toUpper()
Converts the string to uppercase.
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:94
String & unquote(char q='"', QuotingMethod method = ESCAPE)
Reverses changes made by the quote method.
std::size_t hash_value(const DPosition< N, T > &b)
Definition: HashGrid.h:458
iterator Iterator
Iterator.
Definition: String.h:70
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:498
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...
const double c
Definition: Constants.h:214
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
static String numberLength(double d, UInt n)
Returns a string with at maximum n characters for d.
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:58
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:110
QuotingMethod
How to handle embedded quotes when quoting strings.
Definition: String.h:81
const_iterator ConstIterator
Const Iterator.
Definition: String.h:72
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.
double toDouble() const
Conversion to double.
OPENMS_INT32_TYPE Int32
Signed integer type (32bit)
Definition: Types.h:56
String & toLower()
Converts the string to lowercase.
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.
Int32 toInt32() const
Conversion to Int32.
reverse_iterator ReverseIterator
Reverse Iterator.
Definition: String.h:74
size_type SizeType
UInt type.
Definition: String.h:78
String & firstToUpper()
Converts the first letter of the string to uppercase.
std::size_t operator()(OpenMS::String const &s) const
Definition: String.h:521
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:127
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:76
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:70
String prefix(SizeType length) const
returns the prefix of length length
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:111
String chop(Size n) const
Returns a substring where n characters were removed from the end of the string.
Int64 toInt64() const
Conversion to Int64.
String & operator+=(int i)
Sum operator for an integer.
int Int
Signed integer type.
Definition: Types.h:102
bool isQuoted(char q='"')
Checks if the string is wrapped in quotation marks.
static const String EMPTY
Empty string for comparisons.
Definition: String.h:64
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
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