43 #define RC_REGEX_NS std
47 #include <boost/regex.hpp>
48 #define RC_REGEX_NS boost
115 static inline size_t strnlen(
const char *s,
size_t n) {
117 for (i=0; i<n; i++) {
126 template<
class InputIterator>
127 inline void FindNullTerm(InputIterator& first, InputIterator& last) {
128 for(InputIterator iter = first; iter != last; ++iter) {
129 if (0 ==
char(*iter)) {
152 inline RStr(
const std::string& str)
161 str = std::string(s.str, pos, n);
166 inline RStr(
const char *s,
size_t n) {
168 size_t len = strnlen(s, n);
169 if (len < n) { n = len; }
170 str = std::string(s, n);
178 str = std::string(s);
184 : str (std::string(n, c)) {
188 template <
class InputIterator>
195 inline RStr(
const std::initializer_list<char> characters)
238 str = std::move(other.str);
258 return RStrIter(
this, str.length());
263 inline size_t size()
const {
return str.size(); }
265 inline size_t length()
const {
return str.length(); }
267 inline size_t max_size()
const {
return str.max_size(); }
269 inline void resize(
size_t n,
char c) { str.resize(n, c); }
271 inline void resize(
size_t n) { str.resize(n); }
274 return str.capacity();
277 inline void reserve(
size_t capsize=0 ) { str.reserve(capsize); }
279 inline void clear() { str.clear(); }
281 inline bool empty()
const {
return str.empty(); }
297 inline char&
at(
size_t pos) {
303 inline const char&
at(
size_t pos)
const {
337 str.
append(s.str, pos, n);
346 size_t len = strnlen(s, n);
347 if (len < n) { n = len; }
368 template <
class InputIterator>
369 inline RStr&
append(InputIterator first, InputIterator last) {
370 FindNullTerm(first, last);
371 str.append(first, last);
377 inline RStr&
append (std::initializer_list<char> characters) {
394 str.
assign(s.str, pos, n);
402 size_t len = strnlen(s, n);
403 if (len < n) { n = len; }
406 else { str.clear(); }
416 else { str.
clear(); }
428 template <
class InputIterator>
429 inline RStr&
assign(InputIterator first, InputIterator last) {
430 FindNullTerm(first, last);
431 str.assign(first, last);
440 str.insert(pos_this, s.str);
450 size_t pos_s,
size_t n) {
453 str.insert(pos_this, s.str, pos_s, n);
460 inline RStr&
insert(
size_t pos_this,
const char* s,
size_t n) {
464 str.insert(pos_this, s, n);
474 str.insert(pos_this, s);
482 str.insert(pos_this, n, c);
499 template <
class InputIterator>
501 FindNullTerm(first, last);
503 str.insert(str.begin()+p.
GetIndex(), first, last);
509 std::initializer_list<char> characters) {
533 if (last_i > first_i) {
534 erase(first_i, last_i - first_i);
543 erase(pos_this, n_this);
556 const RStr& s,
size_t pos_s,
size_t n_s) {
557 erase(pos_this, n_this);
558 insert(pos_this, s, pos_s, n_s);
564 inline RStr&
replace(
size_t pos_this,
size_t n_this,
const char* s,
566 erase(pos_this, n_this);
574 const char* s,
size_t n_s) {
580 inline RStr&
replace(
size_t pos_this,
size_t n_this,
const char* s) {
581 erase(pos_this, n_this);
593 inline RStr&
replace(
size_t pos_this,
size_t n_this,
size_t n_c,
char c) {
594 erase(pos_this, n_this);
607 template <
class InputIterator>
609 InputIterator in_first, InputIterator in_last) {
611 insert(first, in_first, in_last);
627 inline const char*
data()
const {
634 return str.get_allocator();
644 inline size_t copy(
char *s,
size_t n,
size_t pos=0)
const {
647 return str.copy(s, n, pos);
653 inline size_t find(
const RStr& s,
size_t pos=0)
const {
654 return str.find(s.str, pos);
659 inline size_t find(
const char* s,
size_t pos,
size_t n)
const {
661 if (strnlen(s, n) < n) {
664 return str.find(s, pos, n);
669 inline size_t find(
const char* s,
size_t pos=0)
const {
671 return str.find(s, pos);
675 inline size_t find(
char c,
size_t pos=0)
const {
676 return str.find(c, pos);
683 return str.rfind(s.str, pos);
688 inline size_t rfind(
const char* s,
size_t pos,
size_t n)
const {
690 if (strnlen(s, n) < n) {
693 return str.rfind(s, pos, n);
698 inline size_t rfind(
const char* s,
size_t pos=
npos)
const {
700 return str.rfind(s, pos);
705 return str.rfind(c, pos);
712 return str.find_first_of(s.str, pos);
719 size_t len = strnlen(s, n);
720 if (len < n) { n = len; }
721 return str.find_first_of(s, pos, n);
728 return str.find_first_of(s, pos);
733 return str.find_first_of(c, pos);
740 return str.find_last_of(s.str, pos);
745 inline size_t find_last_of(
const char* s,
size_t pos,
size_t n)
const {
747 size_t len = strnlen(s, n);
748 if (len < n) { n = len; }
749 return str.find_last_of(s, pos, n);
756 return str.find_last_of(s, pos);
762 return str.find_last_of(c, pos);
769 return str.find_first_not_of(s.str, pos);
776 size_t len = strnlen(s, n);
777 if (len < n) { n = len; }
778 return str.find_first_not_of(s, pos, n);
785 return str.find_first_not_of(s, pos);
791 return str.find_first_not_of(c, pos);
798 return str.find_last_not_of(s.str, pos);
805 size_t len = strnlen(s, n);
806 if (len < n) { n = len; }
807 return str.find_last_not_of(s, pos, n);
814 return str.find_last_not_of(s, pos);
820 return str.find_last_not_of(c, pos);
828 return RStr(str.substr(pos, n));
835 return str.compare(s.str);
842 return str.compare(s);
847 inline int compare(
size_t pos_this,
size_t n_this,
const RStr& s)
const {
849 return str.compare(pos_this, n_this, s.str);
854 inline int compare(
size_t pos_this,
size_t n_this,
const char* s)
const {
857 return str.compare(pos_this, n_this, s);
862 inline int compare(
size_t pos_this,
size_t n_this,
863 const RStr& s,
size_t pos_s,
size_t n_s)
const {
866 return str.compare(pos_this, n_this, s.str, pos_s, n_s);
871 inline int compare(
size_t pos_this,
size_t n_this,
872 const char* s,
size_t n_s)
const {
875 size_t len = strnlen(s, n_s);
876 if (len < n_s) { n_s = len; }
877 return str.compare(pos_this, n_this, s, n_s);
892 char basetable[37] =
"0123456789abcdefghijklmnopqrstuvwxyz";
895 case BIN: base = 2;
break;
897 case OCT: base = 8;
break;
898 case DEC: base = 10;
break;
900 case HEX: base = 16;
break;
901 case CHAR: str = char(x);
return;
904 if (base < 1 || base > 36) {
908 if (pad_to < 0 && base == 16) {
909 pad_to =
i32(
sizeof(x) << 1);
916 arr += basetable[-(x%base)];
922 arr += basetable[x%base];
928 if (pad_to > 0 && arr.
size() < size_t(pad_to)) {
929 pad_by = pad_to - arr.
size();
933 str.reserve(str.size() + pad_to + arr.
size() + 1);
937 str.reserve(str.size() + pad_to + arr.
size());
943 else if (style == HEX0x) {
947 for (
size_t i=0; i<pad_by; i++) {
951 for (
size_t i=0; i<arr.
size(); i++) {
952 str += arr[arr.
size()-1-i];
958 u32 precision=std::numeric_limits<T>::digits10) {
960 unsigned int previous_output_format;
961 previous_output_format = _set_output_format(_TWO_DIGIT_EXPONENT);
964 std::stringstream ss;
966 ss.setf(std::ios::scientific, std::ios::floatfield);
969 else if (style == FIXED) {
970 ss.setf(std::ios::fixed, std::ios::floatfield);
972 ss.precision(precision);
977 _set_output_format(previous_output_format);
998 ParseInt(x, style, precision); \
1002 #define RC_RSTR_Int_Input(TYPE) \
1005 inline RStr(TYPE x, RStr_IntStyle style=DEC, i32 precision=-1) { \
1006 ParseInt(x, style, precision); \
1022 #define RC_RSTR_Float_Input(TYPE) \
1029 inline RStr(TYPE x, RStr_FloatStyle style=AUTO, \
1030 u32 precision=std::numeric_limits<TYPE>::digits10) { \
1031 ParseFloat(x, style, precision); \
1041 inline RStr(
bool b) {
1042 str = b ?
"true" :
"false";
1048 inline RStr(
bool pad0s,
void *ptr,
bool use0x=
true) {
1049 u32 precision = pad0s ? (2*
sizeof(ptr)) : 1;
1052 ParseInt(
size_t(ptr), HEX0x, precision);
1055 ParseInt(
size_t(ptr), HEX, precision);
1064 char *s =
reinterpret_cast<char*
>(arr.
Raw());
1068 str = std::string(s, n);
1074 inline RStr(
const std::wstring& wstr) {
1075 str.assign(wstr.begin(), wstr.end());
1081 inline RStr(
const QString &qstr) {
1082 str = qstr.toStdString();
1091 inline f32 Get_f32()
const {
return strtof(str.c_str(), NULL); }
1093 inline f64 Get_f64()
const {
return strtod(str.c_str(), NULL); }
1096 inline f80 Get_f80()
const {
return strtold(str.c_str(), NULL); }
1105 {
return strtoul(str.c_str(), NULL, base); }
1108 {
return strtoull(str.c_str(), NULL, base); }
1111 {
return strtol(str.c_str(), NULL, base); }
1114 {
return strtoll(str.c_str(), NULL, base); }
1130 if (tmp.str ==
"true" || tmp.str ==
"t") {
1151 inline
bool Is_f32(
bool strict=false)
const {
1154 f32 x = strtof(str.c_str(), &test);
1156 bool retval = (errno == 0);
1157 if (strict) { retval = retval && (test == str.c_str()+str.length()); }
1158 else { retval = retval && (test != str.c_str()); }
1164 inline bool Is_f64(
bool strict=
false)
const {
1167 f64 x = strtod(str.c_str(), &test);
1169 bool retval = (errno == 0);
1170 if (strict) { retval = retval && (test == str.c_str()+str.length()); }
1171 else { retval = retval && (test != str.c_str()); }
1178 inline bool Is_f80(
bool strict=
false)
const {
1181 f80 x = strtold(str.c_str(), &test);
1183 bool retval = (errno == 0);
1184 if (strict) { retval = retval && (test == str.c_str()+str.length()); }
1185 else { retval = retval && (test != str.c_str()); }
1194 inline bool Is_u32(
int base=0,
bool strict=
false)
const {
1197 u32 x = strtoul(str.c_str(), &test, base);
1199 bool retval = (errno == 0);
1201 retval = retval && (test == str.c_str()+str.length())
1204 else { retval = retval && (test != str.c_str()); }
1212 inline bool Is_u64(
int base=0,
bool strict=
false)
const {
1215 u64 x = strtoull(str.c_str(), &test, base);
1217 bool retval = (errno == 0);
1219 retval = retval && (test == str.c_str()+str.length())
1222 else { retval = retval && (test != str.c_str()); }
1230 inline bool Is_i32(
int base=0,
bool strict=
false)
const {
1233 i32 x = strtol(str.c_str(), &test, base);
1235 bool retval = (errno == 0);
1236 if (strict) { retval = retval && (test == str.c_str()+str.length()); }
1237 else { retval = retval && (test != str.c_str()); }
1245 inline bool Is_i64(
int base=0,
bool strict=
false)
const {
1248 i64 x = strtoll(str.c_str(), &test, base);
1250 bool retval = (errno == 0);
1251 if (strict) { retval = retval && (test == str.c_str()+str.length()); }
1252 else { retval = retval && (test != str.c_str()); }
1261 return Is_u32(16, strict);
1267 return Is_u64(16, strict);
1273 if (str ==
"0" || str ==
"1") {
1279 if (tmp.str ==
"true" || tmp.str ==
"false" ||
1280 tmp.str ==
"t" || tmp.str ==
"f") {
1290 return QString::fromStdString(str);
1295 inline std::wstring
wstring() {
1297 wstr.assign(str.begin(), str.end());
1303 inline const char*
ToLPCSTR()
const {
1312 hr.Set(hr.Held().c_str());
1316 inline HoldRelated<std::wstring, const wchar_t*>
ToLPCTSTR() {
1331 inline std::string&
Raw() {
return str; }
1334 inline const std::string&
Raw()
const {
return str; }
1351 inline bool Check(
size_t pos)
const {
1352 return (pos < str.length());
1356 inline bool CheckPlus(
size_t pos)
const {
1357 return (pos <= str.length());
1361 inline void Assert(
size_t pos)
const {
1362 if ( !
Check(pos) ) {
1377 inline void Assert(
const char* ptr)
const {
1391 inline RStr&
PadLeft(
const size_t pad_to,
const char pad_with=
' ') {
1404 inline RStr&
PadRight(
const size_t pad_to,
const char pad_with=
' ') {
1414 inline RStr&
PadCenter(
const size_t pad_to,
const char pad_with=
' ') {
1416 size_t diff = pad_to -
length();
1417 size_t half = diff/2;
1418 PadLeft(pad_to - diff + half, pad_with);
1426 inline Data1D<RStr>
Wrap(
const size_t width) {
1427 Data1D<RStr> wrapped;
1431 size_t this_width, end_pos;
1432 size_t search_end = pos + width;
1434 for(end_pos=pos; end_pos < search_end; end_pos++) {
1435 if (str[end_pos] ==
'\n') {
break; }
1437 if (end_pos < search_end) {
1439 this_width = end_pos - pos;
1440 if (end_pos > 0 && str[end_pos-1] ==
'\r') {
1443 wrapped +=
substr(pos, this_width);
1447 wrapped +=
substr(pos, width);
1465 size_t search_end = pos + width;
1466 if (search_end >
length()) {
1470 for(end_pos=pos; end_pos < search_end; end_pos++) {
1471 if (str[end_pos] ==
'\n') {
break; }
1473 if (end_pos < search_end) {
1475 this_width = end_pos - pos;
1476 if (end_pos > 0 && str[end_pos-1] ==
'\r') {
1479 wrapped +=
substr(pos, this_width);
1484 size_t try_pos = pos+width;
1487 if (end_pos ==
npos || end_pos < pos) {
1489 end_pos = pos+width;
1492 this_width = end_pos - pos;
1495 wrapped +=
substr(pos, this_width);
1506 #ifdef RC_RSTR_REGEX
1513 inline bool Match(
const RC_REGEX_NS::regex& reg) {
1514 return RC_REGEX_NS::regex_search(str, reg);
1518 RC_REGEX_NS::regex reg(regstr.
c_str());
1529 RC_REGEX_NS::cmatch matcharr;
1531 result = RC_REGEX_NS::regex_search(str.c_str(), matcharr, reg);
1536 for (
size_t i=1; i<matcharr.size(); i++) {
1537 tmp.
assign(matcharr[i].first, matcharr[i].second);
1546 inline bool Match(
const RStr& regstr, Data1D<RStr>& matches) {
1547 RC_REGEX_NS::regex reg(regstr.c_str());
1548 return Match(reg, matches);
1553 inline void Subst(
const RC_REGEX_NS::regex& reg,
const RStr& subst) {
1554 str = RC_REGEX_NS::regex_replace(str, reg, subst.str);
1558 RC_REGEX_NS::regex reg(regstr.
c_str());
1576 size_t res =
find(s, pos);
1585 end = str.find_last_not_of(chomp_chars.str);
1598 inline RStr&
Trim(
const RStr& trim_chars =
" \t\r\n") {
1602 end = str.find_last_not_of(trim_chars.str);
1607 start = str.find_first_not_of(trim_chars.str);
1608 str = str.substr(start,
end-start+1);
1628 for (i=0; i<str.length(); i++) {
1629 str[i] = tolower(str[i]);
1638 for (i=0; i<str.length(); i++) {
1639 str[i] = toupper(str[i]);
1646 inline Data1D<RStr>
Split(
char c)
const {
1647 Data1D<RStr> retval;
1652 while (start <= str.length()) {
1653 end = str.find_first_of(c, start);
1655 retval.Append(str.substr(start,
npos));
1659 retval.Append(str.substr(start,
end-start));
1674 mid = str.find_first_of(dividers.str, 0);
1676 retval[0] = str.substr(0,
npos);
1679 retval[0] = str.substr(0, mid);
1680 if ((mid+1) < str.length()) {
1681 retval[1] = str.substr(mid+1,
npos);
1694 mid = str.find_last_of(dividers.str,
npos);
1696 retval[0] = str.substr(0,
npos);
1699 retval[0] = str.substr(0, mid);
1700 if ((mid+1) < str.length()) {
1701 retval[1] = str.substr(mid+1,
npos);
1718 while (
end < str.length()) {
1719 start = str.find_first_not_of(dividers.str,
end);
1720 if (start ==
npos) {
1723 end = str.find_first_of(dividers.str, start);
1727 retval.
Append(str.substr(start,
end-start));
1730 if (retval.
size() == 0) { retval +=
""; }
1749 const RStr& spacer=
"",
1750 RStr(*func)(
const T&)=
nullptr) {
1754 if (str_arr.
size() == 0) {
1759 if (func ==
nullptr) {
1760 func = [](
const T& in) {
return RStr(in); };
1763 retval = func(str_arr[0]);
1765 for (i=1; i<str_arr.
size(); i++) {
1767 retval += func(str_arr[i]);
1781 size_t thislen =
length();
1782 size_t otherlen = other.
length();
1789 size_t subst_cnt, insert_cnt;
1790 for (i=0; i<count.
size1(); i++) {
1794 for (i=0; i<otherlen; i++) {
1795 count[curr_ind][0] = i+1;
1797 for (j=0; j<thislen; j++) {
1798 insert_cnt = std::min(1+count[curr_ind][j], 1+count[prev_ind][1+j]);
1799 subst_cnt = count[prev_ind][j] + ((str[j] == ch) ? 0 : 1);
1800 count[curr_ind][j+1] = std::min(insert_cnt, subst_cnt);
1807 return count[prev_ind][thislen];
1814 inline size_t Length8()
const {
1816 for (
size_t i=0; i<str.length(); i++) {
1826 for (
u32 parts=1; (parts<cnt); parts++) {
1828 if (i >= str.length() || (((
u8(str[i])) & 0xC0)!=0x80)) {
1849 retval =
Split(divider);
1851 for (i=0; i<retval.
size(); i++) {
1865 const RStr& divider=
", ") {
1869 if (arr.
size() == 0) {
1874 retval =
RStr(arr[0]);
1876 for (i=1; i<arr.
size(); i++) {
1878 retval +=
RStr(arr[i]);
1891 const RStr& divider1=
", ",
const RStr& divider2=
"\n") {
1895 for (i=0; i<arr.
size2(); i++) {
1896 retval +=
MakeCSV(arr[i], divider1);
1911 const RStr& divider1=
", ",
const RStr& divider2=
"\n",
1912 const RStr& divider3=
"\n") {
1916 if (arr.
size3() == 0) {
1921 retval =
MakeCSV(arr[0], divider1, divider2);
1923 for (i=1; i<arr.
size3(); i++) {
1925 retval +=
MakeCSV(arr[i], divider1, divider2);
1936 for (
size_t i=0; i<str.length(); i++) {
1937 if ((
u8(str[i])) < 0x80) {
1941 if ((
u8(str[i])) < 0xA0) {
1943 u8 win1252[4*0x20] = {0xe2,0x82,0xac,0,0x81,0,0,0,
1944 0xe2,0x80,0x9a,0,0xc6,0x92,0,0,0xe2,0x80,0x9e,0,
1945 0xe2,0x80,0xa6,0,0xe2,0x80,0xa0,0,0xe2,0x80,0xa1,0,
1946 0xcb,0x86,0,0,0xe2,0x80,0xb0,0,0xc5,0xa0,0,0,
1947 0xe2,0x80,0xb9,0,0xc5,0x92,0,0,0x8d,0,0,0,0xc5,0xbd,0,0,
1948 0x8f,0,0,0,0x90,0,0,0,0xe2,0x80,0x98,0,0xe2,0x80,0x99,0,
1949 0xe2,0x80,0x9c,0,0xe2,0x80,0x9d,0,0xe2,0x80,0xa2,0,
1950 0xe2,0x80,0x93,0,0xe2,0x80,0x94,0,0xcb,0x9c,0,0,
1951 0xe2,0x84,0xa2,0,0xc5,0xa1,0,0,0xe2,0x80,0xba,0,
1952 0xc5,0x93,0,0,0x9d,0,0,0,0xc5,0xbe,0,0,0xc5,0xb8,0,0};
1953 utf8 +=
RStr(
reinterpret_cast<char*
>(
1954 &win1252[4*(
u8(str[i])-0x80)]));
1958 utf8 += (str[i] & 0x40) ? 0xc3 : 0xc2;
1959 utf8 += str[i] & 0xbf;
1974 for (
size_t i=0; i<str.length(); i++) {
1981 u32 val = (
u8(str[i])) & (0x7F >> cnt);
1982 for (
u32 parts=1; (parts<cnt) && ((i+1)<str.length()); parts++) {
1984 val = (val << 6) + ((
u8(str[i])) & 0x3F);
1994 enum B64Type { B64STANDARD, B64URL };
1995 static inline void B64DoWrap(
size_t wrap,
RStr& encoded,
size_t& s_cnt) {
1996 if (wrap && s_cnt && (s_cnt % wrap == 0)) {
2001 static inline void B64Error() {
Throw_RC_Error(
"Invalid Base64 Data"); }
2002 static inline void B64DoEnc(
u32& val,
RStr& encoded, B64Type type) {
2003 const char b64enc[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2004 "abcdefghijklmnopqrstuvwxyz"
2006 const char b64encurl[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2007 "abcdefghijklmnopqrstuvwxyz"
2009 if (type == B64STANDARD) {
2010 encoded += b64enc[val >> 18];
2013 encoded += b64encurl[val >> 18];
2015 val = (val << 6) & 0x00FFFFFF;
2017 static inline void B64DoDec(
u8 inp,
u32& val) {
2018 const char b64dec[257] =
2019 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!n!n!odefghijklm!!!!!!"
2020 "!0123456789:;<=>?@ABCDEFGHI!!!!o!JKLMNOPQRSTUVWXYZ[\\]^_`abc!!!!!"
2021 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2022 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
2023 u32 x = b64dec[inp];
2024 if (x ==
'!') { B64Error(); }
2025 val = (val << 6) + (x -
'0');
2027 static inline void B64DoPack(
u32& val, Data1D<u8>& decoded) {
2028 decoded += val >> 16;
2029 val = (val << 8) & 0x00FFFFFF;
2032 static inline RStr ToBase64Type(
const Data1D<u8>& input,
size_t wrap,
2039 for(i=0; i<input.size(); i++) {
2040 val = (val << 8) + input[i];
2042 for (
u32 s=0; s<4; s++) {
2043 B64DoWrap(wrap, encoded, s_cnt);
2044 B64DoEnc(val, encoded, type);
2050 if (resid > 0) { resid++; }
2051 u32 pad = (4-resid) & 3;
2054 for (
u32 s=0; s<resid; s++) {
2055 B64DoWrap(wrap, encoded, s_cnt);
2056 B64DoEnc(val, encoded, type);
2058 if (type == B64STANDARD) {
2059 for (
u32 s=0; s<pad; s++) {
2060 B64DoWrap(wrap, encoded, s_cnt);
2073 return ToBase64Type(input, wrap, B64STANDARD);
2079 return ToBase64Type(input, wrap, B64URL);
2088 for (
size_t i=0; i<input.
size(); i++) {
2089 if (input[i] ==
'\n' || input[i] ==
'\r') {
continue; }
2090 if (input[i] ==
'=') {
break; }
2091 B64DoDec(input[i], val);
2092 if ((icnt&3) == 3) {
2093 for (
size_t d=0; d<3; d++) {
2094 B64DoPack(val, decoded);
2101 case 0:
return decoded;
2102 case 2: resid = 1;
break;
2103 case 3: resid = 2;
break;
2104 default: B64Error();
2106 val <<= (4-(icnt&3))*6;
2107 for (
u32 d=0; d<resid; d++) {
2108 B64DoPack(val, decoded);
2118 for (
size_t i=0; i<hexstr.size(); i++) {
2122 bytes += parse.Get_hex32();
2134 u8 *ptr =
reinterpret_cast<u8*
>(rawdata.
Raw());
2135 size_t len = rawdata.
size() *
sizeof(T);
2136 for (
size_t i=0; i<len; i++) {
2137 hexstr +=
RStr(ptr[i], HEX);
2163 for (i=0; i<argc; i++) {
2164 arglist[i] = argv[i];
2173 const size_t bufsize = 1024;
2174 char buf[bufsize]; buf[0] =
'\0';
2176 UnusedVar(strerror_s(buf, bufsize, err_num));
2178 UnusedVar(strerror_r(err_num, buf, bufsize));
2200 inline bool GetLine(std::istream& in = std::cin,
char delim=
'\n') {
2201 if (in.eof() || (!in.good())) {
return false; }
2205 size_t lastch = str.size()-1;
2206 if (delim==
'\n' && str.size()>0 && str[lastch]==
'\r') {
2210 return !in.fail() && (in.good() || in.eof());
2214 friend std::ostream&
operator<< (std::ostream &out,
const RStr &rstr);
2221 static const size_t npos = -1;
2245 inline RStr
operator+ (
const RStr &lhs,
const RStr &rhs) {
2254 return (in >> rstr.str);
2259 return (out << rstr.str);
2264 inline void swap(RStr& lhs, RStr& rhs) {
2271 inline std::istream&
getline(std::istream& is,
RStr& str,
char delim=
'\n') {
2278 return (lhs.
compare(rhs) == 0);
2283 return (lhs.
compare(rhs) != 0);
2288 return (lhs.
compare(rhs) < 0);
2293 return (lhs.
compare(rhs) > 0);
2298 return (lhs.
compare(rhs) <= 0);
2303 return (lhs.
compare(rhs) >= 0);
2306 #ifdef RC_RSTR_REGEX
2308 const RStr REG_FLT(
"[-+]?[0-9]*\\.?[0-9]+[eE][-+]?[0-9]+|[-+]?[0-9]*\\.?[0-9]+");
2311 const RStr REG_FLTP(
"([-+]?[0-9]*\\.?[0-9]+[eE][-+]?[0-9]+|[-+]?[0-9]*\\.?[0-9]+)");
2323 : singular(singular), plural(plural) { }
2328 return (arg==1) ? singular : plural;
2334 return RStr(arg) +
" " +
For(arg);
2338 RStr singular, plural;
2345 #include <functional>
2347 template<>
struct hash<
RC::RStr> {
2348 std::size_t operator()(
const RC::RStr& s)
const {
2352 std::hash<std::string> h;
Provides a one-dimensional vector-like structure.
Provides a bounds-safe two-dimensional resizeable structure.
Provides a bounds-safe three-dimensional resizeable structure.
Provides informative exception handling.
#define Throw_RC_Type(Type, err)
Use this to throw an RC:ErrorMsg subtype exception.
Definition: Errors.h:282
#define Throw_RC_Error(err)
Use this to throw an RC:ErrorMsg exception.
Definition: Errors.h:274
Provides a bounds-checked iterator that knows when its target was deleted.
Provides a set of convenience macros for metaprogramming and debugging.
#define RC_GetTc(T)
Generates wrappers for const Get_T functions.
Definition: Macros.h:234
Provides short convenience classes and functions.
The version information and configuration settings for RC Lib.
#define RC_RSTR_Int_Input(TYPE)
Internal.
Definition: RStr.h:1002
#define RC_RSTR_Float_Input(TYPE)
Internal.
Definition: RStr.h:1021
Provides typedefs and routines for working with primitives.
uint64_t u64
64-bit unsigned integer.
Definition: Types.h:31
int32_t i32
32-bit signed integer.
Definition: Types.h:28
float f32
32-bit float.
Definition: Types.h:33
int64_t i64
64-bit signed integer.
Definition: Types.h:30
uint8_t u8
8-bit unsigned integer.
Definition: Types.h:25
double f64
64-bit float.
Definition: Types.h:34
long double f80
80-bit float. (Note: Usually takes 16 bytes.)
Definition: Types.h:39
uint16_t u16
16-bit unsigned integer.
Definition: Types.h:27
int16_t i16
16-bit signed integer.
Definition: Types.h:26
int8_t i8
8-bit signed integer.
Definition: Types.h:24
uint32_t u32
32-bit unsigned integer.
Definition: Types.h:29
A bounds-safe one-dimensional vector-like structure.
Definition: Data1D.h:49
void Append(const T &newT)
Add an element to the end, expanding if necessary.
Definition: Data1D.h:811
size_t TypeSize() const
Returns the size of this Data1D's type.
Definition: Data1D.h:361
T * Raw() const
Access a raw unprotected C-pointer to the enclosed data.
Definition: Data1D.h:356
void Reserve(const size_t reserve_size)
Reserve storage without resizing the array.
Definition: Data1D.h:271
size_t size() const
Returns the current number of elements.
Definition: Data1D.h:359
void Resize(const size_t resize_size)
Resize the array, reallocating if necessary.
Definition: Data1D.h:302
A bounds-safe two-dimensional resizeable structure.
Definition: Data2D.h:32
size_t size1() const
Get the size of dimension 1.
Definition: Data2D.h:214
size_t size2() const
Get the size of dimension 2.
Definition: Data2D.h:216
A bounds-safe three-dimensional resizeable structure.
Definition: Data3D.h:31
size_t size3() const
Get the size of dimension 3.
Definition: Data3D.h:201
Provides number-based singular/plural string management.
Definition: RStr.h:2313
RStr For(T arg) const
Provides the singular form if arg is 1, or the plural version otherwise.
Definition: RStr.h:2321
PluralStr(const RStr &singular, const RStr &plural)
Initialize with the singular and plural version of a string.
Definition: RStr.h:2316
RStr Count(T arg) const
For any number arg, provides the number, followed by a space, followed by the correct singular or plu...
Definition: RStr.h:2327
A bounds-checked iterator for random-access containers that knows when its target was deleted.
Definition: Iter.h:27
size_t GetIndex() const
Return the index of the container which this iterator corresponds to.
Definition: Iter.h:62
A bounds-safe string class which provides an identical interface to std::string plus many convenience...
Definition: RStr.h:110
const char * data() const
Identical to c_str.
Definition: RStr.h:627
friend std::ostream & operator<<(std::ostream &out, const RStr &rstr)
Output text from an RStr to a std::ostream (e.g., std::cout).
Definition: RStr.h:2252
bool Is_hex32(bool strict=false) const
True if the start of the string can be converted as hexadecimal to a u32.
Definition: RStr.h:1254
RStr & operator+=(const RStr &s)
Appends s to this RStr.
Definition: RStr.h:309
bool Is_f32(bool strict=false) const
True if the start of the string can be converted to an f32.
Definition: RStr.h:1145
bool Is_hex64(bool strict=false) const
True if the start of the string can be converted as hexadecimal to a u64.
Definition: RStr.h:1260
static RStr ToHexStr(const Data1D< T > &rawdata)
Converts rawdata to a hex string, like { 0xa4, 0xc2, 0x08 } -> "a4c208".
Definition: RStr.h:2126
RStr & assign(const RStr &s)
Copies s to this RStr.
Definition: RStr.h:387
i32 Get_i32(int base=0) const
Convert the beginning characters of this string to this integer type.
Definition: RStr.h:1104
i64 Get_i64(int base=0) const
Convert the beginning characters of this string to this integer type.
Definition: RStr.h:1107
RStr(const char *s)
Creates a new RStr from s until null-termination, or empty string if s is NULL.
Definition: RStr.h:176
bool Is_i64(int base=0, bool strict=false) const
True if the start of the string can be converted to an i64.
Definition: RStr.h:1239
std::wstring wstring()
Convert the RStr to a std::wstring.
Definition: RStr.h:1289
void Subst(const RC_REGEX_NS::regex ®, const RStr &subst)
Substitutes regular expression reg with subst in this string.
Definition: RStr.h:1547
RStr & insert(size_t pos_this, const RStr &s, size_t pos_s, size_t n)
Inserts at index pos_this, n characters from s starting at pos_s.
Definition: RStr.h:449
size_t find_last_not_of(const char *s, size_t pos=npos) const
Returns the highest index at pos or before which does not match a character in s, or npos if all matc...
Definition: RStr.h:812
RStr & assign(const char *s, size_t n)
Sets this RStr to n characters starting at s or until null-termination.
Definition: RStr.h:400
const char * ToLPCSTR() const
For Win32, provides an LPCSTR to the string.
Definition: RStr.h:1297
static RStr ToBase64(const Data1D< u8 > &input, size_t wrap=0)
Encodes input to standard base64 in compliance with RFC 4648.
Definition: RStr.h:2066
RStr & replace(RStrIter first, RStrIter last, const RStr &s)
Replace from first to one before last with all of s.
Definition: RStr.h:549
static Data1D< RStr > Args(int argc=0, char *argv[]=NULL)
Converts standard arguments to "int main" into a Data1D<RStr>.
Definition: RStr.h:2143
size_t capacity() const
Returns the allocated storage space.
Definition: RStr.h:273
static RStr Errno()
Returns a thread-safe error string corresponding to errno.
Definition: RStr.h:2177
bool Is_f64(bool strict=false) const
True if the start of the string can be converted to an f64.
Definition: RStr.h:1158
RStr & Chomp(const RStr &chomp_chars="\r\n")
Remove all trailing newline characters, or provided char set.
Definition: RStr.h:1575
size_t rfind(const char *s, size_t pos=npos) const
Returns the index at pos or before which matches s until null-termination, or npos if no match.
Definition: RStr.h:698
size_t find_first_of(char c, size_t pos=0) const
Returns the index at pos or later which matches character c.
Definition: RStr.h:732
RStr & Truncate(const size_t max_size)
Make sure the string is no longer than max_size.
Definition: RStr.h:1610
RStr & PadLeft(const size_t pad_to, const char pad_with=' ')
If the length is less than pad_to, add pad_width to the left until it reaches that size.
Definition: RStr.h:1385
RStr & ToLower()
Make this RStr lowercase.
Definition: RStr.h:1620
u32 Get_hex32() const
Convert the beginning characters of this string as a hexadecimal to this integer type.
Definition: RStr.h:1112
RStr & assign(const RStr &s, size_t pos, size_t n)
Sets this RStr to n characters in s at index pos, or until the end.
Definition: RStr.h:393
size_t size() const
Returns the length of the string.
Definition: RStr.h:263
bool Contains(const RStr &s, size_t pos=0) const
Returns true if pos or later which matches string s.
Definition: RStr.h:1563
RStr & replace(RStrIter first, RStrIter last, InputIterator in_first, InputIterator in_last)
Replace from first through one before lsat with in1 through one before in2, or until null-termination...
Definition: RStr.h:608
static RStr ToBase64URL(const Data1D< u8 > &input, size_t wrap=0)
Encodes input to base64url in compliance with RFC 4648, safe for url and filename use.
Definition: RStr.h:2072
RStr & replace(size_t pos_this, size_t n_this, const char *s, size_t n_s)
Replace n_this characters at pos_this with n_s characters from s, or until s's null-termination.
Definition: RStr.h:564
size_t find_first_of(const char *s, size_t pos=0) const
Returns the first index at pos or later which matches a character in s, or npos if none match.
Definition: RStr.h:726
RStrIter erase(const RStrIter pos)
Erases one character at index pos.
Definition: RStr.h:523
RStr & assign(const char *s)
Sets this RStr to the characters at s until null-termination.
Definition: RStr.h:412
bool empty() const
True of the string is empty.
Definition: RStr.h:281
const char * c_str() const
Provides a null-terminated C style string corresponding to RStr.
Definition: RStr.h:622
RStr & replace(RStrIter first, RStrIter last, const char *s)
Replace from first to one before last with all of s, or nothing if s is NULL.
Definition: RStr.h:588
RStr(const std::string &str)
Initializes to str.
Definition: RStr.h:152
void resize(size_t n)
Resizes the string, filling with null characters if enlarging.
Definition: RStr.h:271
RStr(const char *s, size_t n)
Creates a new RStr from n characters at s, or until null-termination.
Definition: RStr.h:166
u64 Get_hex64() const
Convert the beginning characters of this string as a hexadecimal to this integer type.
Definition: RStr.h:1115
static const RStr NewLine()
Provides the OS-specific newline string.
Definition: RStr.h:2219
HoldRelated< std::wstring, const wchar_t * > ToLPCWSTR()
For Win32, provides an LPCWSTR to the string.
Definition: RStr.h:1304
size_t find_last_not_of(const RStr &s, size_t pos=npos) const
Returns the highest index at pos or before which does not match a character in s, or npos if all matc...
Definition: RStr.h:797
size_t After(const RStr &s, size_t pos=0) const
Returns the index after the first instance of string s at pos or later, or npos if no match.
Definition: RStr.h:1569
void insert(RStrIter p, size_t n, char c)
Inserts n copies of char c at iterator position p.
Definition: RStr.h:493
RStr & Trim(const RStr &trim_chars=" \t\r\n")
Remove all leading and trailing whitespace, or provided char set.
Definition: RStr.h:1592
void push_back(char c)
Appends character c.
Definition: RStr.h:384
bool Match(const RC_REGEX_NS::regex ®, Data1D< RStr > &matches)
True if the regular expression reg matches this string, and returns the matches in matches.
Definition: RStr.h:1519
void Assert(size_t pos) const
Throws ErrorMsgBounds if the index pos is out of bounds.
Definition: RStr.h:1355
void reserve(size_t capsize=0)
Request a storage capacity increase to capsize.
Definition: RStr.h:277
Data1D< RStr > SplitLast(const RStr ÷rs) const
Return an array of 2 strings split at the last character from dividers.
Definition: RStr.h:1684
size_t find_first_of(const RStr &s, size_t pos=0) const
Returns the first index at pos or later which matches a character in s, or npos if none match.
Definition: RStr.h:711
static RStr MakeCSV(const Data1D< T > &arr, const RStr ÷r=", ")
Makes a comma-separated values string out of a Data1D<T> arr.
Definition: RStr.h:1858
u32 Get_u32(int base=0) const
Convert the beginning characters of this string to this integer type.
Definition: RStr.h:1098
std::string & Raw()
Provides raw access to the std::string this RStr wraps.
Definition: RStr.h:1325
void resize(size_t n, char c)
Resizes the string, filling with character c if enlarging.
Definition: RStr.h:269
RStrIter insert(RStrIter p, char c)
Inserts char c at iterator position p.
Definition: RStr.h:487
Data1D< char > ToData() const
Returns a Data1D<char> corresponding to the character data in the string.
Definition: RStr.h:1332
RStr(char x)
The default constructor for a char, treating it as a character.
Definition: RStr.h:990
static const RStr Whitespace()
Provides all the standard whitespace characters.
Definition: RStr.h:2217
RStr & insert(size_t pos_this, const char *s, size_t n)
Inserts at index pos_this, n characters from s or until NULL-termination.
Definition: RStr.h:460
Data1D< u32 > UTF8toUTF32() const
Treat the contents as a UTF-8 string, and return corresponding UTF-32 data.
Definition: RStr.h:1966
RStr(const RStr &s, size_t pos, size_t n=npos)
Creates a new RStr from a segment of s starting at index pos with length n or until the end.
Definition: RStr.h:159
bool Is_u32(int base=0, bool strict=false) const
True if the start of the string can be converted to an u32.
Definition: RStr.h:1188
int compare(const char *s) const
Returns negative, 0, or positive if this string is lesser, equal, or greater than s.
Definition: RStr.h:840
char & operator[](size_t pos)
Returns the char at index pos, or throws ErrorMsgBounds if out of bounds.
Definition: RStr.h:285
size_t find_first_not_of(const char *s, size_t pos, size_t n) const
Returns the first index at pos or later which does not match the first n characters in s,...
Definition: RStr.h:774
Data1D< RStr > Split(char c) const
Return an array of strings split at each instance of c.
Definition: RStr.h:1640
size_t rfind(char c, size_t pos=npos) const
Returns the index at pos or before which matches character c.
Definition: RStr.h:704
RStr & replace(size_t pos_this, size_t n_this, const RStr &s)
Replace n_this characters at pos_this with all of s.
Definition: RStr.h:542
f64 Get_f64() const
Convert the beginning characters of this string to a float.
Definition: RStr.h:1087
Data1D< RStr > SplitFirst(const RStr ÷rs) const
Return an array of 2 strings split at the first character from dividers.
Definition: RStr.h:1664
size_t find(char c, size_t pos=0) const
Returns the index at pos or later which matches character c.
Definition: RStr.h:675
int compare(size_t pos_this, size_t n_this, const char *s, size_t n_s) const
Returns negative, 0, or positive if the n_this characters at pos_this are lesser, equal,...
Definition: RStr.h:871
bool Is_i32(int base=0, bool strict=false) const
True if the start of the string can be converted to an i32.
Definition: RStr.h:1224
RStr(size_t n, char c)
Initializes to n copies of character c.
Definition: RStr.h:183
size_t Distance(const RStr &other) const
Compute the Levenshtein distance to other.
Definition: RStr.h:1774
size_t Length8() const
Determine the length of the contents treated as a UTF-8 string.
Definition: RStr.h:1808
RStr & append(const char *s, size_t n)
Appends n characters starting at s to this RStr, or fewer if null-termination is reached in s.
Definition: RStr.h:344
friend std::istream & operator>>(std::istream &in, RStr &rstr)
Input text from a std::istream (e.g., std::cin) into an RStr.
Definition: RStr.h:2247
size_t find_first_not_of(const RStr &s, size_t pos=0) const
Returns the first index at pos or later which does not match a character in s, or npos if all match.
Definition: RStr.h:768
std::allocator< char > get_allocator() const
Get the allocator used for string storage.
Definition: RStr.h:633
RStr & append(const RStr &s, size_t pos, size_t n)
Appends n characters in s starting at pos to this RStr, or fewer characters if s is too short.
Definition: RStr.h:336
bool CheckPlus(size_t pos) const
True if the index pos is in bounds, permitting the null.
Definition: RStr.h:1350
RStr & append(const RStr &s)
Appends s to this RStr.
Definition: RStr.h:329
Data1D< RStr > SplitWords() const
Return an array of one or more whitespace separated words.
Definition: RStr.h:1730
RStr & erase(size_t pos=0, size_t n=npos)
Erases n characters at index pos, or until the end.
Definition: RStr.h:516
RStr & insert(size_t pos_this, size_t n, char c)
Inserts n copies of char c at pos_this.
Definition: RStr.h:480
f80 Get_f80() const
Convert the beginning characters of this string to a float.
Definition: RStr.h:1090
int compare(size_t pos_this, size_t n_this, const char *s) const
Returns negative, 0, or positive if the n_this characters at pos_this are lesser, equal,...
Definition: RStr.h:854
RStr & replace(size_t pos_this, size_t n_this, size_t n_c, char c)
Replace n_this characters at pos_this with n_c copies of c.
Definition: RStr.h:593
RStr & insert(const RStrIter p, std::initializer_list< char > characters)
At iterator position p, inserts list of characters.
Definition: RStr.h:508
Data1D< RStr > SplitCSV(char divider=',') const
Return comma-separated values with whitespace trimmed.
Definition: RStr.h:1839
size_t find_last_of(char c, size_t pos=npos) const
Returns the highest index at pos or before which matches character c, or npos if none match.
Definition: RStr.h:761
RStrIter erase(const RStrIter first, const RStrIter last)
Erases from index first through one before index last.
Definition: RStr.h:529
char & at(size_t pos)
Identical to operator[].
Definition: RStr.h:297
QString ToQString() const
Convert the RStr to a QString.
Definition: RStr.h:1283
Data1D< RStr > Wrap(const size_t width)
Wraps each line in this RStr to be no longer than width.
Definition: RStr.h:1420
const char * ToLPCTSTR()
For Win32, provides an LPCTSTR to the string.
Definition: RStr.h:1317
void swap(RStr &s)
Swap contents with s.
Definition: RStr.h:617
bool Is_f80(bool strict=false) const
True if the start of the string can be converted to an f80.
Definition: RStr.h:1172
RStr & replace(size_t pos_this, size_t n_this, const RStr &s, size_t pos_s, size_t n_s)
Replace n_this characters at pos_this with n_s characters from s starting at pos_s.
Definition: RStr.h:555
RStr & replace(size_t pos_this, size_t n_this, const char *s)
Replace n_this characters at pos_this with all of s, or nothing if s is NULL.
Definition: RStr.h:580
f32 Get_f32() const
Convert the beginning characters of this string to a float.
Definition: RStr.h:1085
size_t copy(char *s, size_t n, size_t pos=0) const
Copies n characters to s, starting from pos_this.
Definition: RStr.h:644
size_t find(const char *s, size_t pos=0) const
Returns the index at pos or later which matches s until null-termination, or npos if no match.
Definition: RStr.h:669
size_t find_last_of(const char *s, size_t pos=npos) const
Returns the highest index at pos or before which matches a character in s, or npos if none match.
Definition: RStr.h:754
bool Is_bool() const
True if the string is a "0", "1", or case insensitive "true", "false", "T", or "F".
Definition: RStr.h:1266
RStr & assign(size_t n, char c)
Sets this RStr to n copies of character c.
Definition: RStr.h:421
size_t rfind(const RStr &s, size_t pos=npos) const
Returns the index at pos or before which starts a match of string s, or npos if no match.
Definition: RStr.h:682
bool Is_u64(int base=0, bool strict=false) const
True if the start of the can be converted to an u64.
Definition: RStr.h:1206
RStr(const RStr &other)
Copy constructor.
Definition: RStr.h:147
static Data1D< u8 > FromHexStr(const RStr &hexstr)
Converts hexstr to a byte array, like "a4c208" -> { 0xa4, 0xc2, 0x08 }.
Definition: RStr.h:2109
RStr & insert(size_t pos_this, const RStr &s)
Inserts s starting at index pos_this of this RStr, or throws ErrorMsgBounds.
Definition: RStr.h:438
int compare(const RStr &s) const
Returns negative, 0, or positive if this string is lesser, equal, or greater than s.
Definition: RStr.h:834
Data1D< RStr > SplitAny(const RStr ÷rs) const
Return an array of strings split by any characters in dividers.
Definition: RStr.h:1706
RStrIter end()
Returns a bounds-safe iterator which points past the last element.
Definition: RStr.h:257
RStr & insert(size_t pos_this, const char *s)
Inserts s at index pos_this until null-termination, or nothing if s is NULL.
Definition: RStr.h:471
RStr(InputIterator begin, InputIterator end)
Initializes the string from the values in the iterator range.
Definition: RStr.h:189
RStr & PadCenter(const size_t pad_to, const char pad_with=' ')
If the length is less than pad_to, add pad_width evenly to the right and left until it reaches that s...
Definition: RStr.h:1408
Data1D< RStr > WordWrap(const size_t width)
Wraps each line in this RStr to be no longer than width, but tries to keep whole words together.
Definition: RStr.h:1452
int compare(size_t pos_this, size_t n_this, const RStr &s) const
Returns negative, 0, or positive if the n_this characters at pos_this are lesser, equal,...
Definition: RStr.h:847
RStr ISOtoUTF8() const
Treat this string as ISO-8859-1 and return a UTF8 string.
Definition: RStr.h:1928
RStr & replace(RStrIter first, RStrIter last, const char *s, size_t n_s)
Replace from first through one before last with n_s characters from s, or until s's null-termination.
Definition: RStr.h:573
bool Check(size_t pos) const
True if the index pos is in bounds.
Definition: RStr.h:1345
RStr & append(InputIterator first, InputIterator last)
Appends from first to one before last, or until a null character.
Definition: RStr.h:369
RStr & replace(RStrIter first, RStrIter last, size_t n_c, char c)
Replace from first through one before last with n_c copies of c.
Definition: RStr.h:601
size_t find_last_of(const char *s, size_t pos, size_t n) const
Returns the highest index at pos or before which matches the first n characters in s,...
Definition: RStr.h:745
RStr & operator=(const RStr &s)
Copies the contents of s to this RStr.
Definition: RStr.h:206
RStr & assign(InputIterator first, InputIterator last)
Sets the RStr to characters from first to one before last, or until a null character.
Definition: RStr.h:429
size_t length() const
Returns the length of the string.
Definition: RStr.h:265
size_t find(const char *s, size_t pos, size_t n) const
Returns the index at pos or later which matches n characters of s, or npos if no match.
Definition: RStr.h:659
size_t find_first_of(const char *s, size_t pos, size_t n) const
Returns the first index at pos or later which matches one of the first n characters in s,...
Definition: RStr.h:717
RStr & append(std::initializer_list< char > characters)
Append the initializer list of characters.
Definition: RStr.h:377
bool Get_bool() const
Returns true if case-insensitive "true", "T", or non-zero.
Definition: RStr.h:1118
bool GetLine(std::istream &in=std::cin, char delim='\n')
Set the string equal to the next line from istream in, up to character delim.
Definition: RStr.h:2194
void clear()
Make the string empty.
Definition: RStr.h:279
size_t rfind(const char *s, size_t pos, size_t n) const
Returns the index at pos or before which matches n characters of s, or npos if no match.
Definition: RStr.h:688
RStr & append(size_t n, char c)
Appends n copies of char c.
Definition: RStr.h:362
size_t max_size() const
Returns the maximum size of the string.
Definition: RStr.h:267
size_t find_last_not_of(const char *s, size_t pos, size_t n) const
Returns the highest index at pos or before which does not match the first n characters in s,...
Definition: RStr.h:803
static Data1D< u8 > FromBase64(const RStr &input)
Decodes input from base64 in compliance with RFC 4648, standard or URL encoding.
Definition: RStr.h:2078
RStr & append(const char *s)
Append s to this RStr if s is non-NULL.
Definition: RStr.h:354
RStr substr(size_t pos=0, size_t n=npos) const
Creates a substring from n characters starting at position pos, or until the end of the string.
Definition: RStr.h:826
u64 Get_u64(int base=0) const
Convert the beginning characters of this string to this integer type.
Definition: RStr.h:1101
RStr(char x, RStr_IntStyle style, i32 precision=-1)
Formats x as a string in the given style, and with at least precision 0-padded digits.
Definition: RStr.h:997
size_t find_last_of(const RStr &s, size_t pos=npos) const
Returns the highest index at pos or before which matches a character in s, or npos if none match.
Definition: RStr.h:739
int compare(size_t pos_this, size_t n_this, const RStr &s, size_t pos_s, size_t n_s) const
Returns negative, 0, or positive if the n_this characters at pos_this are lesser, equal,...
Definition: RStr.h:862
RStr(const std::initializer_list< char > characters)
Initializes the string with the list of characters.
Definition: RStr.h:195
size_t find_last_not_of(char c, size_t pos=npos) const
Returns the highest index at pos or before which does not match character c, or npos if all match.
Definition: RStr.h:819
RStrIter begin()
Returns a bounds-safe iterator to the first element.
Definition: RStr.h:248
RStr & ToUpper()
Make this RStr uppercase.
Definition: RStr.h:1630
bool Match(const RC_REGEX_NS::regex ®)
True if the regular expression reg matches this string.
Definition: RStr.h:1507
RStr(RStr &&other) noexcept
Moves other to this RStr.
Definition: RStr.h:200
static const size_t npos
The largest possible value of size_t.
Definition: RStr.h:2215
size_t find(const RStr &s, size_t pos=0) const
Returns the index at pos or later which matches string s, or npos if no match.
Definition: RStr.h:653
RStr()
Default constructor, initializes to blank string.
Definition: RStr.h:143
void insert(RStrIter p, InputIterator first, InputIterator last)
At iterator position p, inserts characters from first through one before last or until null-terminati...
Definition: RStr.h:500
void AssertPlus(size_t pos) const
Throws ErrorMsgBounds if the index pos is out of bounds, permitting the null.
Definition: RStr.h:1363
static RStr Join(const Data1D< T > &str_arr, const RStr &spacer="", RStr(*func)(const T &)=nullptr)
Takes a Data1D<T> array and joins them as one string with spacer between each element while applying ...
Definition: RStr.h:1742
const char & at(size_t pos) const
Const version of at.
Definition: RStr.h:303
size_t find_first_not_of(char c, size_t pos=0) const
Returns the first index at pos or later which does not match character c, or npos if all match.
Definition: RStr.h:790
size_t find_first_not_of(const char *s, size_t pos=0) const
Returns the first index at pos or later which does not match a character in s, or npos if all match.
Definition: RStr.h:783
RStr & PadRight(const size_t pad_to, const char pad_with=' ')
If the length is less than pad_to, add pad_width to the right until it reaches that size.
Definition: RStr.h:1398
const RStr REG_FLTP("([-+]?[0-9]*\\.?[0-9]+[eE][-+]?[0-9]+|[-+]?[0-9]*\\.?[0-9]+)")
A regular expression component to match and return a floating point number.
RStr_IntStyle
The styles in which an integral number can be formatted.
Definition: RStr.h:64
bool operator!=(const RStr &lhs, const RStr &rhs)
True if lhs does not equal rhs.
Definition: RStr.h:2276
bool operator>(const RStr &lhs, const RStr &rhs)
True if lhs is greater than rhs.
Definition: RStr.h:2286
std::istream & getline(std::istream &is, RStr &str, char delim='\n')
Sets str equal to one line from the input stream, up to end of file or the delim, which is discarded.
Definition: RStr.h:2265
void UnusedVar(const T &)
Mark an unused variable to suppress warnings.
Definition: Macros.h:170
std::ostream & operator<<(std::ostream &out, APtr< T > obj)
A convenience stream output for displaying the enclosed object.
Definition: APtr.h:120
std::istream & operator>>(std::istream &in, RStr &rstr)
Input text from a std::istream (e.g., std::cin) into an RStr.
Definition: RStr.h:2247
bool operator>=(const RStr &lhs, const RStr &rhs)
True if lhs is greater than or equal to rhs.
Definition: RStr.h:2296
bool operator<=(const RStr &lhs, const RStr &rhs)
True if lhs is less than or equal to rhs.
Definition: RStr.h:2291
bool operator<(const RStr &lhs, const RStr &rhs)
True if lhs is less than rhs.
Definition: RStr.h:2281
void swap(RC::Data1D< T > &a, RC::Data1D< T > &b)
Efficiently swap all the contents of a and b.
Definition: Data1D.h:1184
RAIter< Cont, T > operator+(size_t x, const RAIter< Cont, T > &iter)
Returns a new iterator with an offset incremented by x.
Definition: Iter.h:144
bool operator==(const RStr &lhs, const RStr &rhs)
True if lhs equals rhs.
Definition: RStr.h:2271
RStr_FloatStyle
The styles in which a floating point number can be formatted.
Definition: RStr.h:74
RAIter< RStr, char > RStrIter
The random-access iterator for RStr begin() and end()
Definition: RStr.h:77
const RStr REG_FLT("[-+]?[0-9]*\\.?[0-9]+[eE][-+]?[0-9]+|[-+]?[0-9]*\\.?[0-9]+")
A regular expression component to match a floating point number.