8 #ifndef INCL_evo_substring_h     9 #define INCL_evo_substring_h   290 #if defined(EVO_CPP11)   321         { 
set(src); 
return *
this; }
   325         { 
set(data); 
return *
this; }
   329         { 
if (data != NULL) 
set(*data); 
else set(); 
return *
this; }
   340         size_ = data ? (
Size)strlen(data) : 0;
   344     using SubListType::set;
   355         size_ = data ? (
Size)strlen(data) : 0;
   368         setempty(); 
return *
this;
   382     template<
class StringT>
   383     bool token(StringT& value, 
char delim) {
   385             const char* ptr = (
char*)memchr(data_, delim, size_);
   387                 Key i = (
Key)(ptr - data_);
   394             value.set(data_, size_);
   413     template<
class StringT>
   414     bool tokenr(StringT& value, 
char delim) {
   416         #if defined(EVO_GLIBC_MEMRCHR)   417             const char* ptr = (
char*)memrchr(data_, delim, size_);
   419                 const Key i = (
Key)(ptr - data_);
   420                 const Size len = size_ - i;
   421                 value.set(data_ + i + 1, len - 1);
   426             for (
Key i=size_; i > 0; ) {
   427                 if (data_[--i] == delim) {
   428                     Size len = size_ - i;
   429                     value.set(data_ + i + 1, len - 1);
   435             value.set(data_, size_);
   456     template<
class StringT>
   461             for (
Key i=0; i < size_; ++i) {
   462                 for (j=0; j < count; ++j) {
   463                     if (data_[i] == delims[j]) {
   465                         found_delim = data_[i];
   473             value.
set(data_, size_);
   496     template<
class StringT>
   501             for (
Key i=size_; i > 0; ) {
   503                 for (j=0; j < count; ++j) {
   504                     if (data_[i] == delims[j]) {
   505                         Size len = size_ - i;
   506                         value.set(data_ + i + 1, len - 1);
   507                         found_delim = data_[i];
   513             value.
set(data_, size_);
   532     template<
class StringT>
   534         const char* NEWLINE_CHARS = 
"\n\r";
   535         Size i = findany(NEWLINE_CHARS, 2);
   538                 line.set(data_, size_);
   548             char ch1 = data_[i - 1];
   550             if ((ch1 == 
'\n' && ch2 == 
'\r') || (ch1 == 
'\r' && ch2 == 
'\n'))
   566     template<
class StringT>
   568         const char* NEWLINE_CHARS = 
"\n\r";
   569         Size i = findanyr(NEWLINE_CHARS, 2);
   572                 line.set(data_, size_);
   579         line.set(data_ + i + 1, size_ - i - 1);
   582             char ch1 = data_[i - 1];
   584             if ((ch1 == 
'\n' && ch2 == 
'\r') || (ch1 == 
'\r' && ch2 == 
'\n'))
   600         { 
return (size_ > 0 ? buffer.
set(data_, size_).
cstr() : 
""); }
   604     using SubListType::compare;
   617     using SubListType::operator==;
   618     using SubListType::operator!=;
   652     using SubListType::starts;
   665     using SubListType::ends;
   671     bool ends(
const char* str)
 const {
   683             const char* ptr = (
char*)memchr(data_, ch, size_);
   685                 return (
Key)(ptr - data_);
   696                 const char* ptr = (
char*)memchr(data_ + start, ch, end - start);
   698                     return (
Key)(ptr - data_);
   706         if (start < size_ && start < end) {
   707             assert( pattern != NULL );
   710             return impl::string_search(pattern, pattern_size, data_ + start, end - start, start);
   717         if (start < size_ && start < end) {
   718             assert( pattern != NULL );
   721             return impl::string_search(alg, pattern, pattern_size, data_ + start, end - start, start);
   728         if (start < size_ && start < end) {
   731             return impl::string_search(pattern.
data_, pattern.
size_, data_ + start, end - start, start);
   738         if (start < size_ && start < end) {
   741             return impl::string_search(alg, pattern.
data_, pattern.
size_, data_ + start, end - start, start);
   748     #if !defined(EVO_NO_MEMRCHR) && defined(EVO_GLIBC_MEMRCHR)   750             const char* ptr = (
char*)memrchr(data_, ch, size_);
   752                 return (
Key)(ptr - data_);
   755         const char* ptr = data_ + size_;
   758                 return (
Key)(ptr - data_);
   765     #if !defined(EVO_NO_MEMRCHR) && defined(EVO_GLIBC_MEMRCHR)   770                 const char* ptr = (
char*)memrchr(data_ + start, ch, end - start);
   772                     return (
Key)(ptr - data_);
   779             if (data_[--end] == ch)
   787         if (start < size_ && start < end) {
   788             assert( pattern != NULL );
   791             return impl::string_search_reverse(pattern, pattern_size, data_ + start, end - start, start);
   798         if (start < size_ && start < end) {
   799             assert( pattern != NULL );
   802             return impl::string_search_reverse(alg, pattern, pattern_size, data_ + start, end - start, start);
   809         if (start < size_ && start < end) {
   812             return impl::string_search_reverse(pattern.
data_, pattern.
size_, data_ + start, end - start, start);
   819         if (start < size_ && start < end) {
   822             return impl::string_search_reverse(alg, pattern.
data_, pattern.
size_, data_ + start, end - start, start);
   829         if (start < size_ && start < end && count > 0) {
   834                 const char* ptr = (
char*)memchr(data_ + start, *chars, end - start);
   836                     return (
Key)(ptr - data_);
   838                 const char* pend = data_ + end;
   839                 const char* ptr  = data_ + start;
   840                 for (; ptr < pend; ++ptr)
   841                     if (memchr(chars, *ptr, count) != NULL)
   842                         return (
Key)(ptr - data_);
   850         { 
return findany(chars.
data_, chars.
size_, start, end); }
   855             return findr(*chars, start, end);
   856         if (start < size_ && start < end && count > 0) {
   859             const char* pstart = data_ + start;
   860             const char* ptr    = data_ + end;
   862                 if (memchr(chars, *--ptr, count) != NULL)
   863                     return (
Key)(ptr - data_);
   870         { 
return findanyr(chars.
data_, chars.
size_, start, end); }
   874         if (start < size_ && start < end) {
   879             const char* pend = data_ + end;
   880             const char* ptr  = data_ + start;
   881             for (; ptr < pend; ++ptr)
   882                 if (memchr(chars, *ptr, count) == NULL)
   883                     return (
Key)(ptr - data_);
   890         { 
return findanybut(chars.
data_, chars.
size_, start, end); }
   894         if (start < size_ && start < end) {
   899             const char* pstart = data_ + start;
   900             const char* ptr    = data_ + end;
   902                 if (memchr(chars, *--ptr, count) == NULL)
   903                     return (
Key)(ptr - data_);
   910         { 
return findanybutr(chars.
data_, chars.
size_, start, end); }
   914         if (start < size_ && start < end) {
   917             for (; start < end; ++start)
   926         if (start < size_ && start < end) {
   938         if (start < size_ && start < end) {
   941             for (; start < end; ++start)
   950         if (start < size_ && start < end) {
   962         { 
return find(ch) != 
NONE; }
   966         { 
return find(str, size) != 
NONE; }
   970         { 
return find(str) != 
NONE; }
   975     template<
class T1,
class T2>
   976     bool split(
char delim, T1& left, T2& right)
 const {
   977         for (
Key i=0; i<size_; ++i) {
   978             if (data_[i] == delim) {
   979                 left.set(*
this, 0, i);
   980                 right.set(*
this, i+1, 
ALL);
   991     bool split(
char delim, T1& left)
 const {
   992         for (
Key i=0; i<size_; ++i) {
   993             if (data_[i] == delim) {
   994                 left.set(*
this, 0, i);
  1006         for (
Key i=0; i<size_; ++i) {
  1007             if (data_[i] == delim) {
  1008                 right.set(*
this, i+1, 
ALL);
  1017     template<
class T1,
class T2>
  1018     bool splitr(
char delim, T1& left, T2& right)
 const {
  1019         for (
Key i=size_; i>0; ) {
  1020             if (data_[--i] == delim) {
  1021                 left.set(*
this, 0, i);
  1022                 right.set(*
this, i+1, 
ALL);
  1034         for (
Key i=size_; i>0; ) {
  1035             if (data_[--i] == delim) {
  1036                 left.set(*
this, 0, i);
  1048         for (
Key i=size_; i>0; ) {
  1049             if (data_[--i] == delim) {
  1050                 right.set(*
this, i+1, 
ALL);
  1063         while ( size_ > 0 && ((ch=data_[size_-1]) == 
' ' || ch == 
'\t') )
  1066         while ( count < size_ && ((ch=data_[count]) == 
' ' || ch == 
'\t') )
  1077         while (size_ > 0 && data_[size_-1] == ch)
  1080         while (count < size_ && data_[count] == ch)
  1093         while ( count < size_ && ((ch=data_[count]) == 
' ' || ch == 
'\t') )
  1105         while (count < size_ && data_[count] == ch && count < 
max)
  1116         if (strsize > 0 && strsize <= size_ && max > 0) {
  1117             Size i, j = 0, count = 0;
  1119                 for (i=0; i < strsize; ++i, ++j)
  1120                     if (j >= size_ || str[i] != data_[j])
  1123             } 
while (j < size_ && count < 
max);
  1137         while ( size_ > 0 && ((ch=data_[size_-1]) == 
' ' || ch == 
'\t') )
  1144         for (
Size i=0; size_ > 0 && data_[size_-1] == ch && i < 
max; ++i)
  1151         if (strsize > 0 && strsize <= size_ && max > 0) {
  1152             Size i, j = size_, count = 0;
  1154                 for (i=strsize; i > 0; )
  1155                     if (j == 0 || str[--i] != data_[--j])
  1158             } 
while (j > 0 && count < 
max);
  1161                 size_ -= (count * strsize);
  1169             const char* end = data_ + size_;
  1179             const char* end = data_ + size_;
  1181             size_ = (
Size)(end - data_);
  1189             const char* end = data_ + size_;
  1199         while ( count < size_ && ((ch=data_[count]) == 
'\n' || ch == 
'\r') )
  1212         for (; count < size_ && max > 0; --
max) {
  1215                 if (count + 1 < size_ && data_[count + 1] == 
'\r') {
  1219             } 
else if (ch == 
'\r') {
  1220                 if (count + 1 < size_ && data_[count + 1] == 
'\n') {
  1238         while ( size_ > 0 && ((ch=data_[size_-1]) == 
'\n' || ch == 
'\r') )
  1246         for (; size_ > 0 && max > 0; --
max) {
  1247             ch = data_[size_ - 1];
  1249                 if (size_ > 1 && data_[size_ - 2] == 
'\r') {
  1253             } 
else if (ch == 
'\r') {
  1254                 if (size_ > 1 && data_[size_ - 2] == 
'\n') {
  1276         { SubListType::clear(); 
return *
this; }
  1280         { SubListType::set(); 
return *
this; }
  1284         { SubListType::set(data); 
return *
this; }
  1288         { SubListType::set(data, index, size); 
return *
this; }
  1292         { SubListType::set(data); 
return *
this; }
  1296         { SubListType::set(data, size); 
return *
this; }
  1300         { SubListType::set2(data, index1, index2); 
return *
this; }
  1304         { SubListType::setempty(); 
return *
this; }
  1308         { SubListType::triml(size); 
return *
this; }
  1312         { SubListType::trimr(size); 
return *
this; }
  1316         { SubListType::truncate(size); 
return *
this; }
  1320         { SubListType::slice(index); 
return *
this; }
  1324         { SubListType::slice(index, size); 
return *
this; }
  1328         { SubListType::slice2(index1, index2); 
return *
this; }
  1338         assert( data_ > (
char*)1 || size_ == 0 );
  1339         return impl::tobool(data_, size_, error);
  1344         assert( data_ > (
char*)1 || size_ == 0 );
  1353         assert( data_ > (
char*)1 || size_ == 0 );
  1354         return impl::tonum<T>(data_, size_, 
error, base);
  1358     template<
class T> T 
getnum(
int base=0)
 const {
  1359         assert( data_ > (
char*)1 || size_ == 0 );
  1366         assert( data_ > (
char*)1 || size_ == 0 );
  1367         return impl::tonumf<T>(data_, size_, 
error);
  1372         assert( data_ > (
char*)1 || size_ == 0 );
  1380         { 
return impl::ToBool<Bool>::getbool(data_, size_); }
  1386         { 
return impl::ToNum<Int>::getnum(data_, size_, base); }
  1390         { 
return impl::ToNum<Long>::getnum(data_, size_, base); }
  1394         { 
return impl::ToNum<LongL>::getnum(data_, size_, base); }
  1400         { 
return impl::ToNum<UInt>::getnum(data_, size_, base); }
  1404         { 
return impl::ToNum<ULong>::getnum(data_, size_, base); }
  1408         { 
return impl::ToNum<ULongL>::getnum(data_, size_, base); }
  1414         { 
return impl::ToNumf<Float>::getnum(data_, size_); }
  1418         { 
return impl::ToNumf<FloatD>::getnum(data_, size_); }
  1422         { 
return impl::ToNumf<FloatL>::getnum(data_, size_); }
  1446     template<
class Tok,
class C> 
typename C::Size 
split(C& items, 
char delim=
',')
 const {
  1447         typename C::Size count = 0;
  1449         for (; tok.next(delim); ++count)
  1450             items.add(tok.value().template convert<typename C::Item>());
  1457     const char* data() 
const;
  1460     const char& operator[](
Key index) 
const;
  1463     const char& item(
Key index) 
const;
  1466     bool operator==(
const StringBase& data) 
const;
  1469     bool operator!=(
const StringBase& data) 
const;
  1481     bool shared() 
const;
  1484     const char* 
first() 
const;
  1487     const char* last() 
const;
  1493     ulong hash(ulong seed) 
const;
  1496     int compare(
const StringBase& data) 
const;
  1505     Key findany(
const char* items,
Size count,
Key start,
Key end) 
const;
  1508     Key findanyr(
const char* items,
Size count,
Key start,
Key end) 
const;
  1511     template<
class T1,
class T2> 
bool splitat(
Key index,T1& left,T2& right) 
const;
  1514     template<
class T1> 
bool splitat(
Key index,T1& left) 
const;
  1517     template<
class T2> 
bool splitat(
Key index,
ValNull left,T2& right) 
const;
  1520     bool splitat_setl(
Key index);
  1523     template<
class T2> 
bool splitat_setl(
Key index,T2& right);
  1526     bool splitat_setr(
Key index);
  1529     template<
class T1> 
bool splitat_setr(
Key index,T1& left);
  1532     void swap(StringBase& list);
  1538     void iterInitMutable();
  1539     const char* iterFirst(IterKey& key) 
const;
  1540     const char* iterNext(IterKey& key) 
const;
  1541     const char* iterNext(
Size count,IterKey& key) 
const;
  1542     const char* iterLast(IterKey& key) 
const;
  1543     const char* iterPrev(IterKey& key) 
const;
  1544     const char* iterPrev(
Size count,IterKey& key) 
const;
  1545     Size iterCount() 
const;
  1546     const char* iterSet(IterKey key) 
const;
  1553     { 
return str2 == str1; }
  1555     { 
return str2 != str1; }
  1561 template<
class T> 
struct Convert_SubStringToIntBase {
  1563     template<
class U> 
static void set(U&, 
const SubString&)
  1565     template<class U> 
static void add(U&, 
const SubString&)
  1567     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1570         { 
return src.
getnum<T>(); }
  1572 template<
class T> 
struct Convert_SubStringToFltBase {
  1574     template<
class U> 
static void set(U&, 
const SubString&)
  1576     template<class U> 
static void add(U&, 
const SubString&)
  1578     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1586     template<
class U> 
static void set(U&, 
const SubString&)
  1588     template<class U> 
static void add(U&, 
const SubString&)
  1590     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1597     template<
class U> 
static void set(U&, 
const SubString&)
  1599     template<class U> 
static void add(U&, 
const SubString&)
  1601     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1606 template<> 
struct Convert<String,SubString> {
  1607     static void set(String& dest, 
const SubString& value)
  1609     static void add(String& dest, 
const SubString& value)
  1610         { dest.
add(value); }
  1611     static bool addq(String& dest, 
const SubString& value, 
char delim)
  1613     static SubString value(
const String& src)
  1616 template<> 
struct Convert<SubString,String> {
  1617     static void set(SubString& dest, 
const String& value)
  1620     template<
class U> 
static void add(U& dest, 
const String& value)
  1622     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1624     static String value(
const SubString& src)
  1627 template<> 
struct Convert<SubString,SubString> {
  1628     static void set(SubString& dest, 
const SubString& value)
  1629         { dest.
set(value); }
  1631     template<
class U> 
static void add(U& dest, 
const SubString& value)
  1633     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1635     static const SubString& value(
const SubString& src)
  1638 template<> 
struct Convert<SubString,bool> {
  1639     static void set(SubString& dest, 
bool value) {
  1640         if (value) dest.
set(
"true", 4);
  1641         else       dest.set(
"false", 5);
  1644     template<
class U> 
static void add(U& dest, 
const SubString& value)
  1646     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1648     static bool value(
const SubString& src)
  1649         { 
return src.
getbool<
bool>(); }
  1651 template<> 
struct Convert<SubString,short>   : 
public Convert_SubStringToIntBase<short>   { };
  1652 template<> 
struct Convert<SubString,int>     : 
public Convert_SubStringToIntBase<int>     { };
  1653 template<> 
struct Convert<SubString,long>    : 
public Convert_SubStringToIntBase<long>    { };
  1654 template<> 
struct Convert<SubString,longl>   : 
public Convert_SubStringToIntBase<longl>   { };
  1655 template<> 
struct Convert<SubString,ushort>  : 
public Convert_SubStringToIntBase<ushort>  { };
  1656 template<> 
struct Convert<SubString,uint>    : 
public Convert_SubStringToIntBase<uint>    { };
  1657 template<> 
struct Convert<SubString,ulong>   : 
public Convert_SubStringToIntBase<ulong>   { };
  1658 template<> 
struct Convert<SubString,ulongl>  : 
public Convert_SubStringToIntBase<ulongl>  { };
  1659 template<> 
struct Convert<SubString,float>   : 
public Convert_SubStringToFltBase<float>   { };
  1660 template<> 
struct Convert<SubString,double>  : 
public Convert_SubStringToFltBase<double>  { };
  1661 template<> 
struct Convert<SubString,ldouble> : 
public Convert_SubStringToFltBase<ldouble> { };
  1662 template<> 
struct Convert<SubString,Bool> {
  1663     static void set(SubString& dest, Bool value) {
  1664         if (value.null()) dest.
set();
  1665         else if (*value)  dest.set(
"true", 4);
  1666         else              dest.set(
"false", 5);
  1669     template<
class U> 
static void add(U& dest, 
const SubString& value)
  1671     template<
class U> 
static bool addq(U&, 
const SubString&, 
char)
  1673     static Bool value(
const SubString& src)
  1674         { 
return src.
getbool<Bool>(); }
  1676 template<> 
struct Convert<SubString,Short>  : 
public Convert_SubStringToIntBase<Short>  { };
  1677 template<> 
struct Convert<SubString,Int>    : 
public Convert_SubStringToIntBase<Int>    { };
  1678 template<> 
struct Convert<SubString,Long>   : 
public Convert_SubStringToIntBase<Long>   { };
  1679 template<> 
struct Convert<SubString,LongL>  : 
public Convert_SubStringToIntBase<LongL>  { };
  1680 template<> 
struct Convert<SubString,UShort> : 
public Convert_SubStringToIntBase<UShort> { };
  1681 template<> 
struct Convert<SubString,UInt>   : 
public Convert_SubStringToIntBase<UInt>   { };
  1682 template<> 
struct Convert<SubString,ULong>  : 
public Convert_SubStringToIntBase<ULong>  { };
  1683 template<> 
struct Convert<SubString,ULongL> : 
public Convert_SubStringToIntBase<ULongL> { };
  1684 template<> 
struct Convert<SubString,Float>  : 
public Convert_SubStringToFltBase<Float>  { };
  1685 template<> 
struct Convert<SubString,FloatD> : 
public Convert_SubStringToFltBase<FloatD> { };
  1686 template<> 
struct Convert<SubString,FloatL> : 
public Convert_SubStringToFltBase<FloatL> { };
  1737         if (verify_order && !verify())
  1759         return (size_ == 0);
  1766         return (data_ == NULL);
  1779         SizeT left = 0, right = size_, mid = 0;
  1780         while (left < right) {
  1781             mid = left + ((right-left) / 2);
  1782             cmp = key.
compare(data_[mid]);
  1832     T 
find_enum(
const SubString& key, T first_enum, T last_enum, T unknown)
 const {
  1833         assert( (
SizeT)last_enum >= (
SizeT)first_enum );
  1834         assert( (
SizeT)last_enum - (
SizeT)first_enum + 1 == size_ );
  1835         SizeT i = find(key);
  1887     T 
find_enum_remap(
const T* remap_array, 
const SubString& key, T first_enum, T last_enum, T unknown)
 const {
  1888         SizeT i = find(key);
  1891         return (T)remap_array[i];
  1928         return data_[reverse_remap_array[i]];
  1931 #if defined(EVO_CPP11)  1970         return find_enum<T>(key, (T)((
SizeT)T::UNKNOWN + 1), (T)((
SizeT)T::ENUM_END - 1), T::UNKNOWN);
  1984         return get_enum_string(enum_value, (T)((
SizeT)T::UNKNOWN + 1), (T)((
SizeT)T::ENUM_END - 1));
  1997         for (
SizeT i = 1; i < size_; ++i)
  1998             if (data_[i-1].compare(data_[i]) >= 0)
  2012         static const int SIZE = (int)T::LAST - (
int)T::FIRST + 1;   
  2020             for (
SizeT i = 0; i < (uint)SIZE; ++i)
  2021                 array[(
int)remap_array[i] - (int)T::FIRST] = i;
 C convert() const
Convert string to value of given type. 
Definition: substring.h:1427
 
SubString get_enum_string_remap(const SizeT *reverse_remap_array, T enum_value, T first_enum, T last_enum) const
Convert enum value to key string from list, with unsorted enum remapped to sorted values...
Definition: substring.h:1924
 
SubString(SubString &&src)
Move constructor (C++11). 
Definition: substring.h:294
 
Key find(StringSearchAlg alg, const StringBase &pattern, Key start=0, Key end=END) const
Find first occurrence of pattern string using specified algorithm. 
Definition: substring.h:737
 
CharBreakType ascii_breaktype(char ch)
Get ASCII character word-break type. 
Definition: str.h:91
 
bool operator==(const ListBase< wchar16, T > &str)
Equality operator to compare against UTF-16 string. 
Definition: substring.h:626
 
T & max(T &a, T &b)
Returns highest of given values. 
Definition: alg.h:47
 
Key findr(const char *pattern, uint pattern_size, Key start=0, Key end=END) const
Find last occurrence of pattern string with reverse search. 
Definition: substring.h:786
 
SubString & stripl_newlines()
Strip all left (beginning) newlines from string. 
Definition: substring.h:1196
 
bool getbool(Error &error) const
Convert to bool value for given boolean type. 
Definition: substring.h:1337
 
SubString & stripr_newlines(Size max)
Strip right (ending) newlines from string. 
Definition: substring.h:1244
 
Float numf() const
Convert to number value (floating point). 
Definition: substring.h:1413
 
SubString & stripl2()
Strip left (beginning) whitespace from string, including newlines. 
Definition: substring.h:1177
 
SubString & triml(Size size)
Trim left (beginning) items. 
Definition: substring.h:1307
 
bool contains(const char *str, Size size) const
Check whether this contains given string. 
Definition: substring.h:965
 
Key findanyr(const StringBase &chars, Key start=0, Key end=END) const
Find last occurrence of any given characters with reverse search. 
Definition: substring.h:869
 
SubString & operator=(SubString &&src)
Move assignment operator (C++11). 
Definition: substring.h:302
 
Long numl(int base=0) const
Convert to number value (signed long). 
Definition: substring.h:1389
 
Basic boolean type. 
Definition: type.h:568
 
int utf8_compare(const char *str1, ulong len1, const char *str2, ulong len2)
Compare two non-terminated UTF-8 strings. 
Definition: str.h:305
 
ValEmpty
Special empty value type, pass as vEMPTY. 
Definition: sys.h:1101
 
Static conditional type. 
Definition: meta.h:134
 
bool token(StringT &value, char delim)
Extract next token from string. 
Definition: substring.h:383
 
bool split(char delim, ValNull left, T2 &right) const
Split at first occurrence of delimiter into right substring. 
Definition: substring.h:1004
 
Evo string scanning helpers with SSE optimized code. 
 
FloatL numfl() const
Convert to number value (ldouble floating point). 
Definition: substring.h:1421
 
Key findr(const StringBase &pattern, Key start=0, Key end=END) const
Find last occurrence of pattern string with reverse search. 
Definition: substring.h:808
 
Nullable< T > & set()
Set as null. 
Definition: type.h:342
 
SubString(const char *data)
Constructor to reference terminated string. 
Definition: substring.h:287
 
Key findany(const StringBase &chars, Key start=0, Key end=END) const
Find first occurrence of any given characters with forward search. 
Definition: substring.h:849
 
T find_enum_class(const SubString &key) const
Find key string in list and convert to enum class value (C++11). 
Definition: substring.h:1969
 
bool tokenr_any(StringT &value, Char &found_delim, const char *delims, Size count)
Extract next token from string in reverse (from end of string) using any of given delimiters...
Definition: substring.h:497
 
bool operator==(const char *str) const
Equality operator. 
Definition: substring.h:632
 
Basic character type (char) – see CharT. 
Definition: type.h:775
 
SubStringMapList input ordering verification failed, see Exception. 
Definition: substring.h:22
 
References a list of sorted substrings for fast lookup. 
Definition: substring.h:1722
 
bool token_line(StringT &line)
Extract next line from string. 
Definition: substring.h:533
 
T first(T val1, T val2)
Definition: alg.h:85
 
Word character (A-Z, a-z, 0-9, _) 
Definition: str.h:65
 
Size Key
Key type (item index) 
Definition: sublist.h:151
 
SubString(const char *data, Size size)
Constructor to reference string data. 
Definition: substring.h:281
 
SubString get_enum_string(T enum_value, T first_enum, T last_enum) const
Convert enum value to key string from list. 
Definition: substring.h:1905
 
Size writequoted(const char *buf, Size size, char delim, bool optional=false)
Write (append) quoted output to string. 
Definition: string.h:4305
 
ValNull
Unique null value type and value (vNULL). 
Definition: sys.h:1096
 
SubString & stripr2()
Strip right (ending) whitespace (including newlines) from string. 
Definition: substring.h:1187
 
Int num(int base=0) const
Convert to number value (signed). 
Definition: substring.h:1385
 
C::Size split(C &items, char delim=',') const
Split delimited string into item list using given tokenizer. 
Definition: substring.h:1446
 
static const T & value(const T &src)=delete
Convert value to target. 
 
int compare(const ListBase< wchar16, T > &str)
Comparison against UTF-16 string. 
Definition: substring.h:612
 
const SubString & asconst() const
Explicitly use a const reference to this. 
Definition: substring.h:313
 
bool empty() const
Get whether empty. 
Definition: substring.h:1758
 
constexpr ReverseRemap(const EnumType *remap_array)
Constructor. 
Definition: substring.h:2019
 
const char * cstr(String &buffer) const
Get terminated string pointer, using given string buffer if needed (const). 
Definition: string.h:1561
 
FloatD numfd() const
Convert to number value (double floating point). 
Definition: substring.h:1417
 
Key findr(StringSearchAlg alg, const StringBase &pattern, Key start=0, Key end=END) const
Find last occurrence of pattern string with reverse search. 
Definition: substring.h:818
 
#define EVO_CREATE_EXCEPTION_IMPL(NAME, BASE)
Create an Evo exception implementation. 
Definition: sys.h:1365
 
SubString get_enum_class_string(T enum_value) const
Convert enum class value to key string from list (C++11). 
Definition: substring.h:1983
 
bool tokenr_line(StringT &line)
Extract next line from string in reverse (from end of string). 
Definition: substring.h:567
 
static const T MAX
Maximum interger value. 
Definition: type.h:996
 
Key findanybut(const char *chars, Size count, Key start=0, Key end=END) const
Find first occurrence of any character not listed with forward search. 
Definition: substring.h:873
 
void swap(T &a, T &b)
Swap contents of given objects. 
Definition: sys.h:1602
 
SubString & stripr_newlines()
Strip all right (ending) newlines from string. 
Definition: substring.h:1236
 
Generic value conversion template. 
Definition: type.h:1757
 
bool tokenr(StringT &value, char delim)
Extract next token from string in reverse (from end of string). 
Definition: substring.h:414
 
Key findany(const char *chars, Size count, Key start=0, Key end=END) const
Find first occurrence of any given characters with forward search. 
Definition: substring.h:828
 
const char * str_scan_nws(const char *str, const char *end)
Scan string pointer for next non-whitespace character and return stop pointer. 
Definition: strscan.h:877
 
SubString & slice2(Key index1, Key index2)
Slice to given subset using start/end positions. 
Definition: substring.h:1327
 
SubString & clear()
Clear by removing all items. 
Definition: substring.h:1275
 
Basic integer type. 
Definition: type.h:980
 
SubString & slice(Key index, Size size)
Slice to given subset. 
Definition: substring.h:1323
 
SizeT find(const SubString &key) const
Find key string in list. 
Definition: substring.h:1777
 
SubString()
Default constructor sets as null. 
Definition: substring.h:234
 
SubString(const ThisType &str)
Copy constructor. 
Definition: substring.h:243
 
Size size() const
Get size. 
 
Check if type is a Plan Old Data type. 
Definition: meta.h:528
 
bool starts(const char *str) const
Check if starts with given terminated string. 
Definition: substring.h:658
 
Error
General Evo error code stored in exceptions, or used directly when exceptions are disabled...
Definition: sys.h:1113
 
bool splitr(char delim, ValNull left, T2 &right) const
Split at last occurrence of delimiter into right substring. 
Definition: substring.h:1046
 
Data equality helper. 
Definition: container.h:712
 
StrSizeT Size
List size integer type. 
Definition: sublist.h:150
 
SubStringMapList()
Constructor for null and empty SubString list. 
Definition: substring.h:1725
 
uint32 StrSizeT
Default Evo string size type. 
Definition: sys.h:734
 
bool contains(const StringBase &str) const
Check whether contains given string. 
Definition: substring.h:969
 
String container. 
Definition: string.h:674
 
T getnum(int base=0) const
Convert to number value for given integer type. 
Definition: substring.h:1358
 
T getnum(Error &error, int base=0) const
Convert to number value for given integer type. 
Definition: substring.h:1351
 
SubString & operator=(const SubString &src)
Assignment operator. 
Definition: substring.h:320
 
SubString & operator=(const StringBase *data)
Assignment operator sets as reference to source data from pointer. 
Definition: substring.h:328
 
Key findnonwordr(Key start=0, Key end=END) const
Find last non-word character with reverse search. 
Definition: substring.h:949
 
Key findwordr(Key start=0, Key end=END) const
Find last word character with reverse search. 
Definition: substring.h:925
 
SubStringMapList(const SubString *data, SizeT size, bool verify_order=false)
Constructor for referencing an existing SubString list. 
Definition: substring.h:1736
 
bool operator==(const PtrBase< T > &ptr1, const PtrBase< T, Atomic< T *> > &ptr2)
Equality operator for managed pointer base and atomic pointer base. 
Definition: atomic.h:1193
 
const SubString * data() const
Get pointer to map string values. 
Definition: substring.h:1744
 
SubString & unshare()
Make data unique – no-op. 
Definition: substring.h:1331
 
SubString & stripl()
Strip left (beginning) whitespace (spaces and tabs). 
Definition: substring.h:1090
 
Key find(char ch) const
Find first occurrence of character with forward search. 
Definition: substring.h:681
 
SubString & stripr()
Strip right (ending) whitespace (spaces and tabs). 
Definition: substring.h:1135
 
T getnumf() const
Convert to floating point number value for given type. 
Definition: substring.h:1371
 
SubString & stripl(char ch, Size max=ALL)
Strip left (beginning) occurrences of character. 
Definition: substring.h:1103
 
static void set(C &dest, T value)=delete
Set target to value (reversed conversion). 
 
static const EndT END
Special integer value for indicating end of items or no item. 
Definition: type.h:1846
 
SubString & strip(char ch)
Strip left (beginning) and right (ending) occurences of character. 
Definition: substring.h:1076
 
static const EndT ALL
Special integer value for indicating all items or all remaining items. 
Definition: type.h:1839
 
T find_enum(const SubString &key, T first_enum, T last_enum, T unknown) const
Find key string in list and convert to enum value. 
Definition: substring.h:1832
 
const char * str_scan_nws_r(const char *str, const char *end)
Scan string pointer for next non-whitespace character in reverse and return new end after stop pointe...
Definition: strscan.h:896
 
T getbool() const
Convert to bool value for given boolean type. 
Definition: substring.h:1343
 
bool operator!=(const PtrBase< T > &ptr1, const PtrBase< T, Atomic< T *> > &ptr2)
Inequality operator for managed pointer base and atomic pointer base. 
Definition: atomic.h:1202
 
ULong numul(int base=0) const
Convert to number value (unsigned long). 
Definition: substring.h:1403
 
Key findnonword(Key start=0, Key end=END) const
Find first non-word word character. 
Definition: substring.h:937
 
bool operator!=(const ListBase< wchar16, T > &str)
Inequality operator to compare against UTF-16 string. 
Definition: substring.h:642
 
SubString & strip2()
Strip left (beginning) and right (ending) whitespace from string, including newlines. 
Definition: substring.h:1167
 
Evo base exception class. 
Definition: sys.h:1214
 
Key find(StringSearchAlg alg, const char *pattern, uint pattern_size, Key start=0, Key end=END) const
Find first occurrence of pattern string using specified algorithm. 
Definition: substring.h:716
 
SubString & convert_set(C value)
Convert value to string, replacing current string. 
Definition: substring.h:1432
 
SubString(const StringBase &str, Key index, Size size=ALL)
Copy constructor. 
Definition: substring.h:263
 
bool token_any(StringT &value, Char &found_delim, const char *delims, Size count)
Extract next token from string using any of given delimiters. 
Definition: substring.h:457
 
const char * cstr(String &buffer) const
Get terminated string pointer, using given string buffer if needed (const). 
Definition: substring.h:599
 
Key find(const char *pattern, uint pattern_size, Key start=0, Key end=END) const
Find first occurrence of pattern string. 
Definition: substring.h:705
 
ULongL numull(int base=0) const
Convert to number value (unsigned long-long). 
Definition: substring.h:1407
 
LongL numll(int base=0) const
Convert to number value (signed long-long). 
Definition: substring.h:1393
 
Evo C++ Library namespace. 
Definition: alg.h:11
 
Key findr(char ch, Key start, Key end=END) const
Find last occurrence of character with reverse search. 
Definition: substring.h:764
 
bool null() const
Get whether null. 
Definition: substring.h:1765
 
UInt numu(int base=0) const
Convert to number value (unsigned). 
Definition: substring.h:1399
 
StringSearchAlg
String search algorithm selection. 
Definition: str.h:1164
 
static const EndT NONE
Special integer value for indicating no item or unknown item. 
Definition: type.h:1832
 
Key findanybut(const StringBase &chars, Key start=0, Key end=END) const
Find first occurrence of any character not listed with forward search. 
Definition: substring.h:889
 
SubString & truncate(Size size)
Truncate to given size. 
Definition: substring.h:1315
 
DataCopy< char >::PassType ItemVal
Item type as parameter (POD types passed by value, otherwise by const-ref) 
Definition: sublist.h:154
 
SubString & operator=(const char *data)
Assignment operator sets as reference to terminated string. 
Definition: substring.h:338
 
SizeT size() const
Get number of items in map. 
Definition: substring.h:1751
 
SubString & set2(const StringBase &data, Key index1, Key index2)
Set as reference to subset of source data using start/end positions. 
Definition: substring.h:1299
 
ListBaseType StringBase
Alias for ListBaseType. 
Definition: substring.h:231
 
SubString & strip()
Strip left (beginning) and right (ending) whitespace (spaces and tabs). 
Definition: substring.h:1061
 
SubString ThisType
This string type. 
Definition: substring.h:230
 
SubString & operator=(const ValNull &val)
Assignment operator sets as null. 
Definition: substring.h:360
 
SubString & strip_newlines()
Strip left (beginning) and right (ending) newlines from string. 
Definition: substring.h:1266
 
SubString & setempty()
Set as empty but not null. 
Definition: substring.h:1303
 
Key findanybutr(const StringBase &chars, Key start=0, Key end=END) const
Find last occurrence of any character not listed with reverse search. 
Definition: substring.h:909
 
T * data_
Data pointer, NULL if null. 
Definition: sys.h:979
 
String & add(char ch)
Append character (modifier). 
Definition: string.h:2741
 
#define EVO_ONCPP14_FULL(EXPR)
Compile EXPR only if "full" C++14 support is detected, otherwise this is a no-op. ...
Definition: sys.h:292
 
SubString & stripr(const char *str, Size strsize, Size max=ALL)
Strip right (ending) occurences of string. 
Definition: substring.h:1150
 
bool contains(char ch) const
Check whether this contains given character. 
Definition: substring.h:961
 
T getnumf(Error &error) const
Convert to floating point number value for given type. 
Definition: substring.h:1364
 
Key find(const StringBase &pattern, Key start=0, Key end=END) const
Find first occurrence of pattern string. 
Definition: substring.h:727
 
SubString & trimr(Size size)
Trim right (ending) items. 
Definition: substring.h:1311
 
SubString & operator=(const StringBase &data)
Assignment operator sets as reference to source data. 
Definition: substring.h:324
 
Bool boolval() const
Convert to bool value. 
Definition: substring.h:1379
 
Reference and access existing list data. 
Definition: sublist.h:145
 
Error error() const
Get error code. 
Definition: sys.h:1260
 
bool splitr(char delim, T1 &left) const
Split at last occurrence of delimiter into left substring. 
Definition: substring.h:1033
 
bool operator!=(const char *str) const
Inequality operator. 
Definition: substring.h:648
 
TSize size_
Data size as item count, 0 if empty or null. 
Definition: sys.h:980
 
Nullable basic floating-point base type. 
Definition: type.h:1291
 
Key find(char ch, Key start, Key end=END) const
Find first occurrence of character with forward search. 
Definition: substring.h:691
 
SubString & stripl(const char *str, Size strsize, Size max=ALL)
Strip left (beginning) occurrences of string. 
Definition: substring.h:1115
 
bool split(char delim, T1 &left, T2 &right) const
Split at first occurrence of delimiter into left/right substrings. 
Definition: substring.h:976
 
Key findanybutr(const char *chars, Size count, Key start=0, Key end=END) const
Find last occurrence of any character not listed with reverse search. 
Definition: substring.h:893
 
T find_enum_remap(const T *remap_array, const SubString &key, T first_enum, T last_enum, T unknown) const
Find key string in list and convert to enum value, with unsorted enum remapped to sorted values...
Definition: substring.h:1887
 
Key findr(char ch) const
Find last occurrence of character with reverse search. 
Definition: substring.h:747
 
String & set()
Set as null and empty. 
Definition: string.h:995
 
SubString(const StringBase &str)
Copy constructor. 
Definition: substring.h:252
 
bool splitr(char delim, T1 &left, T2 &right) const
Split at last occurrence of delimiter into left/right substrings. 
Definition: substring.h:1018
 
uint32 SizeT
Default Evo container size type. 
Definition: sys.h:729
 
bool verify() const
Verify strings are in correct order. 
Definition: substring.h:1996
 
#define EVO_THROW(TYPE, MSG)
Throw an Evo exception. 
Definition: sys.h:1446
 
Reference and access existing string data. 
Definition: substring.h:229
 
SubString(const StringBase *str)
Copy constructor. 
Definition: substring.h:272
 
int utf16_compare8(const wchar16 *str1, ulong len1, const char *str2, ulong len2)
Compare a non-terminated UTF-16 string to a non-terminated UTF-8 string. 
Definition: str.h:842
 
ulong line() const
Get exception line number. 
Definition: sys.h:1248
 
SubString & stripr(char ch, Size max=ALL)
Strip right (ending) occurences of character. 
Definition: substring.h:1143
 
Base for all Evo list types (used internally). 
Definition: sys.h:976
 
SubString & slice(Key index)
Slice beginning items. 
Definition: substring.h:1319
 
SubString & operator=(const ValEmpty &val)
Assignment operator sets as null. 
Definition: substring.h:366
 
Key findr(StringSearchAlg alg, const char *pattern, uint pattern_size, Key start=0, Key end=END) const
Find last occurrence of pattern string with reverse search. 
Definition: substring.h:797
 
bool ends(const char *str) const
Check if ends with given terminated string. 
Definition: substring.h:671
 
Key findanyr(const char *chars, Size count, Key start=0, Key end=END) const
Find last occurrence of any given characters with reverse search. 
Definition: substring.h:853
 
#define EVO_PARAM_UNUSED(NAME)
Mark function parameter as unused to suppress "unreferenced parameter" compiler warnings on it...
Definition: sys.h:427
 
const char * data() const
Get data pointer. 
 
bool split(char delim, T1 &left) const
Split at first occurrence of delimiter into left substring. 
Definition: substring.h:991
 
T::Type EnumType
Alias for enum type used (T::Type) 
Definition: substring.h:2010
 
Builds a reversed enum value remap array for fast reverse lookups. 
Definition: substring.h:2009
 
Key findword(Key start=0, Key end=END) const
Find first word character. 
Definition: substring.h:913
 
SubString & stripl_newlines(Size max)
Strip left (beginning) newlines from string. 
Definition: substring.h:1209