Ejemplo n.º 1
0
void Option::print(raw_ostream &O) const {
  O << "<";
  switch (getKind()) {
#define P(N) case N: O << #N; break
    P(GroupClass);
    P(InputClass);
    P(UnknownClass);
    P(FlagClass);
    P(JoinedClass);
    P(ValuesClass);
    P(SeparateClass);
    P(CommaJoinedClass);
    P(MultiArgClass);
    P(JoinedOrSeparateClass);
    P(JoinedAndSeparateClass);
    P(RemainingArgsClass);
    P(RemainingArgsJoinedClass);
#undef P
  }

  if (Info->Prefixes) {
    O << " Prefixes:[";
    for (const char *const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
      O << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
    }
    O << ']';
  }

  O << " Name:\"" << getName() << '"';

  const Option Group = getGroup();
  if (Group.isValid()) {
    O << " Group:";
    Group.print(O);
  }

  const Option Alias = getAlias();
  if (Alias.isValid()) {
    O << " Alias:";
    Alias.print(O);
  }

  if (getKind() == MultiArgClass)
    O << " NumArgs:" << getNumArgs();

  O << ">\n";
}
Ejemplo n.º 2
0
void OptionParser::print() const {
   
   vector<string> printed;

    OptionMap::const_iterator i = optionMap.begin();
   cout << "Printing Options" << endl;
   while(i != optionMap.end()) {
      Option o = i->second;
      bool skip = false;
      for (int j=0; j<printed.size(); j++) {
         if (printed[j] == o.longName) skip = true;
      }
      if (!skip) {
        printed.push_back(o.longName);
        o.print();
        i++;
        cout << "---------------------" << endl;
      } else { i++; }
   }

}