bool Parser::readNodeDef(const std::string &str) { return readDef(str, toNodeAttribute, na_unknown, m_nodeAttrs); }
bool Parser::readEdgeDef(const std::string &str) { return readDef(str, toEdgeAttribute, ea_unknown, m_edgeAttrs); }
void JsonSchema::readJson() { if (! m_cjson) return; cJSON *jsonId = cJSON_GetObjectItem(m_cjson, "id"); if (jsonId) { m_id = jsonId->valuestring; } cJSON *jsonSchema = cJSON_GetObjectItem(m_cjson, "$schema"); if (jsonSchema) { m_schema = jsonSchema->valuestring; } cJSON *jsonTitle = cJSON_GetObjectItem(m_cjson, "title"); if (jsonTitle) { m_title = jsonTitle->valuestring; } cJSON *jsonType = cJSON_GetObjectItem(m_cjson, "type"); if (jsonType) { m_type = jsonType->valuestring; } cJSON *jsonDescription = cJSON_GetObjectItem(m_cjson, "description"); if (jsonDescription) { m_description = jsonDescription->valuestring; } cJSON *jsonDefinitions = cJSON_GetObjectItem(m_cjson, "definitions"); if (jsonDefinitions) { cJSON *childDefinitions = jsonDefinitions->child; while (childDefinitions) { std::string defName = childDefinitions->string; addDefinition(defName, readDef(childDefinitions, defName)); childDefinitions = childDefinitions->next; } } cJSON *jsonProperties = cJSON_GetObjectItem(m_cjson, "properties"); if (jsonProperties) { cJSON *childProperties = jsonProperties->child; while (childProperties) { std::string attName = childProperties->string; addProperty(attName, readProp(childProperties, attName)); childProperties = childProperties->next; } } if (m_type == "array") { cJSON *jsonItems = cJSON_GetObjectItem(m_cjson, "items"); if (jsonItems) { if (jsonItems->type == 5) { int item_size = cJSON_GetArraySize(jsonItems); int item_index = 0; do { cJSON *item = cJSON_GetArrayItem(jsonItems, item_index); setItem(readItems(item)); } while ( ++item_index < item_size); } else { setItem(readItems(jsonItems)); } } } cJSON *jsonAdditionalProperties = cJSON_GetObjectItem(m_cjson, "additionalProperties"); if (jsonAdditionalProperties) m_additionalProperties = jsonAdditionalProperties->type; else m_additionalProperties = cJSON_True; cJSON *jsonReference = cJSON_GetObjectItem(m_cjson, "$ref"); if (jsonReference) { readJsonRef(jsonReference); } cJSON *jsonAllOf = cJSON_GetObjectItem(m_cjson, "allOf"); if (jsonAllOf) { readAllOf(jsonAllOf); } cJSON *jsonRequiredValues = cJSON_GetObjectItem(m_cjson, "required"); if (jsonRequiredValues) { int size = cJSON_GetArraySize(jsonRequiredValues); int index = 0; do { setRequiredValue(cJSON_GetArrayItem(jsonRequiredValues, index)->valuestring); } while ( ++index < size); } }