Evo C++ Library v0.5.1
Public Types | Public Member Functions | Public Attributes | List of all members
SubString Struct Reference

#include <evo/substring.h>

Inheritance diagram for SubString:
Inheritance graph
[legend]

Detailed Description

Reference and access existing string data.

Use to explictly reference string data, split/tokenize string data, and to convert to other types.

Features

C++11:

Note: Including this automatically includes evo/string.h too

Iterators
Constructors
Read Access
Modifiers
Example
#include <evo/substring.h>
#include <evo/io.h>
using namespace evo;
static Console& c = con();
int main() {
// Create substring from string literal
SubString str("foo,123");
// operator[] provides read-only (const) access
char value = str[0];
//str[0] = 0; // Error: operator[] is read-only
// Iterate and print characters (read-only)
for (SubString::Iter iter(str); iter; ++iter)
c.out << "Ch: " << *iter << NL;
// Split substring into 2 substrings
SubString sub1, sub2;
str.split(',', sub1, sub2);
// Print sub1, and sub2 as number (dereference Int to int)
c.out << "1: " << sub1 << NL
<< "2: " << *sub2.num() << NL;
// Use for formatting substring as terminated string
String tmp;
// Print sub1 as terminated string (just for example)
c.out << sub1.cstr(tmp) << NL;
return 0;
}

Output:

Ch: f
Ch: o
Ch: o
Ch: ,
Ch: 1
Ch: 2
Ch: 3
1: foo
2: 123
foo

Public Types

typedef void EvoContainerType
 Identify Evo container type. More...
 
typedef char Item
 Item type (same as Value) More...
 
typedef DataCopy< char >::PassType ItemVal
 Item type as parameter (POD types passed by value, otherwise by const-ref) More...
 
typedef IteratorRa< ThisType >::Const Iter
 Iterator (const) - IteratorRa. More...
 
typedef Size Key
 Key type (item index) More...
 
typedef ListBase< char, SizeListBaseType
 List base type for any Evo list More...
 
typedef StrSizeT Size
 List size integer type. More...
 
typedef ListBaseType StringBase
 Alias for ListBaseType. More...
 
typedef SubList< char, SizeSubListType
 SubList base type More...
 
typedef SubString ThisType
 This string type. More...
 
typedef char Value
 Value type (same as Item) More...
 

Public Member Functions

 SubString ()
 Default constructor sets as null. More...
 
 SubString (const ThisType &str)
 Copy constructor. More...
 
 SubString (const StringBase &str)
 Copy constructor. More...
 
 SubString (const StringBase &str, Key index, Size size=ALL)
 Copy constructor. More...
 
 SubString (const StringBase *str)
 Copy constructor. More...
 
 SubString (const char *data, Size size)
 Constructor to reference string data. More...
 
 SubString (const char *data)
 Constructor to reference terminated string. More...
 
 SubString (SubString &&src)
 Move constructor (C++11). More...
 
const SubStringasconst () const
 Explicitly use a const reference to this. More...
 
Iter begin () const
 Get iterator at first item (const). More...
 
Bool boolval () const
 Convert to bool value. More...
 
Iter cbegin () const
 Get iterator at first item (const). More...
 
Iter cend () const
 Get iterator at end (const). More...
 
SubStringclear ()
 Clear by removing all items. More...
 
template<class T >
int compare (const ListBase< wchar16, T > &str)
 Comparison against UTF-16 string. More...
 
int compare (const StringBase &data) const
 Comparison. More...
 
bool contains (ItemVal item) const
 Check whether contains given item. More...
 
bool contains (char ch) const
 Check whether this contains given character. More...
 
bool contains (const char *str, Size size) const
 Check whether this contains given string. More...
 
bool contains (const StringBase &str) const
 Check whether contains given string. More...
 
template<class C >
convert () const
 Convert string to value of given type. More...
 
template<class C >
SubStringconvert_set (C value)
 Convert value to string, replacing current string. More...
 
const char * cstr (String &buffer) const
 Get terminated string pointer, using given string buffer if needed (const). More...
 
const char * data () const
 Get data pointer. More...
 
bool empty () const
 Get whether empty. More...
 
Iter end () const
 Get iterator at end (const). More...
 
bool ends (ItemVal item) const
 Check if this ends with given item. More...
 
bool ends (const Item *items, Size size) const
 Check if this ends with given items. More...
 
bool ends (const ListBaseType &items) const
 Check if this ends with given items. More...
 
bool ends (const char *str) const
 Check if ends with given terminated string. More...
 
Key find (char ch) const
 Find first occurrence of character with forward search. More...
 
Key find (char ch, Key start, Key end=END) const
 Find first occurrence of character with forward search. More...
 
Key find (const char *pattern, uint pattern_size, Key start=0, Key end=END) const
 Find first occurrence of pattern string. More...
 
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. More...
 
Key find (const StringBase &pattern, Key start=0, Key end=END) const
 Find first occurrence of pattern string. More...
 
Key find (StringSearchAlg alg, const StringBase &pattern, Key start=0, Key end=END) const
 Find first occurrence of pattern string using specified algorithm. More...
 
Key find (ItemVal item, Key start, Key end) const
 Find first occurrence of item with forward search. More...
 
Key findany (const char *chars, Size count, Key start=0, Key end=END) const
 Find first occurrence of any given characters with forward search. More...
 
Key findany (const StringBase &chars, Key start=0, Key end=END) const
 Find first occurrence of any given characters with forward search. More...
 
Key findany (const char *items, Size count, Key start, Key end) const
 Find first occurrence of any given items with forward search. More...
 
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. More...
 
Key findanybut (const StringBase &chars, Key start=0, Key end=END) const
 Find first occurrence of any character not listed with forward search. More...
 
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. More...
 
Key findanybutr (const StringBase &chars, Key start=0, Key end=END) const
 Find last occurrence of any character not listed with reverse search. More...
 
Key findanyr (const char *chars, Size count, Key start=0, Key end=END) const
 Find last occurrence of any given characters with reverse search. More...
 
Key findanyr (const StringBase &chars, Key start=0, Key end=END) const
 Find last occurrence of any given characters with reverse search. More...
 
Key findanyr (const char *items, Size count, Key start, Key end) const
 Find last occurrence of any given items with reverse search. More...
 
Key findnonword (Key start=0, Key end=END) const
 Find first non-word word character. More...
 
Key findnonwordr (Key start=0, Key end=END) const
 Find last non-word character with reverse search. More...
 
Key findr (char ch) const
 Find last occurrence of character with reverse search. More...
 
Key findr (char ch, Key start, Key end=END) const
 Find last occurrence of character with reverse search. More...
 
Key findr (const char *pattern, uint pattern_size, Key start=0, Key end=END) const
 Find last occurrence of pattern string with reverse search. More...
 
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. More...
 
Key findr (const StringBase &pattern, Key start=0, Key end=END) const
 Find last occurrence of pattern string with reverse search. More...
 
Key findr (StringSearchAlg alg, const StringBase &pattern, Key start=0, Key end=END) const
 Find last occurrence of pattern string with reverse search. More...
 
Key findr (ItemVal item, Key start, Key end) const
 Find last occurrence of item with reverse search. More...
 
