我在我的软件中使用 geos 库作为几何引擎。我目前正在使用它的 capi(因为这是推荐的 api)。
现在的问题是我想序列化和反序列化 struct GEOSGeometry。该库本身是在 c++ 中的,而 capi 是它的包装器。所以说结构定义不可用。我有哪些选择?
这就是capi提到的
/* When we're included by geos_c.cpp, those are #defined to the original
* JTS definitions via preprocessor. We don't touch them to allow the
* compiler to cross-check the declarations. However, for all "normal"
* C-API users, we need to define them as "opaque" struct pointers, as
* those clients don't have access to the original C++ headers, by design.
*/
#ifndef GEOSGeometry
typedef struct GEOSGeom_t GEOSGeometry;
这就是它的包装方式
// Some extra magic to make type declarations in geos_c.h work -
// for cross-checking of types in header.
#define GEOSGeometry geos::geom::Geometry
任何帮助表示赞赏。