Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save njh/809563 to your computer and use it in GitHub Desktop.
Save njh/809563 to your computer and use it in GitHub Desktop.
Patch to add rasqal_world_get_query_language_description() function to rasqal
diff --git a/src/rasqal.h.in b/src/rasqal.h.in
index 52657ad..8df1027 100644
--- a/src/rasqal.h.in
+++ b/src/rasqal.h.in
@@ -1041,7 +1041,11 @@ rasqal_feature rasqal_feature_from_uri(rasqal_world* world, raptor_uri *uri);
RASQAL_API
int rasqal_feature_value_type(const rasqal_feature feature);
+
RASQAL_API
+const raptor_syntax_description* rasqal_world_get_query_language_description(rasqal_world* world, unsigned int counter);
+
+RASQAL_API RASQAL_DEPRECATED
int rasqal_languages_enumerate(rasqal_world* world, unsigned int counter, const char **name, const char **label, const unsigned char **uri_string);
RASQAL_API
diff --git a/src/rasqal_general.c b/src/rasqal_general.c
index b85fca7..b96d98b 100644
--- a/src/rasqal_general.c
+++ b/src/rasqal_general.c
@@ -462,6 +462,33 @@ rasqal_get_query_language_factory(rasqal_world *world, const char *name,
/**
+ * rasqal_world_get_query_language_description:
+ * @world: world object
+ * @counter: index into the list of query languages
+ *
+ * Get query language descriptive information
+ *
+ * Return value: description or NULL if counter is out of range
+ **/
+const raptor_syntax_description*
+rasqal_world_get_query_language_description(rasqal_world* world,
+ unsigned int counter)
+{
+ rasqal_query_language_factory *factory;
+
+ RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(world, rasqal_world, NULL);
+
+ rasqal_world_open(world);
+
+ factory = raptor_sequence_get_at(world->query_languages, counter);
+ if(!factory)
+ return NULL;
+
+ return &factory->desc;
+}
+
+
+/**
* rasqal_languages_enumerate:
* @world: rasqal_world object
* @counter: index into the list of syntaxes
@@ -469,6 +496,8 @@ rasqal_get_query_language_factory(rasqal_world *world, const char *name,
* @label: pointer to store syntax readable label (or NULL)
* @uri_string: pointer to store syntax URI string (or NULL)
*
+ * @deprecated: Use rasqal_world_get_query_language_description() instead.
+ *
* Get information on query languages.
*
* Return value: non 0 on failure of if counter is out of range
diff --git a/src/rasqal_query.c b/src/rasqal_query.c
index 135e7fd..b1ffa64 100644
--- a/src/rasqal_query.c
+++ b/src/rasqal_query.c
@@ -87,8 +87,8 @@ static int rasqal_query_add_query_result(rasqal_query* query, rasqal_query_resul
*
* A query language can be named or identified by a URI, either
* of which is optional. The default query language will be used
- * if both are NULL. rasqal_languages_enumerate returns
- * information on the known names, labels and URIs.
+ * if both are NULL. rasqal_world_get_query_language_description returns
+ * the description of the known names, labels and URIs.
*
* Return value: a new #rasqal_query object or NULL on failure
*/
diff --git a/utils/roqet.c b/utils/roqet.c
index 20c49c8..2b0b00b 100644
--- a/utils/roqet.c
+++ b/utils/roqet.c
@@ -953,13 +953,12 @@ main(int argc, char *argv[])
program, optarg);
fprintf(stderr, "Valid arguments are:\n");
for(i = 0; 1; i++) {
- const char *help_name;
- const char *help_label;
- if(rasqal_languages_enumerate(world, i,
- &help_name, &help_label, NULL))
+ const raptor_syntax_description* desc;
+ desc = rasqal_world_get_query_language_description(world, i);
+ if(desc == NULL)
break;
- fprintf(stderr, " %-12s for %s\n", help_name, help_label);
+ fprintf(stderr, " %-18s for %s\n", desc->names[0], desc->label);
}
usage = 1;
}
@@ -1146,13 +1145,13 @@ main(int argc, char *argv[])
puts(HELP_TEXT("p", "protocol URI ", "Execute QUERY against a SPARQL protocol service URI"));
puts(HELP_TEXT("i", "input LANGUAGE ", "Set query language name to one of:"));
for(i = 0; 1; i++) {
- const char *help_name;
- const char *help_label;
+ const raptor_syntax_description* desc;
- if(rasqal_languages_enumerate(world, i, &help_name, &help_label, NULL))
- break;
+ desc = rasqal_world_get_query_language_description(world, i);
+ if(!desc)
+ break;
- printf(" %-15s %s", help_name, help_label);
+ printf(" %-15s %s", desc->names[0], desc->label);
if(!i)
puts(" (default)");
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment