void Option::writeStrings(JSON::Sink &sink, const string &value, const string &delims) { strings_t l = parseStrings(value, delims); sink.beginList(); for (unsigned i = 0; i < l.size(); i++) sink.append(l[i]); sink.endList(); }
void IPRangeSet::write(JSON::Sink &sink) const { sink.beginList(); for (unsigned i = 0; i < rangeSet.size(); i += 2) if (rangeSet[i] == rangeSet[i + 1]) sink.append(IPAddress(rangeSet[i]).toString()); else sink.append(IPAddress(rangeSet[i]).toString() + "-" + IPAddress(rangeSet[i + 1]).toString()); sink.endList(); }
void Option::writeDoubles(JSON::Sink &sink, const string &value, const string &delims) { doubles_t l = parseDoubles(value, delims); sink.beginList(); for (unsigned i = 0; i < value.size(); i++) { sink.beginAppend(); sink.append(l[i]); } sink.endList(); }
void Option::writeIntegers(JSON::Sink &sink, const string &value, const string &delims) { integers_t l = parseIntegers(value, delims); sink.beginList(); for (unsigned i = 0; i < l.size(); i++) { sink.beginAppend(); if (JSON_MIN_INT < l[i] && l[i] < JSON_MAX_INT) sink.write(l[i]); else sink.write(SSTR("0x" << hex << l[i])); } sink.endList(); }
void ToolPath::write(JSON::Sink &sink) const { Axes lastPos(numeric_limits<double>::infinity()); MoveType type = (MoveType::enum_t)-1; int line = -1; int tool = -1; double feed = -1; double speed = -1; sink.beginList(); for (unsigned i = 0; i < size(); i++) { const Move &move = at(i); sink.appendDict(true); // Axes for (unsigned j = 0; j < 9; j++) if (move.getEnd()[j] != lastPos[j]) sink.insert(string(1, Axes::toAxis(j)), lastPos[j] = move.getEnd()[j]); // Type if (type != move.getType()) sink.insert("type", (type = move.getType()).toString()); // Line number if (line != (int)move.getLine()) sink.insert("line", line = move.getLine()); // Tool if (tool != (int)move.getTool()) sink.insert("tool", tool = move.getTool()); // Feed if (feed != move.getFeed()) sink.insert("feed", feed = move.getFeed()); // Speed if (speed != move.getSpeed()) sink.insert("speed", speed = move.getSpeed()); sink.endDict(); } sink.endList(); }