Program that renames a specific SId and updates all references to it in a given model.
#include <iostream>
int
main (int argc, char* argv[])
{
if (argc != 5)
{
cout << endl << "Usage: renameSId filename oldSId newSId output" << endl << endl;
return 1;
}
const char* filename = argv[1];
const char* oldSId = argv[2];
const char* newSId = argv[3];
const char* output = argv[4];
if (strcmp(oldSId, newSId) == 0)
{
cout << "The Ids are identical, renaming stopped." << endl;
return 1;
}
if (!SyntaxChecker::isValidInternalSId(newSId))
{
cout << "The new SId '" << newSId
<< "' does not represent a valid SId."
<< endl;
return 1;
}
#ifdef __BORLANDC__
unsigned long start, stop;
#else
unsigned long long start, stop;
#endif
start = getCurrentMillis();
stop = getCurrentMillis();
cout << endl;
cout << " filename: " << filename << endl;
cout << " file size: " << getFileSize(filename) << endl;
cout << " read time (ms): " << stop - start << endl;
cout << " error(s): " << errors << endl;
cout << endl;
if (errors > 0)
{
delete document;
return errors;
}
if (element == NULL)
{
cout << "Found no element with SId '"
<< oldSId << "'." << endl;
return 1;
}
for (
unsigned int i = 0; i < allElements->
getSize(); ++i)
static_cast<SBase*>(allElements->
get(i))->renameSIdRefs(oldSId, newSId);
delete document;
return errors;
}