void CCPrettyPrinter::visit(const CCArray *p) { _result += "\n"; _result += _indentStr; _result += "<array>\n"; setIndentLevel(_indentLevel+1); CCObject* obj; int i = 0; char buf[50] = {0}; CCARRAY_FOREACH(p, obj) { if (i > 0) { _result += "\n"; } sprintf(buf, "%s%02d: ", _indentStr.c_str(), i); _result += buf; CCPrettyPrinter v(_indentLevel); obj->acceptVisitor(v); _result += v.getResult(); i++; } setIndentLevel(_indentLevel-1); _result += "\n"; _result += _indentStr; _result += "</array>"; }
virtual void visit(const CCArray *p) { cJSON *json = cJSON_CreateArray(); CCObject *obj = NULL; CCARRAY_FOREACH(p, obj){ obj->acceptVisitor(*this); if (m_json) cJSON_AddItemToArray(json, m_json); }