comparison rdf/generator/template-generator.cpp @ 217:f9b4f60280db

* improve usage printout & command line parsing a bit
author cannam
date Wed, 29 Oct 2008 15:03:32 +0000
parents 27cfae2a4155
children 81ffb843c8cc
comparison
equal deleted inserted replaced
216:991d2ae87980 217:f9b4f60280db
24 using std::ios; 24 using std::ios;
25 25
26 using Vamp::HostExt::PluginLoader; 26 using Vamp::HostExt::PluginLoader;
27 using Vamp::Plugin; 27 using Vamp::Plugin;
28 28
29 //???
29 string programURI = "http://www.vamp-plugins.org/doap.rdf#template-generator"; 30 string programURI = "http://www.vamp-plugins.org/doap.rdf#template-generator";
30 31
31 void usage() 32 void usage()
32 { 33 {
33 cerr << "usage: template-generator -i vamp:soname[:plugin] [vamp:soname[:plugin] ...]" << endl; 34 cerr << endl;
34 cerr << "usage: template-generator PLUGIN_BASE_URI YOUR_URI vamp:soname[:plugin] [vamp:soname[:plugin] ...]" << endl; 35 cerr << "template-generator: Create a skeleton RDF description file describing a Vamp" << endl;
36 cerr << "plugin library using the Vamp ontology." << endl;
37 cerr << endl;
38 cerr << "Usage:" << endl;
39 cerr << " template-generator -i vamp:soname[:plugin] [vamp:soname[:plugin] ...]" << endl;
40 cerr << " template-generator PLUGIN_BASE_URI [ -m YOUR_URI ] [vamp:]soname[:plugin] [[vamp:]soname[:plugin] ...]" << endl;
41 cerr << endl;
42 cerr << "Example:" << endl;
43 cerr << " template-generator http://vamp-plugins.org/rdf/plugins/ vamp-example-plugins" << endl;
44 cerr << endl;
35 exit(2); 45 exit(2);
36 } 46 }
37 47
38 template <class T> 48 template <class T>
39 inline string to_string (const T& t) 49 inline string to_string (const T& t)
62 72
63 string describe_doc(string describerURI, string pluginBundleBaseURI, 73 string describe_doc(string describerURI, string pluginBundleBaseURI,
64 string libname) 74 string libname)
65 { 75 {
66 string res=\ 76 string res=\
67 "<> a vamp:PluginDescription ;\n\ 77 "<> a vamp:PluginDescription ;\n";
68 foaf:maker <"+describerURI+"> ;\n\ 78 if (describerURI != "") {
79 res += " foaf:maker <"+describerURI+"> ;\n";
80 }
81 res += "\
69 foaf:maker <"+programURI+"> ;\n\ 82 foaf:maker <"+programURI+"> ;\n\
70 foaf:primaryTopic <"+pluginBundleBaseURI+libname+"> .\n\n"; 83 foaf:primaryTopic <"+pluginBundleBaseURI+libname+"> .\n\n";
71 return res; 84 return res;
72 } 85 }
73 86
341 if (argc < 3) usage(); 354 if (argc < 3) usage();
342 355
343 bool interactive = false; 356 bool interactive = false;
344 if (!strcmp(argv[1], "-i")) interactive = true; 357 if (!strcmp(argv[1], "-i")) interactive = true;
345 358
346 if (!interactive && argc < 4) usage(); 359 if (!interactive && argc < 3) usage();
347 360
348 string pluginBundleBaseURI, describerURI; 361 string pluginBundleBaseURI, describerURI;
349 362
350 int argidx = 2; 363 int argidx = 2;
351 364
352 if (!interactive) { 365 if (!interactive) {
353 pluginBundleBaseURI = argv[1]; 366 pluginBundleBaseURI = argv[1];
354 describerURI = argv[2]; 367 if (!strcmp(argv[2], "-m")) {
355 argidx = 3; 368 if (argc < 5) usage();
369 describerURI = argv[3];
370 argidx = 4;
371 }
356 } else { 372 } else {
357 cerr << "Please enter the base URI for the plugin bundle : "; 373 cerr << "Please enter the base URI for the plugin bundle : ";
358 getline(cin, pluginBundleBaseURI); 374 getline(cin, pluginBundleBaseURI);
359 cerr << "Please enter your URI : "; 375 cerr << "Please enter your URI (empty to omit) : ";
360 getline(cin, describerURI); 376 getline(cin, describerURI);
361 } 377 }
362 378
363 vector<Plugin *> plugins; 379 vector<Plugin *> plugins;
364 string libname; 380 string libname;