MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / decode_patch_operation

Function decode_patch_operation

cJSON_Utils.c:742–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740enum patch_operation { INVALID, ADD, REMOVE, REPLACE, MOVE, COPY, TEST };
741
742static enum patch_operation decode_patch_operation(const cJSON * const patch, const cJSON_bool case_sensitive)
743{
744 cJSON *operation = get_object_item(patch, "op", case_sensitive);
745 if (!cJSON_IsString(operation))
746 {
747 return INVALID;
748 }
749
750 if (strcmp(operation->valuestring, "add") == 0)
751 {
752 return ADD;
753 }
754
755 if (strcmp(operation->valuestring, "remove") == 0)
756 {
757 return REMOVE;
758 }
759
760 if (strcmp(operation->valuestring, "replace") == 0)
761 {
762 return REPLACE;
763 }
764
765 if (strcmp(operation->valuestring, "move") == 0)
766 {
767 return MOVE;
768 }
769
770 if (strcmp(operation->valuestring, "copy") == 0)
771 {
772 return COPY;
773 }
774
775 if (strcmp(operation->valuestring, "test") == 0)
776 {
777 return TEST;
778 }
779
780 return INVALID;
781}
782
783/* overwrite and existing item with another one and free resources on the way */
784static void overwrite_item(cJSON * const root, const cJSON replacement)

Callers 1

apply_patchFunction · 0.85

Calls 2

cJSON_IsStringFunction · 0.85
get_object_itemFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…