annoviko/pyclustering

[C++ pyclustering] pyclustering package error message support

开放

#592 创建于 2020年2月18日

 (0 条评论) (0 个反应) (0 位负责人)Python (263 个派生)auto 404
EnhancementGood First Issue

仓库指标

星标
 (1,215 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Introduction Almost all objects are returned from C++ pyclustering to python pyclustering using pyclustering_package. See files ccore/include/interface/pyclustering_package.hpp and ccore/src/interface/pyclustering_package.cpp.

Description In order to return error message new type of data within pyclustering_package should be introduced:

PYCLUSTERING_TYPE_CHAR_PTR

And non-exported function pyclustering_package * pyclustering_pachage_from_exception(const std::exception & p_error) should be introduced. That should return pyclustering_package where void * data contains pointer char * line that should be created from p_error.what(). For example:

pyclustering_package * package = new pyclustering_package;
package.size = std::strlen(p_error) + 1;
package.type = PYCLUSTERING_TYPE_CHAR_PTR;

char * buffer = new char[package.size];
std::strcpy(buffer, p_error.what());

package.data = (void *) buffer;

The most suitable place for the function is files pyclustering_package.cpp and pyclustering_package.hpp.

贡献者指南