Conversion de fichiers dans les différents format gérés par Cogitant. Le code source de ce programme se trouve dans "samples/converter". Il n'est utilisable que dans le cas où Cogitant a été compilé avec les fonctions de dessin.
#include <iostream>
using namespace std;
static void printHelp()
{
cerr << "Usage: converter <options>" << endl;
cerr << " -si <fic> Load a support file" << endl;
cerr << " -so <fic> Save the support into a file" << endl;
cerr << " -gi <fic> Load objects from a file (graph, rule, constraint)" << endl;
cerr << " -go <fic> Save an object into a file" << endl;
cerr << " -fi <fic> Load a file (support, graphs, rules, constraints, rdf)" << endl;
cerr << " -fo <fic> Write everything into a file (support + objects)" << endl;
cerr << " -vo <ver> Version of the output format" << endl;
cerr << " CGIF: 1: simplified 2001, 2: 2001, 3: core, 4: extended (default: 4)" << endl;
cerr << " BCGCT: 1, 2: Cogitant v-4, 3: Cogitant v-5 (default: 3)" << endl;
cerr << " -at Allow unknown types when loading a graph" << endl;
cerr << " -ai Allow unknown individuals when loading a graph" << endl;
cerr << " -fp Filter properties. Additional properties (size, colors, etc.) are" << endl;
cerr << " filtered while reading objects." << endl;
cerr << " -ie Ignore DTD errors when loading a file. Use this to load graphs from" << endl;
cerr << " CoGui since CoGui uses extensions of Cogxml." << endl;
cerr << " -ol Use labels instead of ids while writing Cogxml files." << endl;
cerr << " -ib <uri> Set a base URI for relative URis when loading RDF files." << endl;
cerr << "Warning: -so, -go and -fo overwrite file with the given name" << endl;
cerr << "Example: converter -si bucolic.bcs -gi fact.bcg -go fact.cgif -go tmp.fig" << endl;
}
int main(int argc, char* argv[])
{
if (argc == 1)
{
printHelp();
return 0;
}
try
{
vector<cogitant::iSet> igraphs;
unsigned int versionout = 0;
for (int i=1; i<argc; i++)
{
string arg(argv[i]);
if (arg == "-si")
{
i++;
cout << "Loading support " << argv[i] << endl;
}
else if (arg == "-so")
{
i++;
cout << "Writing support " << argv[i] << endl;
}
else if (arg == "-gi")
{
i++;
cout << "Loading objects " << argv[i] << " ..." << endl;
igraphs.clear();
cout << "... " << igraphs.size() << " object(s)" << endl;
}
else if (arg == "-go")
{
i++;
if (!igraphs.empty())
{
cout << "Writing objects " << argv[i] << endl;
}
}
else if (arg == "-fi")
{
i++;
cout << "Loading file " << argv[i] << endl;
env.
read(
string(argv[i]), &igraphs);
}
else if (arg == "-fo")
{
i++;
cout << "Writing file " << argv[i] << endl;
}
else if (arg == "-vo")
{
i++;
}
else if (arg == "-at")
else if (arg == "-ai")
else if (arg == "-fp")
else if (arg == "-ie")
else if (arg == "-ol")
else if (arg == "-ib")
{
i++;
}
else
{
cerr << "Unknown command: " << argv[i] << endl;
printHelp();
return 1;
}
}
}
{
return 1;
}
return 0;
}