[GRASS-SVN] r64226 - in grass/trunk: gui/xml lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 16 20:12:51 PST 2015


Author: glynn
Date: 2015-01-16 20:12:51 -0800 (Fri, 16 Jan 2015)
New Revision: 64226

Modified:
   grass/trunk/gui/xml/grass-interface.dtd
   grass/trunk/lib/gis/parser_dependencies.c
   grass/trunk/lib/gis/parser_interface.c
   grass/trunk/lib/gis/parser_local_proto.h
Log:
Add inter-dependency rules to --interface-description output


Modified: grass/trunk/gui/xml/grass-interface.dtd
===================================================================
--- grass/trunk/gui/xml/grass-interface.dtd	2015-01-16 13:45:34 UTC (rev 64225)
+++ grass/trunk/gui/xml/grass-interface.dtd	2015-01-17 04:12:51 UTC (rev 64226)
@@ -152,3 +152,23 @@
 <!--	list of keywords that describes a task
 -->
 <!ELEMENT keywords   (#PCDATA)>
+
+<!--	option inter-dependency rules
+-->
+<!ELEMENT rules   (rule+)>
+
+<!--	an option inter-dependency rule
+-->
+<!ELEMENT rule   (rule-flag*, rule-option*)>
+<!ATTLIST rule   type            (exclusive | required | requires | requires-all |
+                                  excludes | collective) #REQUIRED>
+
+<!--	a flag name
+-->
+<!ELEMENT rule-flag    EMPTY>
+<!ATTLIST rule-flag    key       CDATA #REQUIRED>
+
+<!--	an option name
+-->
+<!ELEMENT rule-option    EMPTY>
+<!ATTLIST rule-option    key       CDATA #REQUIRED>

Modified: grass/trunk/lib/gis/parser_dependencies.c
===================================================================
--- grass/trunk/lib/gis/parser_dependencies.c	2015-01-16 13:45:34 UTC (rev 64225)
+++ grass/trunk/lib/gis/parser_dependencies.c	2015-01-17 04:12:51 UTC (rev 64226)
@@ -408,3 +408,40 @@
     }
     return FALSE;
 }
+
+static const char * const rule_types[] = {
+    "exclusive",
+    "required",
+    "requires",
+    "requires-all",
+    "excludes",
+    "collective"
+};
+
+void G__describe_option_rules_xml(FILE *fp)
+{
+    unsigned int i, j;
+
+    if (!rules.count)
+	return;
+
+    fprintf(fp, "\t<rules>\n");
+    for (i = 0; i < rules.count; i++) {
+	const struct rule *rule = &((const struct rule *) rules.data)[i];
+	fprintf(fp, "\t\t<rule type=\"%s\">\n", rule_types[rule->type]);
+	for (j = 0; j < rule->count; j++) {
+	    void *p = rule->opts[j];
+	    if (is_flag(p)) {
+		const struct Flag *flag = (const struct Flag *) p;
+		fprintf(fp, "\t\t\t<rule-flag key=\"%c\"/>\n", flag->key);
+	    }
+	    else {
+		const struct Option *opt = (const struct Option *) p;
+		fprintf(fp, "\t\t\t<rule-option key=\"%s\"/>\n", opt->key);
+	    }
+	}
+	fprintf(fp, "\t\t</rule>\n");
+    }
+    fprintf(fp, "\t</rules>\n");
+}
+

Modified: grass/trunk/lib/gis/parser_interface.c
===================================================================
--- grass/trunk/lib/gis/parser_interface.c	2015-01-16 13:45:34 UTC (rev 64225)
+++ grass/trunk/lib/gis/parser_interface.c	2015-01-17 04:12:51 UTC (rev 64226)
@@ -352,5 +352,7 @@
     fprintf(stdout, "\n\t\t</description>\n");
     fprintf(stdout, "\t</flag>\n");
 
+    G__describe_option_rules_xml(stdout);
+
     fprintf(stdout, "</task>\n");
 }

Modified: grass/trunk/lib/gis/parser_local_proto.h
===================================================================
--- grass/trunk/lib/gis/parser_local_proto.h	2015-01-16 13:45:34 UTC (rev 64225)
+++ grass/trunk/lib/gis/parser_local_proto.h	2015-01-17 04:12:51 UTC (rev 64226)
@@ -59,6 +59,7 @@
 void G__check_option_rules(void);
 void G__describe_option_rules(void);
 int G__has_required_rule(void);
+void G__describe_option_rules_xml(FILE *);
 
 #endif
 



More information about the grass-commit mailing list