13#include <fast_float/fast_float.h>
25#include "matpack_concepts.h"
50 :
std::basic_string<charT>(n,
c) {}
58 if (!A.size())
return;
64 ARTS_ASSERT(
static_cast<typename std::basic_string<charT>::size_type
>(pos) <
71 (
static_cast<typename std::basic_string<charT>::size_type
>(numpos) <=
83 std::basic_string<charT>::operator=(
84 std::basic_string<charT>(A, pos, numpos));
88 :
std::basic_string<charT>(A) {
92 :
std::basic_string<charT>(
std::string(sv)) {
98 size_t searchstr_size = searchstr.size();
99 size_t insstr_size = insstr.size();
100 size_t start_pos = 0;
102 while (start_pos != std::string::npos) {
103 start_pos = this->find(searchstr, start_pos);
104 if (start_pos && start_pos != std::string::npos) {
105 this->insert(start_pos, insstr);
106 start_pos += searchstr_size + insstr_size;
118 while (oldpos < (
size_t)this->
nelem() &&
119 (pos = this->find(delim, oldpos)) !=
121 if (pos && pos - oldpos)
122 aos.push_back(this->substr(oldpos, pos - oldpos));
123 oldpos = pos + delim.
nelem();
126 if (oldpos < (
size_t)this->
nelem()) aos.push_back(this->substr(oldpos));
131 std::transform(this->begin(), this->end(), this->begin(),
::toupper);
142 std::transform(this->begin(), this->end(), this->begin(),
::tolower);
157 while (0 != this_string.
nelem() &&
158 (
' ' == this_string[0] ||
'\t' == this_string[0] ||
159 '\n' == this_string[0] ||
'\r' == this_string[0]))
160 this_string.erase(0, 1);
163 while (0 != this_string.
nelem() &&
164 (
' ' == this_string[this_string.
nelem() - 1] ||
165 '\t' == this_string[this_string.
nelem() - 1] ||
166 '\n' == this_string[this_string.
nelem() - 1] ||
167 '\r' == this_string[this_string.
nelem() - 1]))
168 this_string.erase(this_string.
nelem() - 1);
173 size_t s = this->size();
175 return static_cast<long>(s);
182 return std::basic_string<charT>::operator[](n);
188 return std::basic_string<charT>::operator[](n);
192 static const Index
npos =
static_cast<Index
>(std::basic_string<charT>::npos);
221 const std::size_t N = n;
223 while (i < N and i < line.size() and isspace(line[i])) ++i;
224 while (n > i and (n-1) < line.size() and isspace(line[n-1])) --n;
226 if constexpr (std::is_same_v<double, T> or std::is_same_v<float, T>) {
227 fast_float::from_chars(line.data() + i, line.data() + n, x);
228 }
else if constexpr (std::is_same_v<long long, T> or
229 std::is_same_v<long, T> or std::is_same_v<int, T>) {
230 std::from_chars(line.data() + i, line.data() + n, x);
235 std::istringstream item(line.substr(i, n));
251 return hash<string>{}(x);
This file contains the definition of Array.
This can be used to make arrays out of anything.
The implementation for String, the ARTS string class.
char & operator[](Index n)
my_basic_string(Index n, char c=' ')
char operator[](Index n) const
void insert_substr(const my_basic_string< charT > &searchstr, const my_basic_string< charT > &insstr)
void split(Array< my_basic_string< charT > > &aos, const my_basic_string< charT > &delim) const
my_basic_string()=default
my_basic_string tolower() const
void trim()
Trim leading and trailing whitespace.
static const Index npos
Define npos:
my_basic_string toupper() const
void toupper()
Convert to upper case.
my_basic_string(const std::basic_string< charT > &A, Index pos=0, Index numpos=my_basic_string< charT >::npos)
my_basic_string(const char *A)
my_basic_string(const std::string_view &sv)
void tolower()
Convert to lower case.
Helper macros for debugging.
#define ARTS_ASSERT(condition,...)
void extract(T &x, String &line, std::size_t n)
Extract something from the beginning of a string.
size_t operator()(const String &x) const