开发者

objective-c wrapper for namespaced c++ library (gloox)

Im trying to wrap the gloox library in objective-c. I have read this article Making a Objective-C Wrapper for a C++ Library and it is fair开发者_运维技巧ly straight forward however it does not cover classes that are inside a namespace. Any thoughts on how to use the technique in the article above only with a namespace? Thanks for the help!

[edit] Think I figured it out add

#ifdef __cplusplus
namespace gloox {
class Client;
}
#endif


I think the obvious should work when compiled as objective C++:

#if defined __cplusplus
namespace Foo { class MyCPPClass; }   // forward class declaration
#else
/*not sure here*/ /*namespace Foo { typedef struct MyCPPClass MyCPPClass;  }*/ // forward struct declaration
#endif

@interface MyOCClass : NSObject
{
@private
    Foo::MyCPPClass* cppObject;
} 

// methods and properties

@end

The Qt project has a lot of examples for mixing C++ and Objective-C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