Key findword (Key start=0, Key end=END) const
 Find first word character. More...
 
Key findwordr (Key start=0, Key end=END) const
 Find last word character with reverse search. More...
 
const char * first () const
 Get first item (const). More...
 
bool getbool (Error &error) const
 Convert to bool value for given boolean type. More...
 
template<class T >
getbool () const
 Convert to bool value for given boolean type. More...
 
template<class T >
getnum (Error &error, int base=0) const
 Convert to number value for given integer type. More...
 
template<class T >
getnum (int base=0) const
 Convert to number value for given integer type. More...
 
template<class T >
getnumf (Error &error) const
 Convert to floating point number value for given type. More...
 
template<class T >
getnumf () const
 Convert to floating point number value for given type. More...
 
ulong hash (ulong seed) const
 Get data hash value. More...
 
Key iend (Size offset) const
 Get index from last item using offset. More...
 
const char & item (Key index) const
 Get item at position. More...
 
const char * last () const
 Get last item (const). More...
 
bool null () const
 Get whether null. More...
 
Int num (int base=0) const
 Convert to number value (signed). More...
 
Float numf () const
 Convert to number value (floating point). More...
 
FloatD numfd () const
 Convert to number value (double floating point). More...
 
FloatL numfl () const
 Convert to number value (ldouble floating point). More...
 
Long numl (int base=0) const
 Convert to number value (signed long). More...
 
LongL numll (int base=0) const
 Convert to number value (signed long-long). More...
 
UInt numu (int base=0) const
 Convert to number value (unsigned). More...
 
ULong numul (int base=0) const
 Convert to number value (unsigned long). More...
 
ULongL numull (int base=0) const
 Convert to number value (unsigned long-long). More...
 
template<class T >
bool operator!= (const ListBase< wchar16, T > &str)
 Inequality operator to compare against UTF-16 string. More...
 
bool operator!= (const char *str) const
 Inequality operator. More...
 
bool operator!= (const StringBase &data) const
 Inequality operator. More...
 
SubStringoperator= (SubString &&src)
 Move assignment operator (C++11). More...
 
SubStringoperator= (const SubString &src)
 Assignment operator. More...
 
SubStringoperator= (const StringBase &data)
 Assignment operator sets as reference to source data. More...
 
SubStringoperator= (const StringBase *data)
 Assignment operator sets as reference to source data from pointer. More...
 
SubStringoperator= (const char *data)
 Assignment operator sets as reference to terminated string. More...
 
SubStringoperator= (const ValNull &val)
 Assignment operator sets as null. More...
 
SubStringoperator= (const ValEmpty &val)
 Assignment operator sets as null. More...
 
template<class T >
bool operator== (const ListBase< wchar16, T > &str)
 Equality operator to compare against UTF-16 string. More...
 
bool operator== (const char *str) const
 Equality operator. More...
 
bool operator== (const StringBase &data) const
 Equality operator. More...
 
const char & operator[] (Key index) const
 Get item at position. More...
 
SubStringset (const char *data)
 Set as reference to terminated string. More...
 
SubStringset ()
 Set as null. More...
 
SubStringset (const StringBase &data)
 Set as reference to source data. More...
 
SubStringset (const StringBase &data, Key index, Key size=ALL)
 Set as reference to source data. More...
 
SubStringset (const StringBase *data)
 Set as reference to source data by pointer. More...
 
SubStringset (const char *data, Size size)
 Set as reference to data pointer. More...
 
SubStringset2 (const StringBase &data, Key index1, Key index2)
 Set as reference to subset of source data using start/end positions. More...
 
SubStringsetempty ()
 Set as empty but not null. More...
 
bool shared () const
 Get whether shared (false). More...
 
Size size () const
 Get size. More...
 
SubStringslice (Key index)
 Slice beginning items. More...
 
SubStringslice (Key index, Size size)
 Slice to given subset. More...
 
SubStringslice2 (Key index1, Key index2)
 Slice to given subset using start/end positions. More...
 
template<class T1 , class T2 >
bool split (char delim, T1 &left, T2 &right) const
 Split at first occurrence of delimiter into left/right substrings. More...
 
template<class T1 >
bool split (char delim, T1 &left) const
 Split at first occurrence of delimiter into left substring. More...
 
template<class T2 >
bool split (char delim, ValNull left, T2 &right) const
 Split at first occurrence of delimiter into right substring. More...
 
template<class Tok , class C >
C::Size split (C &items, char delim=',') const
 Split delimited string into item list using given tokenizer. More...
 
template<class T1 , class T2 >
bool splitat (Key index, T1 &left, T2 &right) const
 Split into left/right sublists at index. More...
 
template<class T1 >
bool splitat (Key index, T1 &left) const
 Split into left sublist at index. More...
 
template<class T2 >
bool splitat (Key index, ValNull left, T2 &right) const
 Split into right sublist at index. More...
 
bool splitat_setl (Key index)
 Split at index and set as left sublist. More...
 
template<class T2 >
bool splitat_setl (Key index, T2 &right)
 Split at index, set as left sublist, and save right sublist. More...
 
bool splitat_setr (Key index)
 Split at index and set as right sublist. More...
 
template<class T1 >
bool splitat_setr (Key index, T1 &left)
 Split at index, set as right sublist, and save left sublist. More...
 
template<class T1 , class T2 >
bool splitr (char delim, T1 &left, T2 &right) const
 Split at last occurrence of delimiter into left/right substrings. More...
 
template<class T1 >
bool splitr (char delim, T1 &left) const
 Split at last occurrence of delimiter into left substring. More...
 
template<class T2 >
bool splitr (char delim, ValNull left, T2 &right) const
 Split at last occurrence of delimiter into right substring. More...
 
bool starts (ItemVal item) const
 Check if this starts with given item. More...
 
bool starts (const Item *items, Size size) const
 Check if starts with given items. More...
 
bool starts (const ListBaseType &items) const
 Check if this starts with given items. More...
 
bool starts (const char *str) const
 Check if starts with given terminated string. More...
 
SubStringstrip ()
 Strip left (beginning) and right (ending) whitespace (spaces and tabs). More...
 
SubStringstrip (char ch)
 Strip left (beginning) and right (ending) occurences of character. More...
 
SubStringstrip2 ()
 Strip left (beginning) and right (ending) whitespace from string, including newlines. More...
 
SubStringstrip_newlines ()
 Strip left (beginning) and right (ending) newlines from string. More...
 
SubStringstripl ()
 Strip left (beginning) whitespace (spaces and tabs). More...
 
SubStringstripl (char ch, Size max=ALL)
 Strip left (beginning) occurrences of character. More...
 
SubStringstripl (const char *str, Size strsize, Size max=ALL)
 Strip left (beginning) occurrences of string. More...
 
SubStringstripl2 ()
 Strip left (beginning) whitespace from string, including newlines. More...
 
SubStringstripl_newlines ()
 Strip all left (beginning) newlines from string. More...
 
SubStringstripl_newlines (Size max)
 Strip left (beginning) newlines from string. More...
 
SubStringstripr ()
 Strip right (ending) whitespace (spaces and tabs). More...
 
