|
OpenMS
2.6.0
|
Go to the documentation of this file.
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);
100 OPENMS_DLLAPI
String(
const char* s);
102 OPENMS_DLLAPI
String(
const char c);
106 OPENMS_DLLAPI
String(
size_t len,
char c);
108 template <
class InputIterator>
109 String(InputIterator first, InputIterator last) :
110 std::string(first, last)
115 OPENMS_DLLAPI
String(
int i);
117 OPENMS_DLLAPI
String(
unsigned int i);
119 OPENMS_DLLAPI
String(
short int i);
121 OPENMS_DLLAPI
String(
short unsigned int i);
123 OPENMS_DLLAPI
String(
long 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);
154 OPENMS_DLLAPI
bool has(
Byte byte)
const;
221 OPENMS_DLLAPI
String substr(
size_t pos = 0,
size_t n = npos)
const;
320 OPENMS_DLLAPI
float toFloat()
const;
327 OPENMS_DLLAPI
double toDouble()
const;
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;
458 OPENMS_DLLAPI
bool split_quoted(
const String& splitter, std::vector<String>& substrings,
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));
499 StringView(
const std::string& s) : begin_(s.data()), size_(s.size())
511 if (size_ < other.
size_)
return true;
513 if (size_ > other.
size_)
return false;
517 if (begin_ == other.
begin_)
return false;
519 return strncmp(begin_, other.
begin_, size_) < 0;
524 if (size_ != other.
size_)
return false;
528 if (begin_ == other.
begin_)
return true;
530 return strncmp(begin_, other.
begin_, size_) == 0;
536 if (!size_)
return *
this;
539 sv.
begin_ = begin_ + start;
540 sv.
size_ = std::min(length, sv.
size_ - start);
553 if (!size_)
return String();
554 return String(begin_, begin_ + size_);
571 return std::hash<string>()(static_cast<string>(s));
bool operator==(const StringView other) const
Definition: String.h:522
size_type SizeType
UInt type.
Definition: String.h:79
std::size_t hash_value(const DPosition< N, T > &b)
Definition: HashGrid.h:458
StringView(const std::string &s)
Definition: String.h:499
QuotingMethod
How to handle embedded quotes when quoting strings.
Definition: String.h:82
String & fillLeft(char c, UInt size)
Adds c on the left side until the size of the string is size.
static String random(UInt length)
returns a random string of the given length. It consists of [0-9a-zA-Z]
String getString() const
create String object from view
Definition: String.h:551
const_reverse_iterator ConstReverseIterator
Const reverse Iterator.
Definition: String.h:77
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
reverse_iterator ReverseIterator
Reverse Iterator.
Definition: String.h:75
double toDouble() const
Conversion to double.
A more convenient string class.
Definition: String.h:59
String & trim()
removes whitespaces (space, tab, line feed, carriage return) at the beginning and the end of the stri...
String & removeWhitespaces()
removes whitespaces (space, tab, line feed, carriage return)
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
String prefix(SizeType length) const
returns the prefix of length length
String & operator+=(int i)
Sum operator for an integer.
bool hasPrefix(const String &string) const
true if String begins with string, false otherwise
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
String & operator=(const String &)=default
Assignment operator.
String & simplify()
merges subsequent whitespaces to one blank character
String & firstToUpper()
Converts the first letter of the string to uppercase.
String chop(Size n) const
Returns a substring where n characters were removed from the end of the string.
OPENMS_BYTE_TYPE Byte
Byte type.
Definition: Types.h:111
bool operator<(const StringView other) const
less operator
Definition: String.h:509
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
static String number(double d, UInt n)
returns a string for d with exactly n decimal places
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:56
const char * begin_
Definition: String.h:558
std::size_t operator()(OpenMS::String const &s) const
Definition: String.h:569
bool has(Byte byte) const
true if String contains the byte, false otherwise
StringView provides a non-owning view on an existing string.
Definition: String.h:489
StringView substr(Size start, Size length) const
create view that references a substring of the original string
Definition: String.h:534
bool split(const char splitter, std::vector< String > &substrings, bool quote_protect=false) const
Splits a string into substrings using splitter as delimiter.
QString toQString() const
Conversion to Qt QString.
static const String EMPTY
Empty string for comparisons.
Definition: String.h:65
bool hasSuffix(const String &string) const
true if String ends with string, false otherwise
String & unquote(char q='"', QuotingMethod method = ESCAPE)
Reverses changes made by the quote method.
String & toUpper()
Converts the string to uppercase.
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
String & quote(char q='"', QuotingMethod method = ESCAPE)
Wraps the string in quotation marks.
String & fillRight(char c, UInt size)
Adds c on the right side until the size of the string is size.
StringView(const StringView &s)
Definition: String.h:504
Size size_
Definition: String.h:559
String()
Default constructor.
iterator Iterator
Iterator.
Definition: String.h:71
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 & reverse()
inverts the direction of the string
String & remove(char what)
Remove all occurrences of the character what.
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 & ensureLastChar(char end)
Makes sure the string ends with the character end.
Size size() const
size of view
Definition: String.h:545
StringView()
Definition: String.h:494
static String numberLength(double d, UInt n)
Returns a string with at maximum n characters for d.
String suffix(SizeType length) const
returns the suffix of length length
String(InputIterator first, InputIterator last)
Constructor from a char range.
Definition: String.h:109
const_iterator ConstIterator
Const Iterator.
Definition: String.h:73
Int toInt() const
Conversion to int.
float toFloat() const
Conversion to float.
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 operator+(int i) const
Sum operator for an integer.
String & toLower()
Converts the string to lowercase.