Lines Matching refs:pointer
120 static cJSON_bool compare_pointers(const unsigned char *name, const unsigned char *pointer, const cJSON_bool case_sensitive)
122 if ((name == NULL) || (pointer == NULL))
127 for (; (*name != '\0') && (*pointer != '\0') && (*pointer != '/'); (void)name++, pointer++) /* compare until next '/' */
129 if (*pointer == '~')
132 if (((pointer[1] != '0') || (*name != '~')) && ((pointer[1] != '1') || (*name != '/')))
139 pointer++;
142 else if ((!case_sensitive && (tolower(*name) != tolower(*pointer))) || (case_sensitive && (*name != *pointer)))
147 if (((*pointer != 0) && (*pointer != '/')) != (*name != 0))
156 /* calculate the length of a string if encoded as JSON pointer with ~0 and ~1 escape sequences */
172 /* copy a string while escaping '~' and '/' with ~0 and ~1 JSON pointer escape codes */
274 static cJSON_bool decode_array_index_from_pointer(const unsigned char * const pointer, size_t * const index)
279 if ((pointer[0] == '0') && ((pointer[1] != '\0') && (pointer[1] != '/')))
285 for (position = 0; (pointer[position] >= '0') && (pointer[0] <= '9'); position++)
287 parsed_index = (10 * parsed_index) + (size_t)(pointer[position] - '0');
291 if ((pointer[position] != '\0') && (pointer[position] != '/'))
301 static cJSON *get_item_from_pointer(cJSON * const object, const char * pointer, const cJSON_bool case_sensitive)
305 if (pointer == NULL)
310 /* follow path of the pointer */
311 while ((pointer[0] == '/') && (current_element != NULL))
313 pointer++;
317 if (!decode_array_index_from_pointer((const unsigned char*)pointer, &index))
328 while ((current_element != NULL) && !compare_pointers((unsigned char*)current_element->string, (const unsigned char*)pointer, case_sensitive))
339 while ((pointer[0] != '\0') && (pointer[0] != '/'))
341 pointer++;
348 CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointer(cJSON * const object, const char *pointer)
350 return get_item_from_pointer(object, pointer, false);
353 CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointerCaseSensitive(cJSON * const object, const char *pointer)
355 return get_item_from_pointer(object, pointer, true);
509 /* reset pointer to the beginning */
978 /* split pointer in parent and child */