30#include <fast_float/fast_float.h>
67 : std::basic_string<charT>(n,
c) {}
75 if (!A.size())
return;
81 ARTS_ASSERT(
static_cast<typename std::basic_string<charT>::size_type
>(pos) <
88 (
static_cast<typename std::basic_string<charT>::size_type
>(numpos) <=
100 std::basic_string<charT>::operator=(
101 std::basic_string<charT>(A, pos, numpos));
105 : std::basic_string<charT>(A) {
109 : std::basic_string<charT>(std::string(sv)) {
115 size_t searchstr_size = searchstr.size();
116 size_t insstr_size = insstr.size();
117 size_t start_pos = 0;
119 while (start_pos != std::string::npos) {
120 start_pos = this->find(searchstr, start_pos);
121 if (start_pos && start_pos != std::string::npos) {
122 this->insert(start_pos, insstr);
123 start_pos += searchstr_size + insstr_size;
135 while (oldpos < (
size_t)this->
nelem() &&
136 (pos = this->find(delim, oldpos)) !=
138 if (pos && pos - oldpos)
139 aos.push_back(this->substr(oldpos, pos - oldpos));
140 oldpos = pos + delim.
nelem();
143 if (oldpos < (
size_t)this->
nelem()) aos.push_back(this->substr(oldpos));
148 std::transform(this->begin(), this->end(), this->begin(),
::toupper);
159 std::transform(this->begin(), this->end(), this->begin(),
::tolower);
174 while (0 != this_string.
nelem() &&
175 (
' ' == this_string[0] ||
'\t' == this_string[0] ||
176 '\n' == this_string[0] ||
'\r' == this_string[0]))
177 this_string.erase(0, 1);
180 while (0 != this_string.
nelem() &&
181 (
' ' == this_string[this_string.
nelem() - 1] ||
182 '\t' == this_string[this_string.
nelem() - 1] ||
183 '\n' == this_string[this_string.
nelem() - 1] ||
184 '\r' == this_string[this_string.
nelem() - 1]))
185 this_string.erase(this_string.
nelem() - 1);
190 size_t s = this->size();
192 return static_cast<long>(s);
199 return std::basic_string<charT>::operator[](n);
205 return std::basic_string<charT>::operator[](n);
238 const std::size_t
N = n;
240 while (i <
N and i < line.size() and isspace(line[i])) ++i;
241 while (n > i and (n-1) < line.size() and isspace(line[n-1])) --n;
243 if constexpr (std::is_same_v<double, T> or std::is_same_v<float, T>) {
244 fast_float::from_chars(line.data() + i, line.data() + n, x);
245 }
else if constexpr (std::is_same_v<long long, T> or
246 std::is_same_v<long, T> or std::is_same_v<int, T>) {
247 std::from_chars(line.data() + i, line.data() + n, x);
252 std::istringstream item(line.substr(i, n));
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,...)
INDEX Index
The type to use for all integer numbers and indices.
void extract(T &x, String &line, std::size_t n)
Extract something from the beginning of a string.