Changeset 64226


Ignore:
Timestamp:
Jan 16, 2015, 8:12:51 PM (10 years ago)
Author:
glynn
Message:

Add inter-dependency rules to --interface-description output

Location:
grass/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/gui/xml/grass-interface.dtd

    r64106 r64226  
    153153-->
    154154<!ELEMENT keywords   (#PCDATA)>
     155
     156<!--    option inter-dependency rules
     157-->
     158<!ELEMENT rules   (rule+)>
     159
     160<!--    an option inter-dependency rule
     161-->
     162<!ELEMENT rule   (rule-flag*, rule-option*)>
     163<!ATTLIST rule   type            (exclusive | required | requires | requires-all |
     164                                  excludes | collective) #REQUIRED>
     165
     166<!--    a flag name
     167-->
     168<!ELEMENT rule-flag    EMPTY>
     169<!ATTLIST rule-flag    key       CDATA #REQUIRED>
     170
     171<!--    an option name
     172-->
     173<!ELEMENT rule-option    EMPTY>
     174<!ATTLIST rule-option    key       CDATA #REQUIRED>
  • grass/trunk/lib/gis/parser_dependencies.c

    r63855 r64226  
    409409    return FALSE;
    410410}
     411
     412static const char * const rule_types[] = {
     413    "exclusive",
     414    "required",
     415    "requires",
     416    "requires-all",
     417    "excludes",
     418    "collective"
     419};
     420
     421void G__describe_option_rules_xml(FILE *fp)
     422{
     423    unsigned int i, j;
     424
     425    if (!rules.count)
     426        return;
     427
     428    fprintf(fp, "\t<rules>\n");
     429    for (i = 0; i < rules.count; i++) {
     430        const struct rule *rule = &((const struct rule *) rules.data)[i];
     431        fprintf(fp, "\t\t<rule type=\"%s\">\n", rule_types[rule->type]);
     432        for (j = 0; j < rule->count; j++) {
     433            void *p = rule->opts[j];
     434            if (is_flag(p)) {
     435                const struct Flag *flag = (const struct Flag *) p;
     436                fprintf(fp, "\t\t\t<rule-flag key=\"%c\"/>\n", flag->key);
     437            }
     438            else {
     439                const struct Option *opt = (const struct Option *) p;
     440                fprintf(fp, "\t\t\t<rule-option key=\"%s\"/>\n", opt->key);
     441            }
     442        }
     443        fprintf(fp, "\t\t</rule>\n");
     444    }
     445    fprintf(fp, "\t</rules>\n");
     446}
     447
  • grass/trunk/lib/gis/parser_interface.c

    r63858 r64226  
    353353    fprintf(stdout, "\t</flag>\n");
    354354
     355    G__describe_option_rules_xml(stdout);
     356
    355357    fprintf(stdout, "</task>\n");
    356358}
  • grass/trunk/lib/gis/parser_local_proto.h

    r63209 r64226  
    6060void G__describe_option_rules(void);
    6161int G__has_required_rule(void);
     62void G__describe_option_rules_xml(FILE *);
    6263
    6364#endif
Note: See TracChangeset for help on using the changeset viewer.