9b13731e6e466aa0f781179da2d504db2f4c15a9 tdreszer Wed Mar 30 11:28:34 2011 -0700 Made slPairListFromString and slPairListToString optionally handle double quotes. Finally made mdbObjReorderByCv so that priority in cv.ra typeOfTerms is used. diff --git src/inc/common.h src/inc/common.h index f2f7b17..41e03c5 100644 --- src/inc/common.h +++ src/inc/common.h @@ -635,62 +635,72 @@ void slPairFreeList(struct slPair **pList); /* Free up list. (Don't free up values.) */ void slPairFreeVals(struct slPair *list); /* Free up all values on list. */ void slPairFreeValsAndList(struct slPair **pList); /* Free up all values on list and list itself */ struct slPair *slPairFind(struct slPair *list, char *name); /* Return list element of given name, or NULL if not found. */ void *slPairFindVal(struct slPair *list, char *name); /* Return value associated with name in list, or NULL if not found. */ -struct slPair *slPairFromString(char *s); -/* Return slPair list parsed from list in string s - * name1=val1 name2=val2 ... - * Returns NULL if parse error. Free this up with - * slPairFreeValsAndList. */ +struct slPair *slPairListFromString(char *str,boolean respectQuotes); +// Return slPair list parsed from list in string like: [name1=val1 name2=val2 ...] +// if respectQuotes then string can have double quotes: [name1="val 1" "name 2"=val2 ...] +// resulting pair strips quotes: {name1}={val 1},{name 2}={val2} +// Returns NULL if parse error. Free this up with slPairFreeValsAndList. +#define slPairFromString(s) slPairListFromString(s,FALSE) -char *slPairListToString(struct slPair *list); -// Returns an allocated string of pairs in form of -// name1=val1 name2=val2 ... -// Will wrap vals in quotes if contain spaces: name3="val 3" +char *slPairListToString(struct slPair *list,boolean quoteIfSpaces); +// Returns an allocated string of pairs in form of [name1=val1 name2=val2 ...] +// If requested, will wrap name or val in quotes if contain spaces: [name1="val 1" "name 2"=val2] + +char *slPairNameToString(struct slPair *list, char delimiter,boolean quoteIfSpaces); +// Return string created by joining all names (ignoring vals) with the delimiter. +// If requested, will wrap name in quotes if contain spaces: [name1,"name 2" ...] int slPairCmpCase(const void *va, const void *vb); /* Compare two slPairs, ignore case. */ void slPairSortCase(struct slPair **pList); /* Sort slPair list, ignore case. */ int slPairCmp(const void *va, const void *vb); /* Compare two slPairs. */ int slPairValCmpCase(const void *va, const void *vb); /* Case insensitive compare two slPairs on their values (must be string). */ int slPairValCmp(const void *va, const void *vb); /* Compare two slPairs on their values (must be string). */ void slPairValSortCase(struct slPair **pList); /* Sort slPair list on values (must be string), ignore case. */ void slPairValSort(struct slPair **pList); /* Sort slPair list on values (must be string). */ +int slPairIntCmp(const void *va, const void *vb); +// Compare two slPairs on their integer values. + +void slPairIntSort(struct slPair **pList); +// Sort slPair list on integer values. + void gentleFree(void *pt); /* check pointer for NULL before freeing. * (Actually plain old freeMem does that these days.) */ /******* Some stuff for processing strings. *******/ char *cloneStringZ(const char *s, int size); /* Make a zero terminated copy of string in memory */ char *cloneString(const char *s); /* Make copy of string in dynamic memory */ char *cloneLongString(char *s); /* Make clone of long string. */