38 #include <OpenMS/OpenMSConfig.h>
50 template <
typename FloatingPo
intType>
51 struct PrecisionWrapper;
96 OPENMS_DLLAPI
String(
const std::string& s);
98 OPENMS_DLLAPI
String(
const QString& s);
108 template <
class InputIterator>
109 String(InputIterator first, InputIterator last) :
110 std::string(first, last)
121 OPENMS_DLLAPI
String(
short unsigned int i);
125 OPENMS_DLLAPI
String(
long unsigned int i);
127 OPENMS_DLLAPI
String(
long long unsigned int i);
129 OPENMS_DLLAPI
String(
long long signed int i);
131 OPENMS_DLLAPI
String(
float f,
bool full_precision =
true);
133 OPENMS_DLLAPI
String(
double d,
bool full_precision =
true);
135 OPENMS_DLLAPI
String(
long double ld,
bool full_precision =
true);
429 OPENMS_DLLAPI
bool split(
const char splitter, std::vector<String>& substrings,
bool quote_protect =
false)
const;
442 OPENMS_DLLAPI
bool split(
const String& splitter, std::vector<String>& substrings)
const;
466 template <
class StringIterator>
472 std::string::clear();
476 std::string::operator=(* first);
477 for (StringIterator it = ++first; it != last; ++it)
479 std::string::operator+=(glue + (*it));
503 StringView(
const std::string& s) : begin_(s.data()), size_(s.size())
510 if (size_ < other.
size_)
return true;
512 if (size_ > other.
size_)
return false;
516 if (begin_ == other.
begin_)
return false;
518 return strncmp(begin_, other.
begin_, size_) < 0;
523 if (size_ != other.
size_)
return false;
527 if (begin_ == other.
begin_)
return true;
529 return strncmp(begin_, other.
begin_, size_) == 0;
535 if (!size_)
return *
this;
538 sv.
begin_ = begin_ + start;
539 sv.
size_ = std::min(length, sv.
size_ - start);
552 if (!size_)
return String();
553 return String(begin_, begin_ + size_);
570 return std::hash<string>()(
static_cast<string>(s));
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:59
StringView provides a non-owning view on an existing string.
Definition: String.h:490
StringView(const StringView &)=default
StringView substr(Size start, Size length) const
create view that references a substring of the original string
Definition: String.h:533
const char * begin_
Definition: String.h:557
bool operator<(const StringView other) const
less operator
Definition: String.h:508
StringView & operator=(const StringView &)=default
StringView(const std::string &s)
Definition: String.h:503
Size size() const
size of view
Definition: String.h:544
String getString() const
create String object from view
Definition: String.h:550
bool operator==(const StringView other) const
Definition: String.h:521
Size size_
Definition: String.h:558
A more convenient string class.
Definition: String.h:61
String(long long unsigned int i)
Constructor from an unsigned integer.
String & substitute(const String &from, const String &to)
Replaces all occurrences of the string from by the string to.
String & operator+=(int i)
Sum operator for an integer.
const_reverse_iterator ConstReverseIterator
Const reverse Iterator.
Definition: String.h:77
String & fillRight(char c, UInt size)
Adds c on the right side until the size of the string is size.
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(float f, bool full_precision=true)
Constructor from float (full_precision controls number of fractional digits, 3 digits when false,...
String & operator+=(short unsigned int i)
Sum operator for an unsigned integer.
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
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...
String & simplify()
merges subsequent whitespaces to one blank character
String(long int i)
Constructor from an integer.
String chop(Size n) const
Returns a substring where n characters were removed from the end of the string.
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
String(const DataValue &d, bool full_precision=true)
Constructor from DataValue (full_precision controls number of fractional digits for all double types ...
reverse_iterator ReverseIterator
Reverse Iterator.
Definition: String.h:75
String & remove(char what)
Remove all occurrences of the character what.
String & operator+=(long int i)
Sum operator for an integer.
String & operator+=(const char *s)
Sum operator for char*.
String & operator+=(double d)
Sum operator for double.
String prefix(SizeType length) const
returns the prefix of length length
String & firstToUpper()
Converts the first letter of the string to uppercase.
String prefix(char delim) const
returns the prefix up to the first occurrence of char delim (excluding it)
iterator Iterator
Iterator.
Definition: String.h:71
bool has(Byte byte) const
true if String contains the byte, false otherwise
Int toInt() const
Conversion to int.
String(const char c)
Constructor from a char.
String & operator=(const String &)=default
Assignment operator.
String & operator+=(long unsigned int i)
Sum operator for an unsigned integer.
String & operator+=(unsigned int i)
Sum operator for an unsigned integer.
String(long long signed int i)
Constructor from an unsigned integer.
double toDouble() const
Conversion to double.
String(const std::string &s)
Constructor from std::string.
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return)
String(int i)
Constructor from an integer.
QString toQString() const
Conversion to Qt QString.
String & reverse()
inverts the direction of the string
String operator+(char c) const
Sum operator for char.
String operator+(int i) const
Sum operator for an integer.
String operator+(long int i) const
Sum operator for an integer.
const_iterator ConstIterator
Const Iterator.
Definition: String.h:73
QuotingMethod
How to handle embedded quotes when quoting strings.
Definition: String.h:82
@ ESCAPE
Definition: String.h:82
@ DOUBLE
Definition: String.h:82
@ NONE
Definition: String.h:82
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
String(const char *s, SizeType length)
Constructor from char* (only length characters)
String & unquote(char q='"', QuotingMethod method = ESCAPE)
Reverses changes made by the quote method.
String & operator+=(short int i)
Sum operator for an integer.
String operator+(const char *s) const
Sum operator for char*.
String operator+(short unsigned int i) const
Sum operator for an unsigned integer.
String(short unsigned int i)
Constructor from an unsigned integer.
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
String(const char *s)
Constructor from char*.
String operator+(double d) const
Sum operator for double.
String()
Default constructor.
String(String &&)=default
Move constructor.
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
String & toLower()
Converts the string to lowercase.
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
static String numberLength(double d, UInt n)
Returns a string with at maximum n characters for d.
String operator+(float f) const
Sum operator for float.
String & operator+=(char c)
Sum operator for char.
String & fillLeft(char c, UInt size)
Adds c on the left side until the size of the string is size.
String & operator+=(long double d)
Sum operator for long double.
String & operator+=(float f)
Sum operator for float.
String(const String &)=default
Copy constructor.
String operator+(const std::string &s) const
Sum operator for std::string.
String & quote(char q='"', QuotingMethod method = ESCAPE)
Wraps the string in quotation marks.
size_type SizeType
UInt type.
Definition: String.h:79
String prefix(Int length) const
returns the prefix of length length
String operator+(long unsigned int i) const
Sum operator for an unsigned integer.
String suffix(char delim) const
returns the suffix up to the last occurrence of char delim (excluding it)
String(double d, bool full_precision=true)
Constructor from double (full_precision controls number of fractional digits, 3 digits when false,...
String(size_t len, char c)
Constructor from char (repeats the char len times)
String(InputIterator first, InputIterator last)
Constructor from a char range.
Definition: String.h:109
String(long double ld, bool full_precision=true)
Constructor from long double (full_precision controls number of fractional digits,...
String(long unsigned int i)
Constructor from an unsigned integer.
static String random(UInt length)
returns a random string of the given length. It consists of [0-9a-zA-Z]
String & ensureLastChar(char end)
Makes sure the string ends with the character end.
String operator+(long double ld) const
Sum operator for long double.
String suffix(SizeType length) const
returns the suffix of length length
String & operator+=(long long unsigned int i)
Sum operator for an unsigned integer.
String operator+(short int i) const
Sum operator for an integer.
String operator+(const String &s) const
Sum operator for String.
String suffix(Int length) const
returns the suffix of length length
String(short int i)
Constructor from an integer.
bool split(const String &splitter, std::vector< String > &substrings) const
Splits a string into substrings using splitter (the whole string) as delimiter.
String operator+(unsigned int i) const
Sum operator for an unsigned integer.
static String number(double d, UInt n)
returns a string for d with exactly n decimal places
static const String EMPTY
Empty string for comparisons.
Definition: String.h:65
String(unsigned int i)
Constructor from an unsigned integer.
float toFloat() const
Conversion to float.
String & operator=(String &&) &=default
Move assignment operator.
String operator+(long long unsigned int i) const
Sum operator for an unsigned integer.
String & operator+=(const std::string &s)
Sum operator for std::string.
String(const QString &s)
Constructor from Qt QString.
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:467
String & toUpper()
Converts the string to uppercase.
String & operator+=(const String &s)
Sum operator for String.
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:111
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const double c
Definition: Constants.h:209
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::size_t hash_value(const DPosition< N, T > &b)
Definition: HashGrid.h:458
std::size_t operator()(OpenMS::String const &s) const
Definition: String.h:568