MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / parse_array

Function parse_array

outofcore/src/cJSON.cpp:315–340  ·  view source on GitHub ↗

Build an array from input text. */

Source from the content-addressed store, hash-verified

313
314/* Build an array from input text. */
315static const char *parse_array(cJSON *item,const char *value)
316{
317 cJSON *child;
318 if (*value!='[') {ep=value;return nullptr;} /* not an array! */
319
320 item->type=cJSON_Array;
321 value=skip(value+1);
322 if (*value==']') return value+1; /* empty array. */
323
324 item->child=child=cJSON_New_Item();
325 if (!item->child) return nullptr; /* memory fail */
326 value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
327 if (!value) return nullptr;
328
329 while (*value==',')
330 {
331 cJSON *new_item;
332 if (!(new_item=cJSON_New_Item())) return nullptr; /* memory fail */
333 child->next=new_item;new_item->prev=child;child=new_item;
334 value=skip(parse_value(child,skip(value+1)));
335 if (!value) return nullptr; /* memory fail */
336 }
337
338 if (*value==']') return value+1; /* end of array */
339 ep=value;return nullptr; /* malformed. */
340}
341
342/* Render an array to text */
343static char *print_array(cJSON *item,int depth,int fmt)

Callers 1

parse_valueFunction · 0.85

Calls 3

skipFunction · 0.85
cJSON_New_ItemFunction · 0.85
parse_valueFunction · 0.85

Tested by

no test coverage detected