annoviko/pyclustering

[C++ pyclustering] pyclustering package error message support

オープン

#592 opened on 2020/02/18

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Python (263 件のフォーク)auto 404
EnhancementGood First Issue

Repository metrics

Stars
 (1,215 個のスター)
PR merge metrics
 (30d に merged 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.

コントリビューターガイド