2008-11-11 18:51:01 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/props/props_io.hxx>
|
|
|
|
#include <simgear/structure/exception.hxx>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
void usage()
|
|
|
|
{
|
|
|
|
cerr << "Usage: propmerge [-o <outfile>] <infiles>" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if (argc < 2) {
|
|
|
|
usage();
|
2008-11-12 14:41:01 +00:00
|
|
|
return 1;
|
2008-11-11 18:51:01 +00:00
|
|
|
}
|
|
|
|
|
2008-11-11 22:09:56 +00:00
|
|
|
sglog().setLogLevels(SG_ALL, SG_ALERT);
|
|
|
|
|
2008-11-11 18:51:01 +00:00
|
|
|
int numfiles = 0;
|
2008-11-12 14:41:01 +00:00
|
|
|
string outfile;
|
2008-11-11 18:51:01 +00:00
|
|
|
SGPropertyNode root;
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
string s = argv[i];
|
|
|
|
if (s == "-h" || s == "--help") {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s == "-o" || s == "--output") {
|
|
|
|
if (i + 1 == argc)
|
|
|
|
break;
|
2008-11-12 14:41:01 +00:00
|
|
|
outfile = argv[++i];
|
2008-11-11 18:51:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
readProperties(s, &root);
|
|
|
|
numfiles++;
|
|
|
|
} catch (const sg_exception &e) {
|
|
|
|
cerr << "Error: " << e.getFormattedMessage() << endl;
|
2008-11-12 14:41:01 +00:00
|
|
|
return 2;
|
2008-11-11 18:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!numfiles) {
|
|
|
|
cerr << "Error: Nothing to merge." << endl;
|
2008-11-12 14:41:01 +00:00
|
|
|
return 3;
|
2008-11-11 18:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2008-11-12 14:41:01 +00:00
|
|
|
if (outfile.empty())
|
2008-11-11 18:51:01 +00:00
|
|
|
writeProperties(cout, &root, true);
|
|
|
|
else
|
2008-11-12 14:41:01 +00:00
|
|
|
writeProperties(outfile, &root, true);
|
2008-11-11 18:51:01 +00:00
|
|
|
|
|
|
|
} catch (const sg_exception &e) {
|
|
|
|
cerr << "Error: " << e.getFormattedMessage() << endl;
|
2008-11-12 14:41:01 +00:00
|
|
|
return 4;
|
2008-11-11 18:51:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|