【发布时间】:2021-01-02 04:42:07
【问题描述】:
我必须连接两个 API,它们使用不同的结构来描述文件。一个为我提供std::FILE*,第二个期望GFile* 或GInputStream* 属于GIO。有没有一种直接的方法可以从我收到的原始文件指针创建任何一个对象?
void my_function(std::FILE * file) {
GFile * gfile = some_creator_method(file);
//or alternatively
GInputStream * ginput = some_stream_creator_method(file);
//...
//pass the GFile to the other library interface
//either using:
interface_function(gfile);
//or using
interface_stream_function(ginput);
}
//The interface function signatures I want to pass the parameter to:
void interface_function(GFile * f);
void interface_stream_function(GInputStream * is);
【问题讨论】: