Example #1
0
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;
}
Example #2
0
std::ostream& operator<<( std::ostream &sout, const Value &root )
{
   CSJson::StyledStreamWriter writer;
   writer.write(sout, root);
   return sout;
}