SubStringstripr (char ch, Size max=ALL)
 Strip right (ending) occurences of character. More...
 
SubStringstripr (const char *str, Size strsize, Size max=ALL)
 Strip right (ending) occurences of string. More...
 
SubStringstripr2 ()
 Strip right (ending) whitespace (including newlines) from string. More...
 
SubStringstripr_newlines ()
 Strip all right (ending) newlines from string. More...
 
SubStringstripr_newlines (Size max)
 Strip right (ending) newlines from string. More...
 
void swap (ThisType &list)
 Swap with another sublist. More...
 
void swap (StringBase &list)
 Swap with another sublist. More...
 
template<class StringT >
bool token (StringT &value, char delim)
 Extract next token from string. More...
 
template<class StringT >
bool token_any (StringT &value, Char &found_delim, const char *delims, Size count)
 Extract next token from string using any of given delimiters. More...
 
template<class StringT >
bool token_line (StringT &line)
 Extract next line from string. More...
 
template<class StringT >
bool tokenr (StringT &value, char delim)
 Extract next token from string in reverse (from end of string). More...
 
template<class StringT >
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. More...
 
template<class StringT >
bool tokenr_line (StringT &line)
 Extract next line from string in reverse (from end of string). More...
 
SubStringtriml (Size size)
 Trim left (beginning) items. More...
 
SubStringtrimr (Size size)
 Trim right (ending) items. More...
 
SubStringtruncate (Size size)
 Truncate to given size. More...
 
SubStringunshare ()
 Make data unique – no-op. More...
 

Public Attributes

char * data_
 Data pointer, NULL if null. More...
 
StrSizeT size_
 Data size as item count, 0 if empty or null. More...
 

Member Typedef Documentation

◆ EvoContainerType

typedef void EvoContainerType
inherited

Identify Evo container type.

◆ Item

typedef char Item
inherited

Item type (same as Value)

◆ ItemVal

typedef DataCopy<char >::PassType ItemVal
inherited

Item type as parameter (POD types passed by value, otherwise by const-ref)

◆ Iter

typedef IteratorRa<ThisType>::Const Iter
inherited

Iterator (const) - IteratorRa.

◆ Key

typedef Size Key
inherited

Key type (item index)

◆ ListBaseType

typedef ListBase<char ,Size> ListBaseType
inherited

List base type for any Evo list

◆ Size

typedef StrSizeT Size
inherited

List size integer type.

◆ StringBase

Alias for ListBaseType.

◆ SubListType

typedef SubList<char ,Size> SubListType
inherited

SubList base type

◆ ThisType

This string type.

◆ Value

typedef char Value
inherited

Value type (same as Item)

Constructor & Destructor Documentation

◆ SubString() [1/8]

SubString ( )
inline

Default constructor sets as null.

◆ SubString() [2/8]

SubString ( const ThisType str)
inline

Copy constructor.

  • This will reference the same pointer as given string
  • Caution: Source string pointer must remain valid
Parameters
strString to copy

◆ SubString() [3/8]

SubString ( const StringBase str)
inline

Copy constructor.

  • This will reference the same pointer as given string
  • Caution: Source string pointer must remain valid
Parameters
strString to copy

◆ SubString() [4/8]

SubString ( const StringBase str,
Key  index,
Size  size = ALL 
)
inline

Copy constructor.

  • This will reference the same pointer as given string
  • Caution: Source string pointer must remain valid
Parameters
strString to reference
indexStart index of string to reference, END to set as empty
sizeSize as item count, ALL for all from index

◆ SubString() [5/8]

SubString ( const StringBase str)
inline

Copy constructor.

  • This will reference the same pointer as given string
  • Caution: Source string pointer must remain valid
Parameters
strPointer to string to copy, NULL to set as null

◆ SubString() [6/8]

SubString ( const char *  data,
Size  size 
)
inline

Constructor to reference string data.

Parameters
dataString data to reference
sizeString size in bytes

◆ SubString() [7/8]

SubString ( const char *  data)
inline

Constructor to reference terminated string.

Parameters
dataString data to reference – must be terminated

◆ SubString() [8/8]

SubString ( SubString &&  src)
inline

Move constructor (C++11).

Parameters
srcSource to move

Member Function Documentation

◆ asconst()

const SubString& asconst ( ) const
inline

Explicitly use a const reference to this.

  • This is useful to force using this as const without casting
Returns
This

◆ begin()

Iter begin ( ) const
inlineinherited

