FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
string.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
10#include <kernel/util/half.hpp>
11
12// includes, system
13#include <locale>
14#include <stdexcept>
15#include <string>
16#include <sstream>
17#include <vector>
18#include <deque>
19#include <iomanip>
20#include <cstddef>
21
22#ifdef FEAT_COMPILER_MICROSOFT
23# include <string.h> // for _stricmp
24#endif
25
26#ifndef __CUDACC__
27#ifdef FEAT_HAVE_QUADMATH
28extern "C"
29{
30# include <quadmath.h>
31}
32#endif // FEAT_HAVE_QUADMATH
33#endif // __CUDACC__
34
35namespace FEAT
36{
45 class String
46 : public std::string
47 {
48 public:
63 {
64 public:
74 bool operator()(const String& left, const String& right) const
75 {
76 return left.compare_no_case(right) < 0;
77 }
78 }; // class NoCaseLess
79
80 public:
82 inline String()
83 : std::string()
84 {
85 }
86
88 inline String(const char* str)
89 : std::string(str)
90 {
91 }
92
94 inline String(const char* str, size_type count)
95 : std::string(str, count)
96 {
97 }
98
100 inline String(const std::string& str)
101 : std::string(str)
102 {
103 }
104
105#ifndef __CUDACC__
107 inline String(std::string&& str)
108 : std::string(str)
109 {
110 }
111#endif
112
114 inline String(const String& str)
115 : std::string(str)
116 {
117 }
118
119#ifndef __CUDACC__
121 inline String(String&& str)
122 : std::string(str)
123 {
124 }
125#endif
126
128 inline String(const std::string& str, size_type offset, size_type count = npos)
129 : std::string(str, offset, count)
130 {
131 }
132
134 inline String(size_type count, char c)
135 : std::string(count, c)
136 {
137 }
138
140 String& operator=(const std::string& str)
141 {
142 std::string::operator=(str);
143 return *this;
144 }
145
146#ifndef __CUDACC__
147 String& operator=(std::string&& str)
148 {
149 std::string::operator=(str);
150 return *this;
151 }
152#endif
153
154 String& operator=(const String& str)
155 {
156 std::string::operator=(str);
157 return *this;
158 }
159
160#ifndef __CUDACC__
161 String& operator=(String&& str)
162 {
163 std::string::operator=(str);
164 return *this;
165 }
166#endif
167
168 String& operator=(const char* s)
169 {
170 std::string::operator=(s);
171 return *this;
172 }
173
174 String& append(const std::string& str)
175 {
176 std::string::append(str);
177 return *this;
178 }
179
180 String& append(const std::string& str, size_type pos, size_type n)
181 {
182 std::string::append(str, pos, n);
183 return *this;
184 }
185
186 String& append(const char* s, size_type n)
187 {
188 std::string::append(s, n);
189 return *this;
190 }
191
192 String& append(const char* s)
193 {
194 std::string::append(s);
195 return *this;
196 }
197
198 String& append(size_type n, char c)
199 {
200 std::string::append(n, c);
201 return *this;
202 }
203
204 String& operator+=(const std::string& str)
205 {
206 return append(str);
207 }
208
209 String& operator+=(const char* s)
210 {
211 return append(s);
212 }
213
214 String substr(size_type pos = size_type(0), size_type n = npos) const
215 {
216 return String(std::string::substr(pos, n));
217 }
219
223 static const char* whitespaces()
224 {
225 return " \a\b\f\n\r\t\v";
226 }
227
234 void push_front(char value)
235 {
236 insert(size_type(0), size_type(1), value);
237 }
238
241 {
242 erase(size_type(0), size_type(1));
243 }
244
246 void pop_back()
247 {
248 erase(size() - size_type(1), size_type(1));
249 }
250
262 String trim_front(const String & charset) const
263 {
264 // find first character not to be trimmed
265 size_type pos = find_first_not_of(charset);
266 if(pos == npos)
267 return String();
268 else
269 return substr(pos);
270 }
271
279 {
280 return trim_front(whitespaces());
281 }
282
294 String trim_back(const String & charset) const
295 {
296 // find last character not to be trimmed
297 size_type pos = find_last_not_of(charset);
298 if(pos == npos)
299 return String();
300 else
301 return substr(size_type(0), pos + size_type(1));
302 }
303
311 {
312 return trim_back(whitespaces());
313 }
314
328 String trim(const String & charset) const
329 {
330 // trim front and back
331 return trim_front(charset).trim_back(charset);
332 }
333
342 String trim() const
343 {
344 return trim(whitespaces());
345 }
346
359 String& trim_me(const String & charset)
360 {
361 return (*this = trim(charset));
362 }
363
372 {
373 return (*this = trim());
374 }
375
393 String pad_front(size_type len, char c = ' ') const
394 {
395 size_type l(length());
396 return (l < len) ? String(len - l, c).append(*this) : *this;
397 }
398
416 String pad_back(size_type len, char c = ' ') const
417 {
418 size_type l(length());
419 return (l < len) ? String(*this).append(len - l, c) : *this;
420 }
421
431 String trunc_front(size_type len) const
432 {
433 return length() <= len ? *this : substr(length() - len);
434 }
435
445 String trunc_back(size_type len) const
446 {
447 return length() <= len ? *this : substr(size_type(0), len);
448 }
449
468 std::deque<String> split_by_charset(const String & charset) const
469 {
470 std::deque<String> words;
471 if(empty() || charset.empty())
472 {
473 return words;
474 }
475
476 // find first occurrence of split substring
477 size_type off1(find_first_not_of(charset));
478 if(off1 == npos)
479 {
480 // only delimiter characters; nothing to be extracted
481 return words;
482 }
483
484 // go splitting
485 while(off1 != npos)
486 {
487 // find next occurrence of delimiter string
488 size_type off2(find_first_of(charset, off1));
489
490 // add next split substring to vector
491 if(off2 == npos)
492 {
493 // extract last substring
494 words.push_back(substr(off1));
495 return words;
496 }
497 else
498 {
499 // extract next substring
500 words.push_back(substr(off1, (off2 == npos ? npos : off2 - off1)));
501 }
502
503 // find next occurrence of split substring
504 off1 = find_first_not_of(charset, off2);
505 }
506
507 // okay
508 return words;
509 }
510
519 std::deque<String> split_by_whitespaces() const
520 {
522 }
523
540 std::deque<String> split_by_string(const String & delimiter) const
541 {
542 std::deque<String> words;
543 if(empty() || delimiter.empty())
544 return words;
545
546 // find first occurrence of delimiter substring
547 size_type off1(find(delimiter));
548 words.push_back(substr(0, off1));
549 if(off1 == npos)
550 return words;
551
552 // go splitting
553 const size_type del_len(delimiter.size());
554 while(off1 != npos)
555 {
556 // increase leading offset by delimiter length
557 off1 += del_len;
558
559 // find next substring occurrence
560 size_type off2 = find(delimiter, off1);
561 if(off2 == npos)
562 {
563 // extract last substring
564 words.push_back(substr(off1));
565 return words;
566 }
567 else
568 {
569 // extract next substring
570 words.push_back(substr(off1, off2 - off1));
571 }
572
573 // update offset
574 off1 = off2;
575 }
576
577 // okay
578 return words;
579 }
580
599 size_type replace_all(const String & find_string, const String & replace_string)
600 {
601 size_type flen(find_string.size());
602 size_type rlen(replace_string.size());
603 if(flen <= 0)
604 return size_type(0);
605
606 // find first occurrence of find string
607 size_type pos(find(find_string));
608 size_type counter(size_type(0));
609 while(pos != npos)
610 {
611 // replace substring
612 replace(pos, flen, replace_string);
613
614 // increment counter
615 ++counter;
616
617 // find next occurrence
618 pos = find(find_string, pos + rlen);
619 }
620
621 // return replacement count
622 return counter;
623 }
624
631 String upper() const
632 {
633 String str;
634 str.reserve(size());
635 for(const_iterator it(begin()); it != end(); ++it)
636 {
637#ifdef FEAT_COMPILER_MICROSOFT
638 str.push_back(std::toupper(*it, std::locale::classic()));
639#else
640 std::locale loc;
641 str.push_back(std::toupper<char>(*it, loc));
642#endif
643 }
644 return str;
645 }
646
653 String lower() const
654 {
655 String str;
656 str.reserve(size());
657 for(const_iterator it(begin()); it != end(); ++it)
658 {
659#ifdef FEAT_COMPILER_MICROSOFT
660 str.push_back(std::tolower(*it, std::locale::classic()));
661#else
662 std::locale loc;
663 str.push_back(std::tolower<char>(*it, loc));
664#endif
665 }
666 return str;
667 }
668
680 int compare_no_case(const String& other) const
681 {
682#ifdef FEAT_COMPILER_MICROSOFT
683 // The MS C library offers a function for this task.
684 return _stricmp(c_str(), other.c_str());
685#else
686 // reference implementation
687 std::locale loc;
688 size_type n1 = size();
689 size_type n2 = other.size();
690 size_type n = std::min(n1, n2);
691
692 // loop over all characters and compare them
693 for(size_type i = 0; i < n; ++i)
694 {
695 int k = int(std::tolower<char>((*this)[i], loc)) - int(std::tolower<char>(other[i], loc));
696 if(k < 0)
697 {
698 return -1;
699 }
700 else if(k > 0)
701 {
702 return 1;
703 }
704 }
705
706 // If we come out here, then both strings are identical for the first n characters.
707 // Now let's check whether their length is equal, too.
708 if(n1 < n2)
709 {
710 return -1;
711 }
712 else if(n1 > n2)
713 {
714 return 1;
715 }
716 else
717 {
718 return 0;
719 }
720#endif
721 }
722
732 bool starts_with(const String& head) const
733 {
734 // every string starts with an empty string
735 if(head.empty())
736 return true;
737
738 // check size
739 if(this->size() < head.size())
740 return false;
741
742 // compare head
743 return (this->compare(std::size_t(0), head.size(), head) == 0);
744 }
745
755 bool ends_with(const String& tail) const
756 {
757 // every string ends with an empty string
758 if(tail.empty())
759 return true;
760
761 // check size
762 if(this->size() < tail.size())
763 return false;
764
765 // compare tail
766 return (this->compare(this->size() - tail.size(), tail.size(), tail) == 0);
767 }
768
778 bool starts_with(const char head) const
779 {
780 return (this->empty() ? false : this->front() == head);
781 }
782
792 bool ends_with(const char tail) const
793 {
794 return (this->empty() ? false : this->back() == tail);
795 }
796
812 bool is_one_of(const String& set, const String& sep = " ", bool case_insensitive = false) const
813 {
814 std::deque<String> sset = set.split_by_string(sep);
815 for(const auto& s : sset)
816 {
817 if(case_insensitive)
818 {
819 if(this->compare_no_case(s) == 0)
820 return true;
821 }
822 else if(this->compare(s) == 0)
823 return true;
824 }
825 return false;
826 }
827
837 template<typename T_>
838 bool parse(T_& t) const
839 {
840 std::istringstream iss(trim());
841 iss >> t;
842 return !iss.fail();
843 }
844
846 bool parse(bool& b) const
847 {
848 if(trim().compare_no_case("true") == 0)
849 {
850 b = true;
851 return true;
852 }
853 if(trim().compare_no_case("false") == 0)
854 {
855 b = false;
856 return true;
857 }
858 return false;
859 }
860
861 bool parse(std::string& s) const
862 {
863 s.assign(*this);
864 return true;
865 }
866
867 // This one is really required, as otherwise some compilers choose the
868 // generic template instead of the overload for std::string above...
869 bool parse(String& s) const
870 {
871 s.assign(*this);
872 return true;
873 }
874
875 // Overload for std::uint8_t. Required because the generic parsing via
876 // input stream treats this type as a char and reads only a single character
877 bool parse(std::uint8_t& var) const
878 {
879 try
880 {
881 std::uint64_t tmp = std::stoull(this->c_str());
882 if(tmp <= 255)
883 {
884 var = std::uint8_t(tmp);
885 }
886 else
887 {
888 return false;
889 }
890 }
891 catch(std::invalid_argument& /*e*/)
892 {
893 return false;
894 }
895
896 return true;
897 }
898
899 // Overload for std::int8_t. Required because the generic parsing via
900 // input stream treats this type as a char and reads only a single character
901 bool parse(std::int8_t& var) const
902 {
903 try
904 {
905 std::int64_t tmp = std::stoll(this->c_str());
906 if(-128 <= tmp && tmp <= 127)
907 {
908 var = std::int8_t(tmp);
909 }
910 else
911 {
912 return false;
913 }
914 }
915 catch(std::invalid_argument& /*e*/)
916 {
917 return false;
918 }
919
920 return true;
921 }
922
923 #ifdef FEAT_HAVE_HALFMATH
924 bool parse(Half& t)
925 {
926 float tmp;
927 bool ret = parse(tmp);
928 t = __float2half(tmp);
929 return ret;
930 }
931 #endif
932
933#ifndef __CUDACC__
934#ifdef FEAT_HAVE_QUADMATH
935 bool parse(__float128& x) const
936 {
937 if(this->empty())
938 return false;
939
940 const char* nptr(this->c_str());
941 char* endptr(nullptr);
942 x = strtoflt128(nptr, &endptr);
943 // Note: According to the C-Standard (ISO/IEC 9899:1190 (E), 7.10.1.4 The strod function),
944 // the 'strtod' function sets 'endptr' to 'nptr' if the conversion fails, so we simply
945 // hope that the quadmath function for __float128 honors this convention...
946 return (nptr != endptr);
947 }
948#endif // FEAT_HAVE_QUADMATH
949#endif // __CUDACC__
951 }; // class String
952
954 inline String operator+(const String& a, const String& b)
955 {
956 return String(a).append(b);
957 }
958
959 inline String operator+(const char* a, const String& b)
960 {
961 return String(a).append(b);
962 }
963
964 inline String operator+(const String& a, const char* b)
965 {
966 return String(a).append(b);
967 }
968
969 inline String operator+(const String& a, char c)
970 {
971 return String(a).append(String::size_type(1), c);
972 }
973
974 inline String operator+(char c, const String& b)
975 {
976 return String(String::size_type(1), c).append(b);
977 }
979
992 template<typename T_>
993 inline String stringify(const T_& item)
994 {
995 std::ostringstream oss;
996 oss << item;
997 return oss.str();
998 }
999
1001 inline String stringify(const char* item)
1002 {
1003 return String(item);
1004 }
1005
1006 inline String stringify(const std::string& item)
1007 {
1008 return item;
1009 }
1010
1011 inline String stringify(char item)
1012 {
1013 return String(1, item);
1014 }
1015
1016 inline String stringify(bool item)
1017 {
1018 return String(item ? "true" : "false");
1019 }
1020
1021#ifdef FEAT_HAVE_HALFMATH
1022 inline String stringify(const Half& item)
1023 {
1024 return stringify(__half2float(item));
1025 }
1026#endif
1027
1028#ifndef __CUDACC__
1029 inline String stringify(std::nullptr_t)
1030 {
1031 return String("nullptr");
1032 }
1033
1034#ifdef FEAT_HAVE_QUADMATH
1035 inline String stringify(__float128 value)
1036 {
1037 // get buffer length
1038 int len = ::quadmath_snprintf(nullptr, 0, "%Qg", value);
1039 // allocate buffer
1040 std::vector<char> buffer(len+16);
1041 // print to buffer
1042 quadmath_snprintf(buffer.data(), buffer.size(), "%Qg", value);
1043 // convert buffer to string
1044 return String(buffer.data());
1045 }
1046#endif // FEAT_HAVE_QUADMATH
1047#endif // __CUDACC__
1049
1065 template<typename Iterator_>
1067 Iterator_ first,
1068 Iterator_ last,
1069 const String & delimiter = "")
1070 {
1071 if(first == last)
1072 return String();
1073
1074 Iterator_ it(first);
1075 String str = stringify(*it);
1076
1077 for(++it; it != last; ++it)
1078 str.append(delimiter).append(stringify(*it));
1079
1080 return str;
1081 }
1082
1098 template<typename Container_>
1100 const Container_& container,
1101 const String & delimiter = "")
1102 {
1103 return stringify_join(container.cbegin(), container.cend(), delimiter);
1104 }
1105
1136 template<typename DataType_>
1137 inline String stringify_fp_sci(DataType_ value, int precision = 0, int width = 0, bool sign = false)
1138 {
1139 std::ostringstream oss;
1140 oss << std::scientific;
1141 if(precision > 0)
1142 oss << std::setprecision(precision);
1143 if(width > 0)
1144 oss << std::setw(width);
1145 if(sign)
1146 oss << std::showpos;
1147 oss << value;
1148 return oss.str();
1149 }
1150
1151 #ifdef FEAT_HAVE_HALFMATH
1153 inline String stringify_fp_sci(Half value, int precision = 0, int width = 0, bool sign = false)
1154 {
1155 return stringify_fp_sci(__half2float(value), precision, width, sign);
1156 }
1158 #endif
1159
1190 template<typename DataType_>
1191 inline String stringify_fp_fix(DataType_ value, int precision = 0, int width = 0, bool sign = false)
1192 {
1193 std::ostringstream oss;
1194 oss << std::fixed;
1195 if(precision > 0)
1196 oss << std::setprecision(precision);
1197 if(width > 0)
1198 oss << std::setw(width);
1199 if(sign)
1200 oss << std::showpos;
1201 oss << value;
1202 return oss.str();
1203 }
1204
1205 #ifdef FEAT_HAVE_HALFMATH
1207 inline String stringify_fp_fix(Half value, int precision = 0, int width = 0, bool sign = false)
1208 {
1209 return stringify_fp_fix(__half2float(value), precision, width, sign);
1210 }
1212 #endif
1213
1214#ifndef __CUDACC__
1215#ifdef FEAT_HAVE_QUADMATH
1216 inline String stringify_fp_sci(__float128 value, int precision = 0, int width = 0, bool sign = false)
1217 {
1218 String format("%");
1219 if(sign)
1220 format.append("+");
1221 if(width > 0)
1222 format.append(stringify(width));
1223 if(precision > 0)
1224 {
1225 format.append(".");
1226 format.append(stringify(precision));
1227 }
1228 format.append("Qe");
1229 // get buffer length
1230 int len = ::quadmath_snprintf(nullptr, 0, format.c_str(), value);
1231 // allocate buffer
1232 std::vector<char> buffer(len+16);
1233 // print to buffer
1234 quadmath_snprintf(buffer.data(), buffer.size(), format.c_str(), value);
1235 // convert buffer to string
1236 return String(buffer.data());
1237 }
1238
1239 inline String stringify_fp_fix(__float128 value, int precision = 0, int width = 0, bool sign = false)
1240 {
1241 String format("%");
1242 if(sign)
1243 format.append("+");
1244 if(width > 0)
1245 format.append(stringify(width));
1246 if(precision > 0)
1247 {
1248 format.append(".");
1249 format.append(stringify(precision));
1250 }
1251 format.append("Qf");
1252 // get buffer length
1253 int len = ::quadmath_snprintf(nullptr, 0, format.c_str(), value);
1254 // allocate buffer
1255 std::vector<char> buffer(len+16);
1256 // print to buffer
1257 quadmath_snprintf(buffer.data(), buffer.size(), format.c_str(), value);
1258 // convert buffer to string
1259 return String(buffer.data());
1260 }
1261
1262 inline std::istream& operator>>(std::istream& is, __float128& x)
1263 {
1264 String buffer;
1265 // try to parse a string
1266 if(!(is >> buffer).fail())
1267 {
1268 if(!buffer.parse(x))
1269 {
1270 // parse failed, so put back the string
1271 for(std::size_t i(0); i < buffer.size(); ++i)
1272 is.putback(buffer.at(i));
1273
1274 // set failbit
1275 is.setstate(std::ios_base::failbit);
1276 }
1277 }
1278 return is;
1279 }
1280#endif // FEAT_HAVE_QUADMATH
1281#endif // __CUDACC__
1282
1310 inline String stringify_bytes(std::uint64_t bytes, int precision = 3, int width = 7)
1311 {
1312 // the bounds are chosen such that the output will never have more than 3 leading digits
1313 if(bytes <= 999ull)
1314 return stringify(bytes).pad_front(std::size_t(width)) + " Bytes";
1315 else if(bytes <= 1'022'976ull) // = 999*1024
1316 return stringify_fp_fix(double(bytes) / (1024.), precision, width) + " KiB";
1317 else if(bytes <= 1'047'527'424ull) // = 999*1024^2
1318 return stringify_fp_fix(double(bytes) / (1048576.), precision, width) + " MiB";
1319 else if(bytes <= 1'072'668'082'176ull) // = 999*1024^3
1320 return stringify_fp_fix(double(bytes) / (1073741824.), precision, width) + " GiB";
1321 else if(bytes <= 1'098'412'116'148'224ull) // = 999*1024^4
1322 return stringify_fp_fix(double(bytes) / (1099511627776.), precision, width) + " TiB";
1323 else
1324 return stringify_fp_fix(double(bytes) / (1125899906842624.), precision, width) + " PiB";
1325 }
1326} // namespace FEAT
1327
1328// operator<<(__float128) must reside in the std namespace because gcc/icc search the namespace of ostream for a fitting op<< first
1329// and would otherwise only find op<< with conversions of __float128 to int/double/long etc, which would lead to ambiguous overloads, too.
1330#ifndef __CUDACC__
1331#ifdef FEAT_HAVE_QUADMATH
1332namespace std
1333{
1334 inline std::ostream& operator<<(std::ostream& os, __float128 x)
1335 {
1336 // write to stream
1337 return (os << FEAT::stringify(x));
1338 }
1339}
1340#endif // FEAT_HAVE_QUADMATH
1341#endif // __CUDACC__
FEAT Kernel base header.
A class providing case-insensitive String comparison.
Definition: string.hpp:63
bool operator()(const String &left, const String &right) const
Compares two Strings without regard to case.
Definition: string.hpp:74
String class implementation.
Definition: string.hpp:47
String trunc_front(size_type len) const
Truncates the front of the string to a given maximum length.
Definition: string.hpp:431
void pop_front()
Removes the first character from the string.
Definition: string.hpp:240
String trim() const
Trims the string of all white-spaces.
Definition: string.hpp:342
bool parse(T_ &t) const
Parses the string and stores its value in the provided variable.
Definition: string.hpp:838
String trim_back(const String &charset) const
Trims the back of the string.
Definition: string.hpp:294
String & trim_me()
Trims this string of all white-spaces.
Definition: string.hpp:371
std::deque< String > split_by_string(const String &delimiter) const
Splits the string by a delimiter substring.
Definition: string.hpp:540
String trim_front() const
Trims the front of the string of all white-spaces.
Definition: string.hpp:278
String trim_back() const
Trims the back of the string of all white-spaces.
Definition: string.hpp:310
String trunc_back(size_type len) const
Truncates the back of the string to a given maximum length.
Definition: string.hpp:445
String(std::string &&str)
CTOR.
Definition: string.hpp:107
String(const String &str)
copy CTOR
Definition: string.hpp:114
static const char * whitespaces()
Returns a null-terminated char string containing all white-space characters.
Definition: string.hpp:223
String(const char *str, size_type count)
CTOR.
Definition: string.hpp:94
std::deque< String > split_by_whitespaces() const
Splits the string by white-spaces.
Definition: string.hpp:519
int compare_no_case(const String &other) const
Compares two strings without regard to case.
Definition: string.hpp:680
bool ends_with(const char tail) const
Checks whether this string ends with a specified character.
Definition: string.hpp:792
String trim_front(const String &charset) const
Trims the front of the string.
Definition: string.hpp:262
bool starts_with(const char head) const
Checks whether this string starts with a specified character.
Definition: string.hpp:778
String pad_back(size_type len, char c=' ') const
Pads the back of the string up to a desired length.
Definition: string.hpp:416
bool ends_with(const String &tail) const
Checks whether this string ends with another string.
Definition: string.hpp:755
std::deque< String > split_by_charset(const String &charset) const
Splits the string by a delimiter charset.
Definition: string.hpp:468
String & trim_me(const String &charset)
Trims this string.
Definition: string.hpp:359
void pop_back()
Removes the last character from the string.
Definition: string.hpp:246
bool starts_with(const String &head) const
Checks whether this string starts with another string.
Definition: string.hpp:732
String(const char *str)
CTOR.
Definition: string.hpp:88
String(const std::string &str)
CTOR.
Definition: string.hpp:100
String()
default constructor
Definition: string.hpp:82
String(String &&str)
move CTOR
Definition: string.hpp:121
String(const std::string &str, size_type offset, size_type count=npos)
CTOR.
Definition: string.hpp:128
String pad_front(size_type len, char c=' ') const
Pads the front of the string up to a desired length.
Definition: string.hpp:393
size_type replace_all(const String &find_string, const String &replace_string)
Replaces all occurrences of a substring by another substring.
Definition: string.hpp:599
String trim(const String &charset) const
Trims the string.
Definition: string.hpp:328
void push_front(char value)
Inserts a character at the front of the string.
Definition: string.hpp:234
String upper() const
Converts the string to upper case.
Definition: string.hpp:631
String(size_type count, char c)
CTOR.
Definition: string.hpp:134
bool is_one_of(const String &set, const String &sep=" ", bool case_insensitive=false) const
Checks whether this string is equal to one in a set of strings.
Definition: string.hpp:812
String lower() const
Converts the string to lower case.
Definition: string.hpp:653
std::istream & operator>>(std::istream &is, Pack::Type &t)
stream input operator for Pack::Type
Definition: pack.hpp:178
CUDA_HOST_DEVICE Vector< T_, n_ > operator+(const Vector< T_, n_, sa_ > &a, const Vector< T_, n_, sb_ > &b)
vector addition operator
FEAT namespace.
Definition: adjactor.hpp:12
String stringify_fp_fix(DataType_ value, int precision=0, int width=0, bool sign=false)
Prints a floating point value to a string in fixed-point notation.
Definition: string.hpp:1191
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:993
String stringify_join(Iterator_ first, Iterator_ last, const String &delimiter="")
Joins a sequence of strings.
Definition: string.hpp:1066
__half Half
Half data type.
Definition: half.hpp:25
String stringify_bytes(std::uint64_t bytes, int precision=3, int width=7)
Prints a byte size to a string using the common units Bytes, KiB, MiB, Gib, TiB or PiB.
Definition: string.hpp:1310
String stringify_fp_sci(DataType_ value, int precision=0, int width=0, bool sign=false)
Prints a floating point value to a string in scientific notation.
Definition: string.hpp:1137
@ value
specifies whether the space should supply basis function values