Beispiel #1
0
void Option::printHelpTOC(XMLHandler &handler, const string &prefix) const {
  handler.startElement("li");

  XMLAttributes attrs;
  attrs["href"] = "#" + prefix + "option-" + getName();
  handler.startElement("a", attrs);
  handler.text(getName());
  handler.endElement("a");

  handler.endElement("li");
}
Beispiel #2
0
void Option::printHelp(XMLHandler &handler, const string &prefix) const {
  XMLAttributes attrs;

  attrs["class"] = "option";
  attrs["id"] = prefix + "option-" + getName();
  handler.startElement("div", attrs);

  // Name
  attrs.clear();
  attrs["class"] = "name";
  handler.startElement("span", attrs);
  handler.text(getName());
  handler.endElement("span");

  // Type
  attrs["class"] = "type";
  handler.startElement("span", attrs);
  handler.text(isOptional() ? "[" : "<");
  handler.text(getTypeString());

  // Default
  if (hasDefault()) {
    handler.text(" = ");

    bool isString = type == STRING_TYPE || type == STRINGS_TYPE;

    attrs["class"] = "default";
    handler.startElement("span", attrs);
    handler.text((isString ? "\"" : "") + getDefault() +
                 (isString ? "\"" : ""));
    handler.endElement("span");
  }

  handler.text(isOptional() ? "]" : ">");
  handler.endElement("span");

  // Help
  if (getHelp() != "") {
    attrs["class"] = "help";
    handler.startElement("div", attrs);
    string help = getHelp();
    vector<string> tokens;
    String::tokenize(help, tokens, "\t");
    handler.text(String::join(tokens, "  "));
    handler.text(" ");
    handler.endElement("div");
  }


  handler.endElement("div");
}
//-----------------------------------------------------------------------
static void XMLCALL expatEndElementHandler(void *userData, const XML_Char *name)
{
    MyUserData* myUserData = static_cast<MyUserData*>(userData);
    assert(myUserData);
    XMLHandler* handler = myUserData->handler;
    const UTFConverter& converter = myUserData->converter;
    assert(handler);
    assert(converter);
    std::string& s0 = myUserData->s0;

    s0 = name;
    handler->endElement(converter(s0, s0));
}
Beispiel #4
0
void Option::write(XMLHandler &handler, uint32_t flags) const {
  XMLAttributes attrs;

  string value = toString();
  if (isObscured() && !(flags & OBSCURED_FLAG))
    value = string(value.size(), '*');

  if (!isPlural()) attrs["v"] = value;

  handler.startElement(name, attrs);

  if (isPlural()) handler.text(value);

  handler.endElement(name);
}