Пример #1
0
void Workpiece::write(JSON::Sink &sink) const {
  sink.beginDict();

  sink.insertBoolean("automatic", automatic);
  sink.insert("margin", margin);
  if (bounds.isValid()) {
    sink.beginInsert("bounds");
    bounds.write(sink);
  }

  sink.endDict();
}
Пример #2
0
void Option::write(JSON::Sink &sink, bool config, const string &delims) const {
  if (config) {
    string value = toString();

    if (isObscured() && !(flags & OBSCURED_FLAG))
      sink.write(string(value.size(), '*'));
    else writeValue(sink, value, delims);

    return;
  }

  sink.beginDict();

  if (!getHelp().empty()) sink.insert("help", getHelp());

  if (hasValue()) {
    sink.beginInsert("value");
    string value = toString();

    if (isObscured() && !(flags & OBSCURED_FLAG))
      sink.write(string(value.size(), '*'));
    else writeValue(sink, value, delims);
  }

  if (hasDefault()) {
    sink.beginInsert("default");
    writeValue(sink, getDefault(), delims);
  }

  sink.insert("type", getTypeString());
  if (isOptional()) sink.insertBoolean("optional", true);
  if (shortName) sink.insert("short", string(1, shortName));
  if (isSet()) sink.insertBoolean("set", true);
  if (isCommandLine()) sink.insertBoolean("command_line", true);
  if (isDepreciated()) sink.insertBoolean("depreciated", true);
  if (!constraint.isNull()) sink.insert("constraint", constraint->getHelp());

  sink.endDict();
}