简体   繁体   中英

Ibm Rational Rhapsody C++; using the Java Api: extract #include information

I need to extract information from a single C++ class in Rhapsody. Using the Java Api, I had no problems getting the operations and attributes of a class, but I also need the #include paths that the class uses.

Rhapsody has those information saved somewhere, when I generate the class they are available in the files.

Generating the class from Rhapsody is not an option because I need to modify the operations in a certain way.

Here's an example Rhapsody project: https://www.datafilehost.com/d/1384936c

When extracting the class Bar, I also want to get the String " #include "stdint.h" ".

To give you an idea where I want to go: I want to unit test the class Foo, and thus need a mock of the class Bar. The unit test framework is googletest. It would be helpful to generate the mocked class directly from the rhapsody project. It should look like this:

    // file Bar_MOCK.h
    #include <stdint.h>
    #include <gmock/gmock.h>
    class Bar_MOCK {
    public:
      MOCK_METHOD1(getInt, void(uint64_t* val));
      MOCK_METHOD1(setInt, void(uint64_t val));
    };

You will need to iterate through the attributes and arguments, look at the types and then from those types navigate up the hierarchy to put together a fully qualified namespace to make your imports for your java class. The other option is to just use fully qualified namespaces in place in your java code that you generate. Oh, and don't forget to consult the NameSpaceName and DefineNameSpace properties. You will probably want to break the processing of any class down into at least 2 steps: 1-collect and create the imports needed, 2-write the rest of the Java class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM