繁体   English   中英

使用自定义可搜索源boost :: iostreams :: stream

[英]Using custom seekable source boost::iostreams::stream

如果我想使用boost :: iostreams :: stream的自定义可搜索源,需要实现哪些方法? 我查看了Boost的无法搜索的源缓冲区教程 ,并尝试将标记修改为input_seekable并添加了本教程中seek功能。 不幸的是,这导致我的编译器抱怨缺少get函数,我找不到文档(从编译器错误消息,我可以弄清楚签名是什么,但就是这样)。 这个功能应该做什么? 我还需要实现其他任何功能吗?

此外,编译器希望我有三个输入参数来seek ; 第一个是*dev ,我认为它将由stream本身提供。

设备标题:

class SourceBuffer
{
private:
  FILE *file;

public:
  typedef char                              char_type;
  typedef boost::iostreams::input_seekable  category;

  SourceBuffer(const char *fileName);
  SourceBuffer();
  ~SourceBuffer();

  std::streamsize                 read(char *s, std::streamsize n);

  boost::iostreams::stream_offset seek(boost::iostreams::stream_offset off, std::ios_base::seekdir way);

  void open(const char *fileName);
  void close();
protected:
}

用法:

boost::iostreams::stream<SourceBuffer> *example;
example = new boost::iostreams::stream<SourceBuffer>(fileName);

SeekableDevice概念中记录了确切的要求: http//www.boost.org/doc/libs/1_58_0/libs/iostreams/doc/concepts/seekable_device.html

您可以查看列出的任何模型的实现,以获取有关如何解决此问题的提示:

  • 阵列,
  • 文件,
  • 类file_descriptor,
  • 将mapped_file

关于dev*参数,似乎你在使用自由函数模板boost :: iostreams :: seek来混淆Device::seek (你实现的是为了满足这个概念)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM