Translation of C ++ API into managed code API

I am trying to wrap a C ++ library in Objective-C classes for import into MonoTouch using btouch. I am trying to understand how to translate the API for use in a managed environment. In particular, how to handle methods that accept pointers to local variables, such as the static method ULDatabaseManager :: OpenConnection in the following example:

class UL_CLS_SPEC ULError {
    public:
    ULError();

    /* Gets the error code (SQLCODE) for the last operation. */
    inline an_sql_code GetSQLCode() const {
        return _info.sqlcode;
    }
}

class UL_CLS_SPEC ULDatabaseManager {
    public:
    /* Initializes the UltraLite runtime. */
    static bool Init();

    /* Finalizes the UltraLite runtime. */
    static void Fini();

    /* Opens a new connection to an existing database. */
    static ULConnection * OpenConnection(
        const char * connParms,
        ULError * error = UL_NULL);
}

From Objective-C, this C ++ API will be called as follows:

- (void)openConnection {
    if (ULDatabaseManager::Init()) {
        const char * connectionParms;
        ULConnection * conn = nil;
        ULError error;

        connectionParms = [self getConnectionParms];

        // Attempt connection to the database
        conn = ULDatabaseManager::OpenConnection(connectionParms, &error);

        // If database file not found, create it and create the schema
        if (error.GetSQLCode() == SQLE_ULTRALITE_DATABASE_NOT_FOUND) {       
            // Handle error
        }                
    }
}

API OpenConnection ULError . , , , , , , ULError. API Objective-C? ULError?

, , ++ Objective-C ( MonoTouch, ), , , !:) . , , ++ API.

PS: , ++ Objective-C, MonoTouch , -, btouch Objective-C, .

+3
2

, , - API, Monotouch btouch. , , OpenConnection, , . open nil, . ULError, lastConnectionError, ++ OpenConnection ++. - GetLastConnectionError, , .

0

, objective-c ++. btouch .

+1

All Articles