Skip to main content

How to change comment location in Rational Rhapsody generated code using post processing script


Technote (FAQ)


Question

How do you change the position of comments in IBM Rational Rhapsody generated code using a post processing script?

Cause

You would like to adjust the position of the comments generated by Rhapsody to comply with external report generation tools. like Doxygen.

Answer

In order to adjust the position of comments in Rational Rhapsody generated code, you can use the below C++ post processing script:

Disclaimer

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.



#include "stdio.h"
#include <string>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <atlbase.h>

using namespace std;

static void process( const char* filename, string newTypesPkg ) {

string startString, endString, lineString, fileString;

fstream in( filename );

size_t found;

if ( !in ) {

cout << filename << " does not exist!" << endl;

} else {

while ( getline(in, lineString,'\n'))

{

if (lineString.substr(0,26) == "    /* some declaration */") {

continue;

}

found = lineString.find("/*## attribute");

if (found != string::npos)

{

size_t len = lineString.size();

lineString.replace(found,len - found, "    /* some declaration */");

}


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];
string newTypesPkg;

if ( argc > 1 ) {

strcpy (fileName, argv[1] );

process(fileName , newTypesPkg);

} else {

printf ("Missing arguments\n");

}

return 0;

}


You will 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


Rate this page:

(0 users)Average rating

Copyright and trademark information

IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.

Rate this page:


(0 users)Average rating

Add comments

Document information

Rational Rhapsody

General Information


Software version:
7.6.1.3, 8.0


Operating system(s):
Windows


Reference #:
1622167


Modified date:
2013-02-01

Translate my page

Content navigation