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>
static void printHelp()
{
cerr << "Usage: converter <options>" << endl;
cerr << "Main options" << endl;
cerr << " -si <file> Load a support file." << endl;
cerr << " -so <file> Save the support into a file." << endl;
cerr << " -gi <file> Load objects from a file (graph, rule, constraint)." << endl;
cerr << " -go <file> Save an object into a file." << endl;
cerr << " -fi <file> Load a file (support, graphs, rules, constraints, rdf)." << endl;
cerr << " -fo <file> Write everything into a file (support + objects)." << endl;
cerr << " -ff Show file formats and extensions." << endl;
cerr << "Specific options" << 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 << " -fg <id> Filter objects (graphs, rules, constrains). Objects not named <id>" << endl;
cerr << " are ignored in write operations." << endl;
cerr << "CoGXML options" << endl;
cerr << " -ci Ignore DTD errors when loading a file. Use this to load graphs from" << endl;
cerr << " CoGui since CoGui uses extensions of Cogxml." << endl;
cerr << " -cl Use labels instead of ids." << endl;
cerr << "RDF options" << endl;
cerr << " -rb <uri> Set a base URI for relative URis when loading RDF files." << endl;
cerr << " -rp Force the use of prefixes while writing N3 files." << endl;
cerr << "Linear form options" << endl;
cerr << " -ll <lang> Set the language for output." << endl;
cerr << "Fig output options" << endl;
cerr << " -gl Show label on edges." << endl;
cerr << " -gm Show * marker on concepts." << endl;
cerr << 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;
}
{
cout << "File formats" << endl;
{
cout << "IN ";
else
cout << " ";
cout << "OUT ";
else
cout << " ";
for (vector<string>::const_iterator ie=exts.begin(); ie!=exts.end(); ie++)
{
if (ie != exts.begin()) cout << ",";
cout << (*ie);
}
cout << ")" << 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 == "-ff")
printFormats(env);
else if (arg == "-at")
else if (arg == "-ai")
else if (arg == "-fp")
else if (arg == "-fg")
{
i++;
vector<cogitant::iSet>::iterator j=igraphs.begin();
while (j != igraphs.end())
if (env.
objects(*j)->name() == argv[i])
j++;
else
igraphs.erase(j);
cout << igraphs.size() << " selected object(s)" << endl;
}
else if (arg == "-ci")
else if (arg == "-cl")
else if (arg == "-rp")
{
dynamic_cast<cogitant::RdfsOutputN3 *
>(outn3->
getOut())->setAutoPrefixes(
true);
}
else if (arg == "-rb")
{
i++;
}
else if (arg == "-ll")
{
i++;
}
else if ((arg == "-gl") || (arg == "-gm"))
{
{
if (ogl != NULL)
{
if (arg == "-gl")
else if (arg == "-gm")
}
}
}
else
{
cerr << "Unknown command: " << argv[i] << endl;
printHelp();
return 1;
}
}
cout << "Done." << endl;
}
{
return 1;
}
return 0;
}