Question & Answer
Question
How do you remove '//' (single line comment style) from file header information generated for tag values using post processing script in IBM Rational Rhapsody?
Cause
You would like to use a C++ script to modify the generated code as per your specific requirement, which is not possible using the GUI.
Answer
In order to remove '//' from file header information generated for tag values, you can use the below C++ post processing script in Rational Rhapsody:
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
---|
#import "C:\Program Files (x86)\IBM\Rational\Rhapsody\7.6\rhapsody.tlb" raw_interfaces_only, no_namespace, named_guids
#include "stdio.h"
#include <string>
#include <conio.h>
#include <iostream>
#include <fstream>
using namespace std;
static void process( const char* filename ) {
string lineString, lineString1, fileString;
int flag = 0, flag1 = 0;
fstream in( filename );
if ( !in ) {
cout << filename << " does not exist!" << endl;
} else {
while ( getline(in, lineString,'\n')) {
if (lineString.substr(0,3) == "// ")
flag = 1;
if (lineString.substr(0,3) == "***")
flag1 = 1;
if (flag == 1 && flag1 == 0) {
lineString.erase(0,2);
lineString = " " + lineString;
}
fileString += lineString + '\n';
}
in.close();
ofstream out(filename, ios::ate );
out.seekp(ios::beg);
out << fileString;
out.close();
}
}
int main(int argc, char* argv[]) {
char fileName[80];
if ( argc > 1 ) {
strcpy (fileName, argv[1] );
process(fileName);
} else {
printf ("Missing arguments\n");
}
return 0;
}
You need to convert the above code to an executable using any C++ IDE [say Microsoft Visual Studio 6] and use the same in the property CG::File::InvokePostProcessor
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21573151