ZFFramework
 
Loading...
Searching...
No Matches
ZFCoreDataPairSplit.h File Reference

util to split data pairs from a string More...

#include "ZFCoreArray.h"
#include "ZFCoreStringUtil.h"

Go to the source code of this file.

Functions

zfbool ZFCoreDataPairSplitString (ZFCoreArray< ZFIndexRange > &outData, zfindex desiredCountOrIndexMax, const zfchar *src, zfindex srcLen=((zfindex) -1), const zfchar *separatorTokens=",", const zfchar *leftTokens="(", const zfchar *rightTokens=")", zfbool allowEmptyItem=_ZFT_t_zffalse)
 split data pair such as "(a, b, c)" from a string
 
template<typename T_int>
zfbool ZFCoreDataPairSplitInt (ZFCoreArray< T_int > &outData, zfindex desiredCountOrIndexMax, const zfchar *src, zfindex srcLen=((zfindex) -1), const zfchar *separatorTokens=",", const zfchar *leftTokens="(", const zfchar *rightTokens=")", zfbool allowEmptyItem=_ZFT_t_zffalse)
 split data to int array format, see ZFCoreDataPairSplitString
 
template<typename T_float>
zfbool ZFCoreDataPairSplitFloat (ZFCoreArray< T_float > &outData, zfindex desiredCountOrIndexMax, const zfchar *src, zfindex srcLen=((zfindex) -1), const zfchar *separatorTokens=",", const zfchar *leftTokens="(", const zfchar *rightTokens=")", zfbool allowEmptyItem=_ZFT_t_zffalse)
 split data to float array format, see ZFCoreDataPairSplitString
 

Detailed Description

util to split data pairs from a string

Function Documentation

◆ ZFCoreDataPairSplitString()

zfbool ZFCoreDataPairSplitString ( ZFCoreArray< ZFIndexRange > & outData,
zfindex desiredCountOrIndexMax,
const zfchar * src,
zfindex srcLen = ((zfindex) -1),
const zfchar * separatorTokens = ",",
const zfchar * leftTokens = "(",
const zfchar * rightTokens = ")",
zfbool allowEmptyItem = _ZFT_t_zffalse )
extern

split data pair such as "(a, b, c)" from a string

return splited sub-string's index range
spaces and tabs would be ignored between elements and tokens, spaces and tabs in elements would be reserved
only all format matched would result success, missing or extra tokens would result fail
embeded data pair is allowed, such as "(a, (b, c), d)" can be splited to "a", "(b, c)", "d"

leftToken or rightToken can be disabled by setting to zfnull
if leftToken has been set, then rightToken must also be set with same order
if rightToken not set, src can only be stopped by reach end