Get iterator at first item (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
Returns
Iterator at first item, or at end position if empty
See also
end(), cbegin()

◆ boolval()

Bool boolval ( ) const
inline

Convert to bool value.

Fails on bad format, empty, or number overflow.

Format: [WHITESPACE] ["on"|"off"|"yes"|"no"|"true"|"false"|"t"|"f"|DIGITS] [WHITESPACE]

  • Result is true if non-zero number – checked using getnum(Error&,int) with T=long, base=0
  • Case insensitive
Returns
Converted value, set to null on failure

◆ cbegin()

Iter cbegin ( ) const
inlineinherited

Get iterator at first item (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
Returns
Iterator at first item, or at end position if empty
See also
Iter, cend(), begin(), end()

◆ cend()

Iter cend ( ) const
inlineinherited

Get iterator at end (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • This really just creates an empty iterator
Returns
Iterator at end position
See also
Iter, cbegin(), begin(), end()

◆ clear()

SubString& clear ( )
inline

Clear by removing all items.

  • Does not set as null – null status is unchanged
Returns
This

◆ compare() [1/2]

int compare ( const ListBase< wchar16, T > &  str)
inline

Comparison against UTF-16 string.

Template Parameters
TInferred from argument
Parameters
strString to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ compare() [2/2]

int compare ( const StringBase data) const

Comparison.

Parameters
dataData to compare to
Returns
Result (<0 if this is less, 0 if equal, >0 if this is greater)

◆ contains() [1/4]

bool contains ( ItemVal  item) const
inlineinherited

Check whether contains given item.

  • This does a simple linear search for given item, using item operator==() for comparisons
Parameters
itemItem to check for
Returns
Whether item was found

◆ contains() [2/4]

bool contains ( char  ch) const
inline

Check whether this contains given character.

Parameters
chCharacter to check for
Returns
Whether character was found

◆ contains() [3/4]

bool contains ( const char *  str,
Size  size 
) const
inline

Check whether this contains given string.

Parameters
strPointer to string to check for
sizeString size in bytes
Returns
Whether string was found

◆ contains() [4/4]

bool contains ( const StringBase str) const
inline

Check whether contains given string.

Parameters
strString to check for
Returns
Whether string was found

◆ convert()

C convert ( ) const
inline

Convert string to value of given type.

Template Parameters
CType to convert to
Returns
Converted value

◆ convert_set()

SubString& convert_set ( value)
inline

Convert value to string, replacing current string.

Template Parameters
CType to convert from, inferred from argument
Parameters
valueValue to convert

◆ cstr()

const char* cstr ( String buffer) const
inline

Get terminated string pointer, using given string buffer if needed (const).

  • Caution: Modifying buffer may (will) invalidate the returned pointer
Parameters
bufferBuffer to use, if needed
Returns
Terminated string pointer

◆ data()

const char* data ( ) const

Get data pointer.

  • Caution: May return an invalid non-NULL pointer if empty
Returns
Data pointer as read-only, NULL if null, may be invalid if empty (const)

◆ empty()

bool empty ( ) const

Get whether empty.

Returns
Whether empty

◆ end()

Iter end ( ) const
inlineinherited

Get iterator at end (const).

  • This allows compatibility with range-based for loops and other libraries, otherwise use container Iter directly
  • This really just creates an empty iterator
Returns
Iterator at end position
See also
begin(), cend()

◆ ends() [1/4]

bool ends ( ItemVal  item) const
inlineinherited

Check if this ends with given item.

  • Uses item operator==() for comparisons
Parameters
itemItem to check
Returns
Whether ends with item

◆ ends() [2/4]

bool ends ( const Item items,
Size  size 
) const
inlineinherited

Check if this ends with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
sizeItem count to check
Returns
Whether ends with items

◆ ends() [3/4]

bool ends ( const ListBaseType items) const
inlineinherited

Check if this ends with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
Returns
Whether ends with items

◆ ends() [4/4]

bool ends ( const char *  str) const
inline

Check if ends with given terminated string.

Parameters
strString to check for – must be terminated
Returns
Whether ends with string

◆ find() [1/7]

Key find ( char  ch) const
inline

Find first occurrence of character with forward search.

Parameters
chCharacter to find
Returns
Found character index, NONE if not found

◆ find() [2/7]

Key find ( char  ch,
Key  start,
Key  end = END 
) const
inline

Find first occurrence of character with forward search.

  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
chCharacter to find
startStarting index for search
endEnd index for search, END for end of string
Returns
Found character index, NONE if not found

◆ find() [3/7]

Key find ( const char *  pattern,
uint  pattern_size,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of pattern string.

Parameters
patternPointer to pattern to look for, must not be NULL
pattern_sizePattern size in bytes
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern_size=0

◆ find() [4/7]

Key find ( StringSearchAlg  alg,
const char *  pattern,
uint  pattern_size,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of pattern string using specified algorithm.

  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
algSearch algorithm to use, see StringSearchAlg
patternPointer to pattern to look for, must not be NULL
pattern_sizePattern size in bytes
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern_size=0

◆ find() [5/7]

Key find ( const StringBase pattern,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of pattern string.

Parameters
patternPattern to look for
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern is empty

◆ find() [6/7]

Key find ( StringSearchAlg  alg,
const StringBase pattern,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of pattern string using specified algorithm.

  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
algSearch algorithm to use, see StringSearchAlg
patternPattern to look for
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern_size=0

◆ find() [7/7]

Key find ( ItemVal  item,
Key  start,
Key  end 
) const

Find first occurrence of item with forward search.

  • This searches for given item, using item operator==() for comparisons
  • Search stops before reaching end index or end of list
  • Item at end index is not checked
Parameters
itemItem to find
startStarting index for search
endEnd index for search, END for end of list
Returns
Found item index or NONE if not found

◆ findany() [1/3]

Key findany ( const char *  chars,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of any given characters with forward search.

  • This searches for any one of the given characters
  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
charsCharacters to search for, must not contain multi-byte chars
countCharacter count to search for
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index , NONE if not found or if count=0

◆ findany() [2/3]

Key findany ( const StringBase chars,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of any given characters with forward search.

  • This searches for any one of the given characters
  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
charsCharacters to search for, must not contain multi-byte chars
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index, NONE if not found or if chars is empty

◆ findany() [3/3]

Key findany ( const char *  items,
Size  count,
Key  start,
Key  end 
) const

Find first occurrence of any given items with forward search.

  • This searches for any of given items, using item operator==() for comparisons
  • Search stops before reaching end index or end of list
Parameters
itemsItems to search for
countCount of items to search for
startStarting index for search
endEnd index for search, END for end of list
Returns
Found item index or NONE if not found

◆ findanybut() [1/2]

Key findanybut ( const char *  chars,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of any character not listed with forward search.

  • This searches for any character not in chars
  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
charsExcluded characters, must not contain multi-byte chars
countExcluded character count
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index, NONE if not found

◆ findanybut() [2/2]

Key findanybut ( const StringBase chars,
Key  start = 0,
Key  end = END 
) const
inline

Find first occurrence of any character not listed with forward search.

  • This searches for any character not in chars
  • Search stops before reaching end index or end of string
  • Character at end index is not checked
Parameters
charsExcluded characters, must not contain multi-byte chars
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index, NONE if not found

◆ findanybutr() [1/2]

Key findanybutr ( const char *  chars,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of any character not listed with reverse search.

  • This searches for any character not in chars
  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
charsExcluded characters, must not contain multi-byte chars
countExcluded character count
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found

◆ findanybutr() [2/2]

Key findanybutr ( const StringBase chars,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of any character not listed with reverse search.

  • This searches for any character not in chars
  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
charsExcluded characters, must not contain multi-byte chars
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found

◆ findanyr() [1/3]

Key findanyr ( const char *  chars,
Size  count,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of any given characters with reverse search.

  • This searches for any one of the given characters
  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
charsCharacters to search for, must not contain multi-byte chars
countCharacter count to search for
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found or if count=0

◆ findanyr() [2/3]

Key findanyr ( const StringBase chars,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of any given characters with reverse search.

  • This searches for any one of the given characters
  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
charsCharacters to search for, must not contain multi-byte chars
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found or if chars is empty

◆ findanyr() [3/3]

Key findanyr ( const char *  items,
Size  count,
Key  start,
Key  end 
) const

Find last occurrence of any given items with reverse search.

  • This searches for any of given items, using item operator==() for comparisons
  • Same as findany() but does reverse search starting right before end index or at last item if end of list
  • As with findany(), item at end index is not checked
Parameters
itemsItems to search for
countCount of items to search for
startStarting index for search range – last item checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found item index or NONE if not found

◆ findnonword()

Key findnonword ( Key  start = 0,
Key  end = END 
) const
inline

Find first non-word word character.

  • This finds the first character that is NOT a word character
  • A word character is a letter, number, or underscore – see cbtWORD
Parameters
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index, NONE if not found

◆ findnonwordr()

Key findnonwordr ( Key  start = 0,
Key  end = END 
) const
inline

Find last non-word character with reverse search.

  • This finds the last character that is NOT a word character (with reverse search)
  • A word character is a letter, number, or underscore – see cbtWORD
Parameters
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found

◆ findr() [1/7]

Key findr ( char  ch) const
inline

Find last occurrence of character with reverse search.

  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
chCharacter to find
Returns
Found character index, NONE if not found

◆ findr() [2/7]

Key findr ( char  ch,
Key  start,
Key  end = END 
) const
inline

Find last occurrence of character with reverse search.

  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
chCharacter to find
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of string
Returns
Found character index or NONE if not found

◆ findr() [3/7]

Key findr ( const char *  pattern,
uint  pattern_size,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of pattern string with reverse search.

Parameters
patternPointer to pattern to look for, must not be NULL
pattern_sizePattern size in bytes
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern is empty

◆ findr() [4/7]

Key findr ( StringSearchAlg  alg,
const char *  pattern,
uint  pattern_size,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of pattern string with reverse search.

  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
algSearch algorithm to use, see StringSearchAlg
patternPointer to pattern to look for, must not be NULL
pattern_sizePattern size in bytes
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern is empty

◆ findr() [5/7]

Key findr ( const StringBase pattern,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of pattern string with reverse search.

Parameters
patternPattern to look for
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern is empty

◆ findr() [6/7]

Key findr ( StringSearchAlg  alg,
const StringBase pattern,
Key  start = 0,
Key  end = END 
) const
inline

Find last occurrence of pattern string with reverse search.

  • This does a reverse search starting right before end index
  • Character at end index is not checked
Parameters
algSearch algorithm to use, see StringSearchAlg
patternPattern to look for
startStarting index for search
endEnd index for search, END for end of string
Returns
Found pattern index, NONE if not found or if pattern is empty

◆ findr() [7/7]

Key findr ( ItemVal  item,
Key  start,
Key  end 
) const

Find last occurrence of item with reverse search.

  • This searches for given item, using item operator==() for comparisons
  • This does a reverse search starting right before end index
  • Item at end index is not checked
Parameters
itemItem to find
startStarting index for search range – last item checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found item index or NONE if not found

◆ findword()

Key findword ( Key  start = 0,
Key  end = END 
) const
inline

Find first word character.

  • A word character is a letter, number, or underscore – see cbtWORD
Parameters
startStarting index for search
endEnd index for search, END for end of list
Returns
Found character index, NONE if not found

◆ findwordr()

Key findwordr ( Key  start = 0,
Key  end = END 
) const
inline

Find last word character with reverse search.

  • A word character is a letter, number, or underscore – see cbtWORD
Parameters
startStarting index for search range – last character checked in reverse search
endEnd index for search range (reverse search starting point), END for end of list
Returns
Found character index, NONE if not found

◆ first()

const char* first ( ) const

Get first item (const).

Returns
First item pointer, NULL if empty

◆ getbool() [1/2]

bool getbool ( Error error) const
inline

Convert to bool value for given boolean type.

Fails on bad format, empty, or number overflow.

Format: [WHITESPACE] ["on"|"off"|"yes"|"no"|"true"|"false"|"t"|"f"|DIGITS] [WHITESPACE]

  • Result is true if non-zero number – checked using getnum(Error&,int) with T=long, base=0
  • Case insensitive

Error codes:

  • ENone: success
  • EInval: bad format, invalid character, or no digits
  • EOutOfBounds: number overflow
Parameters
errorStores conversion error code, ENone on success [out]
Returns
Converted value on success, partially converted value or 0 on failure

◆ getbool() [2/2]

T getbool ( ) const
inline

Convert to bool value for given boolean type.

Fails on bad format, empty, or number overflow

Format: [WHITESPACE] ["on"|"off"|"yes"|"no"|"true"|"false"|"t"|"f"|DIGITS] [WHITESPACE]

  • Result is true if non-zero number – checked using getnum(Error&,int) with T=long, base=0
  • Case insensitive
Template Parameters
TBoolean type to convert to – can be Bool or bool
Returns
Converted value on success, Bool set as null on failure, primitive is false on failure

◆ getnum() [1/2]

T getnum ( Error error,
int  base = 0 
) const
inline

Convert to number value for given integer type.

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive

Error codes:

  • ENone: success
  • EInval: bad format, invalid character, or no digits
  • EOutOfBounds: number overflow
Template Parameters
TBasic integer type to convert to – must be primitive like: int32, int, long, uint32, uint, ulong, etc
Parameters
errorStores conversion error code, ENone on success [out]
baseConversion base, 0 for autodetect
Returns
Converted value on success, partially converted value or 0 on failure

◆ getnum() [2/2]

T getnum ( int  base = 0) const
inline

Convert to number value for given integer type.

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
Template Parameters
TInteger type to convert to – can be IntegerT type like Int32, Int, ULong, etc or primitive like int32, int, ulong, etc
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value on success, IntegerT set as null on failure, primitive is 0 on failure

◆ getnumf() [1/2]

T getnumf ( Error error) const
inline

Convert to floating point number value for given type.

Fails on bad format or no digits.

Format: [WHITESPACE] ("nan" | NUMBER) [WHITESPACE]

  • NUMBER: ["+"|"-"] ("inf" | DIGITS ["." DIGITS] [EXPONENT])
  • EXPONENT: ["+"|"-"] ("e"|"E") DIGITS
  • Only decimal (base 10) digits supported
  • Not-A-Number ("nan") and infinite ("inf") values are case insensitive

Error codes:

  • ENone: success
  • EInval: bad format, invalid character, or no digits
Template Parameters
TBasic floating point type to convert to – must be primitive like: float, double, ldouble
Parameters
errorStores conversion error code, ENone on success [out]
Returns
Converted value, partially converted value or 0 on failure

◆ getnumf() [2/2]

T getnumf ( ) const
inline

Convert to floating point number value for given type.

Fails on bad format or no digits.

Format: [WHITESPACE] ("nan" | NUMBER) [WHITESPACE]

  • NUMBER: ["+"|"-"] ("inf" | DIGITS ["." DIGITS] [EXPONENT])
  • EXPONENT: ["+"|"-"] ("e"|"E") DIGITS
  • Only decimal (base 10) digits supported
  • Not-A-Number ("nan") and infinite ("inf") values are case insensitive
Template Parameters
TFloating point type to convert to – can be FloatT type like Float, FloatD, etc or primitive like float, double, etc
Returns
Converted value on success, FloatT set as null on failure, primitive is 0 on failure

◆ hash()

ulong hash ( ulong  seed) const

Get data hash value.

Parameters
seedSeed value for hashing multiple values, 0 if none
Returns
Hash value

◆ iend()

Key iend ( Size  offset) const

Get index from last item using offset.

  • This simplifies math when computing an index from last item
  • This uses the formula: iend = size - 1 - offset
Parameters
offsetOffset from end, 0 for last item, 1 for second-last, etc
Returns
Resulting index, END if offset out of bounds

◆ item()

const char& item ( Key  index) const

Get item at position.

  • Caution: Results are undefined if index is out of bounds – though index is checked with assert()
Parameters
indexItem index
Returns
Given item as read-only (const)

◆ last()

const char* last ( ) const

Get last item (const).

Returns
Last item pointer, NULL if empty

◆ null()

bool null ( ) const

Get whether null.

  • Always empty when null
Returns
Whether null

◆ num()

Int num ( int  base = 0) const
inline

Convert to number value (signed).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ numf()

Float numf ( ) const
inline

Convert to number value (floating point).

Fails on bad format or no digits.

Format: [WHITESPACE] ("nan" | NUMBER) [WHITESPACE]

  • NUMBER: ["+"|"-"] ("inf" | DIGITS ["." DIGITS] [EXPONENT])
  • EXPONENT: ["+"|"-"] ("e"|"E") DIGITS
  • Only decimal (base 10) digits supported
  • Not-A-Number ("nan") and infinite ("inf") values are case insensitive
Returns
Converted value, set as null on failure

◆ numfd()

FloatD numfd ( ) const
inline

Convert to number value (double floating point).

Fails on bad format or no digits.

Format: [WHITESPACE] ("nan" | NUMBER) [WHITESPACE]

  • NUMBER: ["+"|"-"] ("inf" | DIGITS ["." DIGITS] [EXPONENT])
  • EXPONENT: ["+"|"-"] ("e"|"E") DIGITS
  • Only decimal (base 10) digits supported
  • Not-A-Number ("nan") and infinite ("inf") values are case insensitive
Returns
Converted value, set as null on failure

◆ numfl()

FloatL numfl ( ) const
inline

Convert to number value (ldouble floating point).

Fails on bad format or no digits.

Format: [WHITESPACE] ("nan" | NUMBER) [WHITESPACE]

  • NUMBER: ["+"|"-"] ("inf" | DIGITS ["." DIGITS] [EXPONENT])
  • EXPONENT: ["+"|"-"] ("e"|"E") DIGITS
  • Only decimal (base 10) digits supported
  • Not-A-Number ("nan") and infinite ("inf") values are case insensitive
Returns
Converted value, set as null on failure

◆ numl()

Long numl ( int  base = 0) const
inline

Convert to number value (signed long).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ numll()

LongL numll ( int  base = 0) const
inline

Convert to number value (signed long-long).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ numu()

UInt numu ( int  base = 0) const
inline

Convert to number value (unsigned).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
  • Negative values are converted to unsigned equivalent
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ numul()

ULong numul ( int  base = 0) const
inline

Convert to number value (unsigned long).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
  • Negative values are converted to unsigned equivalent
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ numull()

ULongL numull ( int  base = 0) const
inline

Convert to number value (unsigned long-long).

Fails on bad format, no digits, or overflow.

Format: [WHITESPACE] ["+"|"-"] ["0x"|"0X"|"x"|"0"] DIGITS [WHITESPACE]

  • Base 2-36 supported – Base 0 autodetects hex or octal based on prefix, defaults to decimal
  • Base 16 (hex) may use "0x", "0X", or "x" prefix
  • Base 8 (octal) may use "0" prefix
  • Letters in digits are not case sensitive
  • Negative values are converted to unsigned equivalent
Parameters
baseConversion base, 0 for autodetect
Returns
Converted value, set as null on failure

◆ operator!=() [1/3]

bool operator!= ( const ListBase< wchar16, T > &  str)
inline

Inequality operator to compare against UTF-16 string.

Template Parameters
TInferred from argument
Parameters
strString to compare to
Returns
Whether inequal

◆ operator!=() [2/3]

bool operator!= ( const char *  str) const
inline

Inequality operator.

Parameters
strString to compare to – must be null terminated
Returns
Whether inequal

◆ operator!=() [3/3]

bool operator!= ( const StringBase data) const

Inequality operator.

Parameters
dataData to compare to
Returns
Whether inequal

◆ operator=() [1/7]

SubString& operator= ( SubString &&  src)
inline

Move assignment operator (C++11).

Parameters
srcSource to move
Returns
This

◆ operator=() [2/7]

SubString& operator= ( const SubString src)
inline

Assignment operator.

Parameters
srcSource to copy
Returns
This

◆ operator=() [3/7]

SubString& operator= ( const StringBase data)
inline

Assignment operator sets as reference to source data.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference
Returns
This

◆ operator=() [4/7]

SubString& operator= ( const StringBase data)
inline

Assignment operator sets as reference to source data from pointer.

  • This will reference the same pointer as given data pointer, if not NULL
  • Caution: Source data pointer (data->data_) must remain valid
Parameters
dataData pointer to reference, calls set() if NULL
Returns
This

◆ operator=() [5/7]

SubString& operator= ( const char *  data)
inline

Assignment operator sets as reference to terminated string.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference
Returns
This

◆ operator=() [6/7]

SubString& operator= ( const ValNull val)
inline

Assignment operator sets as null.

Parameters
valvNULL
Returns
This

◆ operator=() [7/7]

SubString& operator= ( const ValEmpty val)
inline

Assignment operator sets as null.

Parameters
valvEMPTY
Returns
This

◆ operator==() [1/3]

bool operator== ( const ListBase< wchar16, T > &  str)
inline

Equality operator to compare against UTF-16 string.

Template Parameters
TInferred from argument
Parameters
strString to compare to
Returns
Whether equal

◆ operator==() [2/3]

bool operator== ( const char *  str) const
inline

Equality operator.

Parameters
strString to compare to – must be null terminated
Returns
Whether equal

◆ operator==() [3/3]

bool operator== ( const StringBase data) const

Equality operator.

Parameters
dataData to compare to
Returns
Whether equal

◆ operator[]()

const char& operator[] ( Key  index) const

Get item at position.

  • Caution: Results are undefined if index is out of bounds – though index is checked with assert()
Parameters
indexItem index
Returns
Given item as read-only (const)

◆ set() [1/6]

SubString& set ( const char *  data)
inline

Set as reference to terminated string.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference – must be terminated
Returns
This

◆ set() [2/6]

SubString& set ( )
inline

Set as null.

Returns
This

◆ set() [3/6]

SubString& set ( const StringBase data)
inline

Set as reference to source data.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference
Returns
This

◆ set() [4/6]

SubString& set ( const StringBase data,
Key  index,
Key  size = ALL 
)
inline

Set as reference to source data.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference
indexStart index of data to reference, END to set as empty
sizeSize as item count, ALL for all from index
Returns
This

◆ set() [5/6]

SubString& set ( const StringBase data)
inline

Set as reference to source data by pointer.

  • This will reference the same pointer as given data
  • Caution: Source data pointer must remain valid
Parameters
dataPointer to data to reference, null if NULL
Returns
This

◆ set() [6/6]

SubString& set ( const char *  data,
Size  size 
)
inline

Set as reference to data pointer.

Parameters
dataData to reference
sizeData size as item count

◆ set2()

SubString& set2 ( const StringBase data,
Key  index1,
Key  index2 
)
inline

Set as reference to subset of source data using start/end positions.

  • This will reference the same pointer as given data
  • If data is null then this will be set to null
  • If index2 <= index1 then this will be set to an empty sublist
  • Caution: Source data pointer must remain valid
Parameters
dataData to reference
index1Start index of data to reference, END to set as empty
index2End index of data (this item not included), END for all after index1
Returns
This

◆ setempty()

SubString& setempty ( )
inline

Set as empty but not null.

Returns
This

◆ shared()

bool shared ( ) const

Get whether shared (false).

  • This doesn't support sharing or unique states, so this always returns false
  • Referenced data is considered constant and immutable while it's referenced
Returns
Whether shared (always false)

◆ size()

Size size ( ) const

Get size.

Returns
Size as item count

◆ slice() [1/2]

SubString& slice ( Key  index)
inline

Slice beginning items.

  • This adjusts pointer, trimming beginning items
  • If null then will be left null
Parameters
indexStart index of new slice, END to set as empty (or leave null if null)
Returns
This

◆ slice() [2/2]

SubString& slice ( Key  index,
Size  size 
)
inline

Slice to given subset.

  • This adjusts pointer to given subset
  • If null then will be left null
Parameters
indexStart index of new slice, END to set as empty (or leave null if null)
sizeSlice size as item count, ALL for all from index
Returns
This

◆ slice2()

SubString& slice2 ( Key  index1,
Key  index2 
)
inline

Slice to given subset using start/end positions.

  • This adjusts pointer to given subset
  • If index2 < index1 then result will be empty
  • If null then will be left null
Parameters
index1Start index of new slice, END to set as empty (or leave null if null)
index2End index of new slice (this item not included), END for all after index1
Returns
This

◆ split() [1/4]

bool split ( char  delim,
T1 &  left,
T2 &  right 
) const
inline

Split at first occurrence of delimiter into left/right substrings.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1String type to store left substring
T2String type to store right substring
Parameters
delimDelimiter to find
leftSet to substring before delim, set to this if not found [out]
rightSet to substring after delim, null if not found [out]
Returns
Whether successful, false if delim not found

◆ split() [2/4]

bool split ( char  delim,
T1 &  left 
) const
inline

Split at first occurrence of delimiter into left substring.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1String type to store left substring
Parameters
delimDelimiter to find
leftSet to substring before delim, set to this if not found [out]
Returns
Whether successful, false if delim not found

◆ split() [3/4]

bool split ( char  delim,
ValNull  left,
T2 &  right 
) const
inline

Split at first occurrence of delimiter into right substring.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T2String type to store right substring
Parameters
delimDelimiter to find
leftvNULL (ignored)
rightSet to substring after delim, null if not found [out]
Returns
Whether successful, false if delim not found

◆ split() [4/4]

C::Size split ( C &  items,
char  delim = ',' 
) const
inline

Split delimited string into item list using given tokenizer.

  • This tokenizes and adds each item to list, using convert() for conversion to list item type
  • String must be convertible to list item type via convert()
  • See join() to join list back into string
Template Parameters
TokTokenizer to use, such as StrTok
CList container for items – inferred from items parameter
Parameters
itemsList to add items to [in/out]
delimDelimiter to use

◆ splitat() [1/3]

bool splitat ( Key  index,
T1 &  left,
T2 &  right 
) const

Split into left/right sublists at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1List type to store left sublist
T2List type to store right sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat() [2/3]

bool splitat ( Key  index,
T1 &  left 
) const

Split into left sublist at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1List type to store left sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat() [3/3]

bool splitat ( Key  index,
ValNull  left,
T2 &  right 
) const

Split into right sublist at index.

  • Can use methods like find() or findany() for index
  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T2List type to store right sublist
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftvNULL (ignored)
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat_setl() [1/2]

bool splitat_setl ( Key  index)

Split at index and set as left sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist before index, unchanged if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged)
Returns
Whether successful, false if bad index

◆ splitat_setl() [2/2]

bool splitat_setl ( Key  index,
T2 &  right 
)

Split at index, set as left sublist, and save right sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist before index, unchanged if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end (i.e. unchanged)
rightSet to sublist after index, null if bad index [out]
Returns
Whether successful, false if bad index

◆ splitat_setr() [1/2]

bool splitat_setr ( Key  index)

Split at index and set as right sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist after index, null if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
Returns
Whether successful, false if bad index

◆ splitat_setr() [2/2]

bool splitat_setr ( Key  index,
T1 &  left 
)

Split at index, set as right sublist, and save left sublist.

  • Can use methods like find() or findany() for index
  • Sets this to sublist after index, null if bad index [out]
Parameters
indexIndex to split at, bad index (NONE or out-of-bounds) splits at end
leftSet to sublist before index, set to this if bad index [out]
Returns
Whether successful, false if bad index

◆ splitr() [1/3]

bool splitr ( char  delim,
T1 &  left,
T2 &  right 
) const
inline

Split at last occurrence of delimiter into left/right substrings.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1String type to store left substring
T2String type to store right substring
Parameters
delimDelimiter to find
leftSet to substring before delim, set to this if not found [out]
rightSet to substring after delim, null if not found [out]
Returns
Whether successful, false if delim not found

◆ splitr() [2/3]

bool splitr ( char  delim,
T1 &  left 
) const
inline

Split at last occurrence of delimiter into left substring.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T1String type to store left substring
Parameters
delimDelimiter to find
leftSet to substring before delim, set to this if not found [out]
Returns
Whether successful, false if delim not found

◆ splitr() [3/3]

bool splitr ( char  delim,
ValNull  left,
T2 &  right 
) const
inline

Split at last occurrence of delimiter into right substring.

  • Template types are automatically deduced from arguments
  • For more advanced parsing see StrTok
Template Parameters
T2String type to store right substring
Parameters
delimDelimiter to find
leftvNULL (ignored)
rightSet to substring after delim, null if not found [out]
Returns
Whether successful, false if delim not found

◆ starts() [1/4]

bool starts ( ItemVal  item) const
inlineinherited

Check if this starts with given item.

  • Uses item operator==() for comparisons
Parameters
itemItem to check
Returns
Whether starts with item

◆ starts() [2/4]

bool starts ( const Item items,
Size  size 
) const
inlineinherited

Check if starts with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
sizeSize as item count to check
Returns
Whether starts with items

◆ starts() [3/4]

bool starts ( const ListBaseType items) const
inlineinherited

Check if this starts with given items.

  • Uses item operator==() for comparisons
Parameters
itemsItems to check
Returns
Whether starts with items

◆ starts() [4/4]

bool starts ( const char *  str) const
inline

Check if starts with given terminated string.

Parameters
strString to check for – must be terminated
Returns
Whether starts with string

◆ strip() [1/2]

SubString& strip ( )
inline

Strip left (beginning) and right (ending) whitespace (spaces and tabs).

  • This non-destructively removes whitespace so data isn't modified – see Slicing
  • This doesn't strip newlines – see strip2()
Returns
This

◆ strip() [2/2]

SubString& strip ( char  ch)
inline

Strip left (beginning) and right (ending) occurences of character.

  • This non-destructively removes characters so data isn't modified – see Slicing
Parameters
chCharacter to strip
Returns
This

◆ strip2()

SubString& strip2 ( )
inline

Strip left (beginning) and right (ending) whitespace from string, including newlines.

Returns
This

◆ strip_newlines()

SubString& strip_newlines ( )
inline

Strip left (beginning) and right (ending) newlines from string.

  • This non-destructively removes characters so data isn't modified – see Slicing
  • This removes all beginning and ending newline chars (CR and LF) so this effectively recognizes all the main newlines types, see Newline
Returns
This

◆ stripl() [1/3]

SubString& stripl ( )
inline

Strip left (beginning) whitespace (spaces and tabs).

  • This non-destructively removes whitespace so data isn't modified – see Slicing
  • This doesn't strip newlines – see stripl2()
Returns
This

◆ stripl() [2/3]

SubString& stripl ( char  ch,
Size  max = ALL 
)
inline

Strip left (beginning) occurrences of character.

  • This non-destructively removes characters so data isn't modified – see Slicing
Parameters
chCharacter to strip
maxMax count to strip, ALL for all
Returns
This

◆ stripl() [3/3]

SubString& stripl ( const char *  str,
Size  strsize,
Size  max = ALL 
)
inline

Strip left (beginning) occurrences of string.

  • This non-destructively removes characters so data isn't modified – see Slicing
Parameters
strPointer to string to strip
strsizeString length to strip
maxMax number of occurences to strip, ALL for all
Returns
This

◆ stripl2()

SubString& stripl2 ( )
inline

Strip left (beginning) whitespace from string, including newlines.

Returns
This

◆ stripl_newlines() [1/2]

SubString& stripl_newlines ( )
inline

Strip all left (beginning) newlines from string.

  • This non-destructively removes characters so data isn't modified – see Slicing
  • This removes all beginning newline chars (CR and LF) so this effectively recognizes all the main newlines types, see Newline
Returns
This

◆ stripl_newlines() [2/2]

SubString& stripl_newlines ( Size  max)
inline

Strip left (beginning) newlines from string.

  • This non-destructively removes characters so data isn't modified – see Slicing
  • This recognizes all the main newlines types, see Newline
  • Note that a single newline may be 2 characters, so a max of 1 may remove 2 characters, and so on
Parameters
maxMax number of newlines to strip, ALL for all
Returns
This

◆ stripr() [1/3]

SubString& stripr ( )
inline

Strip right (ending) whitespace (spaces and tabs).

  • This non-destructively removes whitespace so data isn't modified – see Slicing
  • This doesn't strip newlines – see stripr2()
Returns
This

◆ stripr() [2/3]

SubString& stripr ( char  ch,
Size  max = ALL 
)
inline

Strip right (ending) occurences of character.

  • This non-destructively removes characters so data isn't modified – see Slicing
Parameters
chCharacter to strip
maxMax count to strip, ALL for all
Returns
This

◆ stripr() [3/3]

SubString& stripr ( const char *  str,
Size  strsize,
Size  max = ALL 
)
inline

Strip right (ending) occurences of string.

  • This non-destructively removes characters so data isn't modified – see Slicing
Parameters
strPointer to string to strip
strsizeString length to strip
maxMax number of occurences to strip, ALL for all
Returns
This

◆ stripr2()

SubString& stripr2 ( )
inline

Strip right (ending) whitespace (including newlines) from string.

Returns
This

◆ stripr_newlines() [1/2]

SubString& stripr_newlines ( )
inline

Strip all right (ending) newlines from string.

  • This non-destructively removes characters so data isn't modified – see Slicing
  • This removes all ending newline chars (CR and LF) so this effectively recognizes all the main newlines types, see Newline
Returns
This

◆ stripr_newlines() [2/2]

SubString& stripr_newlines ( Size  max)
inline

Strip right (ending) newlines from string.

  • This non-destructively removes characters so data isn't modified – see Slicing
  • This recognizes all the main newlines types, see Newline
Parameters
maxMax number of newlines to strip, ALL for all
Returns
This

◆ swap() [1/2]

void swap ( ThisType list)
inlineinherited

Swap with another sublist.

Parameters
listList to swap with

◆ swap() [2/2]

void swap ( StringBase list)

Swap with another sublist.

Parameters
listList to swap with

◆ token()

bool token ( StringT &  value,
char  delim 
)
inline

Extract next token from string.

  • If delim is found, the token value up to that delim is extracted
  • If delim isn't found, the whole string is extracted
  • The extracted token is removed from this string, including the delim (if found)
  • See also: StrTok (and variants)
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from first parameter
Parameters
valueSet to next token value, or null if none [out]
delimDelimiter to tokenize on
Returns
Whether next token was found, false if current string is empty

◆ token_any()

bool token_any ( StringT &  value,
Char found_delim,
const char *  delims,
Size  count 
)
inline

Extract next token from string using any of given delimiters.

  • If a delim is found, the token value up to that delim is extracted
  • If a delim isn't found, the whole string is extracted
  • The extracted token is removed from this string, including the delim (if found)
  • See also: StrTok (and variants)
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from first parameter
Parameters
valueSet to next token value, or null if none [out]
found_delimSet to delimited found, null if no delim found [out]
delimsDelimiters to search for
countCount of delimiters to search for, must be positive
Returns
Whether next token was found, false if current string is empty

◆ token_line()

bool token_line ( StringT &  line)
inline

Extract next line from string.

  • The extracted line is removed from this string, along with the ending newline
  • This recognizes all the main newlines types, see Newline
  • See also: StrTokLine
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from parameter
Parameters
lineSet to extracted line (newline removed), null if no line extracted
Returns
Whether line extracted, false if this is empty

◆ tokenr()

bool tokenr ( StringT &  value,
char  delim 
)
inline

Extract next token from string in reverse (from end of string).

  • If delim is found, the token value up to that delim is extracted
  • If delim isn't found, the whole string is extracted
  • The extracted token is removed from this string, including the delim (if found)
  • See also: StrTokR (and variants)
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from first parameter
Parameters
valueSet to next token value, or null if none [out]
delimDelimiter to tokenize on
Returns
Whether next token was found, false if current string is empty

◆ tokenr_any()

bool tokenr_any ( StringT &  value,
Char found_delim,
const char *  delims,
Size  count 
)
inline

Extract next token from string in reverse (from end of string) using any of given delimiters.

  • If a delim is found, the token value up to that delim is extracted
  • If a delim isn't found, the whole string is extracted
  • The extracted token is removed from this string, including the delim (if found)
  • See also: StrTokR (and variants)
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from first parameter
Parameters
valueSet to next token value, or null if none [out]
found_delimSet to delimited found, null if no delim found [out]
delimsDelimiters to search for
countCount of delimiters to search for, must be positive
Returns
Whether next token was found, false if current string is empty

◆ tokenr_line()

bool tokenr_line ( StringT &  line)
inline

Extract next line from string in reverse (from end of string).

  • The extracted line is removed from this string, along with the ending newline
  • This recognizes all the main newlines types, see Newline
Template Parameters
StringTOutput string type to store line (String or SubString), inferred from parameter
Parameters
lineSet to extracted line (newline removed), null if no line extracted
Returns
Whether line extracted, false if this is empty

◆ triml()

SubString& triml ( Size  size)
inline

Trim left (beginning) items.

  • This non-destructively trims beginning items
Parameters
sizeTrim size as item count to remove
Returns
This

◆ trimr()

SubString& trimr ( Size  size)
inline

Trim right (ending) items.

  • This non-destructively trims ending items
Parameters
sizeTrim size as item count to remove
Returns
This

◆ truncate()

SubString& truncate ( Size  size)
inline

Truncate to given size.

  • This non-destructively trims ending items
Parameters
sizeSize to truncate to as item count
Returns
This

◆ unshare()

SubString& unshare ( )
inline

Make data unique – no-op.

  • This doesn't support sharing or unique states, so this is always a no-op
  • Referenced data is considered constant and immutable while it's referenced
Returns
This

Member Data Documentation

◆ data_

char * data_
inherited

Data pointer, NULL if null.

◆ size_

StrSizeT size_
inherited

Data size as item count, 0 if empty or null.


The documentation for this struct was generated from the following file: