Go to the documentation of this file. 27 #define LESSsa(i,j) (sortFCmp(&arr[i], &arr[j], compareFunction)) 28 #define SWAPsa(i,j) tmp = arr[i], arr[i] = arr[j], arr[j] = tmp 31 #include "recycleContainers.h" 33 #endif // recycleContainers 35 #define walkJsonPath(getSmallObj, arrayCode, dictCode, returnFail, directHit, keyErrorReturn)\ 37 if (!key) {keyErrorReturn;}\ 39 jsonPathRest keyType = keyIsSmallJson(self, key);\ 40 if (keyType == NOT_A_PATH) {\ 45 sDictt **d = &(self->top);\ 46 sArrayt **a = &(self->topA);\ 52 for(size_t i = 0 ; key[i] ; i++) {\ 59 const char *next = findS((key+i+1), "]");\ 61 size_t keyLen = (size_t)(next - (key+i+1));\ 62 char *keyInPath = sliceS((key+i+1), 0, (int64_t)keyLen);\ 68 if ((*a)->type != ARRAY) {free(keyInPath);keyErrorReturn;}\ 72 if (!*a) {free(keyInPath);keyErrorReturn;}\ 74 int64_t idx = parseInt(keyInPath);\ 76 int64_t len = (*a)->count;\ 77 if (idx >= len) {free(keyInPath);keyErrorReturn;}\ 78 if (idx < -len) {free(keyInPath);keyErrorReturn;}\ 79 if (idx < 0) {idx = len + idx;}\ 86 oo = sArrayGetP(*a, (uint32_t)idx);\ 97 const char *next = key+i;\ 98 size_t keyLen = i - keyIdx;\ 99 char *keyInPath = sliceS((key+keyIdx), 0, (int64_t)keyLen);\ 105 if ((*d)->type != DICT) {free(keyInPath);keyErrorReturn;}\ 108 unescapeKey(keyInPath, keyInPath, keyLen);\ 115 oo = sDictGetP(*d, keyInPath);\ 125 if (key[i] == '\\' && status == 1) escape = true;\ 127 UNIQVAR(walkEnd): UNUSED 134 walkJsonPath(if (!oo) {free(keyInPath); if(isNew){free(o);} return NULL;}, sArraySetTiny(*a, (uint32_t)idx, o), sDictSetTiny(d, keyInPath, o), , sDictSetTiny(&(self->top), key, o); return self, if(isNew){free(o);} return NULL) 138 #define setJsonPathsFree\ 139 walkJsonPath(if (!oo) {free(keyInPath); if(isNew){sFree(o);} return NULL;}, sArraySetTiny(*a, (uint32_t)idx, o), sDictSetTiny(d, keyInPath, o), , sDictSetTiny(&(self->top), key, o); return self, if(isNew){sFree(o);} return NULL) 141 #define setJsonPathWithoutReturn\ 142 walkJsonPath(if (!oo) {free(keyInPath);if(isNew){free(o);}return NULL;}, sArraySetTiny(*a, (uint32_t)idx, o), sDictSetTiny(d, keyInPath, o), , sDictSetTiny(&(self->top), key, o); goto UNIQVAR(walkEnd), if(isNew){free(o);}return NULL) 144 #define setPJsonPath(objP)\ 145 walkJsonPath(if (!oo) {free(keyInPath);return NULL;}, sArraySetP(*a, (uint32_t)idx, objP), sDictSetP(d, keyInPath, objP), , sDictSetP(&(self->top), key, objP); return self, return NULL) 147 #define setPNFreeJsonPath(objP, finishArg)\ 148 walkJsonPath(if (!oo) {free(keyInPath);return NULL;}, sArraySetP(*a, (uint32_t)idx, objP), sDictSetP(d, keyInPath, objP), , sDictSetP(&(self->top), key, objP); finishArg ; return self, return NULL) 153 walkJsonPath(if (!oo) {free(keyInPath);goto fail;} o = *oo, if (!*a) {free(keyInPath);goto fail;} o = sArrayGetTiny(*a, (uint32_t)idx), if (!*d) {free(keyInPath);goto fail;} o = sDictGetTiny(*d, keyInPath), if (!self->top) goto fail, o = sDictGetTiny(self->top, key); goto pass, goto fail) 156 walkJsonPath(if (!oo) {free(keyInPath);return NULL;}, if (!*a) {free(keyInPath);return NULL;} sArrayDelTiny(*a, (uint32_t)idx), if (!*d) {free(keyInPath);return NULL;} sDictDelTiny(*d, keyInPath), if (!self->top) return NULL, sDictDelTiny(self->top, key) ; return self, return NULL) 158 #define removeJsonPath\ 159 walkJsonPath(if (!oo) {free(keyInPath);return NULL;}, if (!*a) {free(keyInPath);return NULL;} sArraySetShortTiny(*a, (uint32_t)idx, NULL), if (!*d) {free(keyInPath);return NULL;} forEachSDict(*d, e) {if (e->key && eqS(keyInPath, e->key)) { free(e->key); e->key = NULL; break;} }, if (!self->top) return NULL, forEachSDict(self->top, e) {if (e->key && eqS(key, e->key)) { free(e->key); e->key = NULL; break;} } ; return self, return NULL) 161 #define typeStringJsonPath\ 162 walkJsonPath(if (!oo) {free(keyInPath);return NULL;}, if (!*a) {free(keyInPath);return NULL;} o = sArrayGetTiny(*a, (uint32_t)idx), if (!*d) {free(keyInPath);return NULL;} o = sDictGetTiny(*d, keyInPath), if (!self->top) return NULL, o = sDictGet(self->top, key) ; if (!o) return NULL; return SMALL_TYPE_NAMES[(size_t)o->type], return NULL) 164 #define typeJsonPath\ 165 walkJsonPath(if (!oo) {free(keyInPath);return 0;}, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, (uint32_t)idx), if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath), if (!self->top) return 0, o = sDictGet(self->top, key) ; if (!o) return 0; return o->type, return 0) 167 #define isEJsonPath(test)\ 168 walkJsonPath(if (!oo) {free(keyInPath);return 0;}, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, (uint32_t)idx), if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath), if (!self->top) return 0, o = sDictGet(self->top, key) ; if (!o) return false; return test, return 0) 170 #define mainSetJsonPathWithoutReturn(initValue, allocValue, subSetJsonPath) \ 174 jsonPathRest kType = keyIsSmallJson(self, key);\ 175 if (self->topIsA != SMALLJSON_IS_EMPTY && ((kType == ARRAY_PATH && self->topIsA != TOP_IS_ARRAY) || ((kType == NOT_A_PATH || kType == DICT_PATH) && self->topIsA != TOP_IS_DICT)))\ 178 switch(self->topIsA) {\ 179 case SMALLJSON_IS_EMPTY:\ 180 if (kType == NOT_A_PATH || kType == DICT_PATH)\ 181 self->topIsA = TOP_IS_DICT;\ 182 else if (kType == ARRAY_PATH)\ 183 self->topIsA = TOP_IS_ARRAY;\ 188 bool isNew UNUSED = false;\ 196 #define mainSetJsonPath(initValue, allocValue, subSetJsonPath) \ 197 mainSetJsonPathWithoutReturn(initValue, allocValue, subSetJsonPath)\