40 #ifndef OSSIM_CSLT_HONOURSTRINGS 41 # define OSSIM_CSLT_HONOURSTRINGS 0x0001 43 #ifndef OSSIM_CSLT_ALLOWEMPTYTOKENS 44 # define OSSIM_CSLT_ALLOWEMPTYTOKENS 0x0002 46 #ifndef OSSIM_CSLT_PRESERVEQUOTES 47 # define OSSIM_CSLT_PRESERVEQUOTES 0x0004 49 #ifndef OSSIM_CSLT_PRESERVEESCAPES 50 # define OSSIM_CSLT_PRESERVEESCAPES 0x0008 66 if( papszList == NULL )
69 for( i = 0; papszList[i] != NULL; i++ )
98 const char * pszDelimiters,
100 int bAllowEmptyTokens )
107 if( bAllowEmptyTokens )
120 const char * pszDelimiters,
124 char **papszRetList = NULL;
125 int nRetMax = 0, nRetLen = 0;
127 int nTokenMax, nTokenLen;
131 pszToken = (
char *) calloc(10,1);
134 while( pszString != NULL && *pszString !=
'\0' )
136 int bInString =
false;
141 for( ; *pszString !=
'\0'; pszString++ )
145 if( !bInString && strchr(pszDelimiters, *pszString) != NULL )
154 if( bHonourStrings && *pszString ==
'"' )
158 pszToken[nTokenLen] = *pszString;
176 if( bInString && pszString[0] ==
'\\' && pszString[1] ==
'"' )
180 pszToken[nTokenLen] = *pszString;
189 && pszString[0] ==
'\\' && pszString[1] ==
'\\' )
193 pszToken[nTokenLen] = *pszString;
199 if( nTokenLen >= nTokenMax-3 )
201 nTokenMax = nTokenMax * 2 + 10;
205 pszToken[nTokenLen] = *pszString;
209 pszToken[nTokenLen] =
'\0';
216 if( (pszToken[0] !=
'\0' || bAllowEmptyTokens)
217 || (*pszString ==
'\0' && bAllowEmptyTokens
218 && strchr(pszDelimiters, *(pszString-1)) ) )
220 if( nRetLen >= nRetMax - 1 )
222 nRetMax = nRetMax * 2 + 10;
223 papszRetList = (
char **)
227 papszRetList[nRetLen++] = strdup( pszToken );
228 papszRetList[nRetLen] = NULL;
232 if( papszRetList == NULL )
233 papszRetList = (
char **) calloc(
sizeof(
char *),1);
251 while(*papszStrList != NULL)
272 papszPtr = papszStrList;
273 while(*papszPtr != NULL)
295 pReturn = malloc( nNewSize );
297 pReturn = realloc( pData, nNewSize );
#define OSSIM_CSLT_PRESERVEQUOTES
int ossimCSLCount(char **papszStrList)
#define OSSIM_CSLT_PRESERVEESCAPES
char ** ossimCSLTokenizeStringComplex(const char *pszString, const char *pszDelimiters, int bHonourStrings, int bAllowEmptyTokens)
#define OSSIM_CSLT_HONOURSTRINGS
#define OSSIM_CSLT_ALLOWEMPTYTOKENS
void * ossimCPLRealloc(void *pData, size_t nNewSize)
int ossimCSLFindString(char **papszList, const char *pszTarget)
char ** ossimCSLTokenizeString2(const char *pszString, const char *pszDelimiters, int nCSLTFlags)
char ** ossimCSLTokenizeString(const char *pszString)
void ossimCSLDestroy(char **papszStrList)