Exemplo n.º 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");
}
Exemplo n.º 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");
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
static void XMLCALL expatStartElementHandler(void *userData, const XML_Char *name, const XML_Char **atts)
{
    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;
    std::string& s1 = myUserData->s1;

    XMLAttributes attributes;
    for (const XML_Char**p = atts; *p; p += 2)
    {
        assert(p[0] && p[1]);
        s0 = p[0];
        s1 = p[1];
        attributes.setValue(converter(s0, s0), converter(s1, s1));
    }

    s0 = name;
    handler->startElement(converter(s0, s0), attributes);
}