bool TouchGrabber::save(const std::string &filename) { CSJson::Value root; CSJson::StyledStreamWriter writer; /// Use default indent char (tab) for (const TouchRecord &raw : mTouchesRecVector) { CSJson::Value value; value["x"] = raw.x; value["y"] = raw.y; value["time"] = raw.time; value["event"] = raw.event; /// CCLOG("%s %f:%f %f",raw.event.c_str(),raw.x,raw.y,raw.time); /// Append to the array root.append(value); } std::ofstream out(CCFileUtils::sharedFileUtils()->getWritablePath().append(filename).c_str(), std::ofstream::out); writer.write(out, root); out.close(); return true; }
std::ostream& operator<<( std::ostream &sout, const Value &root ) { CSJson::StyledStreamWriter writer; writer.write(sout, root); return sout; }