0

我在 IDL(test.idl) 文件中有一种方法:

bool login(in string name, in string cipher) raises (AuthenticationException);

AuthenticationException 在我的 IDL 文件中被声明为异常。然后我使用 tao_idl 生成具有以下参数的骨架:

-Wb,stub_export_macro=BASE_STUB_Export -Wb,stub_export_include=base_stub_export.h -Wb,skel_export_macro=BASE_SKEL_Export -Wb,skel_export_include=base_skel_export.h -GC

但是,testS.h 中生成的登录方法是这样的:

virtual ::project::UserContext * login (
  const char * name,
  const char * cipher) = 0;

和testI.h:

virtual
 ::project::UserContext * login (
  const char * name,
  const char * cipher);

这对我来说很奇怪。因为方法声明缺少 AuthenticationException 异常。我相信该方法应该是这样的: login(..) throw(AuthenticationException) 在业务逻辑中抛出自定义异常,而不是 CORBA 标准异常,并且客户端存根可以捕获这些异常。

我的 tao_idl 参数有问题吗?

4

1 回答 1

1

不,您的 tao_idl 参数没有任何问题,这就是 IDL 到 C++ 映射的定义方式。旧版本的 IDL 到 C++ 确实在 C++ 中使用了异常规范,但最近的没有,请参阅 OMG IDL 到 C++ 的映射,您可以从http://www.omg.org/spec/CPP获得。

此外,IDL 到 C++11 语言映射不使用异常规范,这种更现代的 C++ 语言映射也可从 OMG 获得,请参阅http://www.omg.org/spec/CPP11

您的 IDL 方法和生成的签名不匹配,使用 IDL 到 C++11 您在 IDL 中的登录方法(具有布尔返回类型)看起来像

virtual bool login (const std::string& name, const std::string& cipher) = 0;
于 2013-12-01T17:59:33.943 回答