关于C#:使用自定义可搜索的源boost :: iostreams :: stream

Using custom seekable source boost::iostreams::stream

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

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

设备头:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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:
}

用法:

1
2
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,
  • 映射文件

关于dev*参数,您似乎将Device::seek(为了满足该概念而实现的东西)与免费功能模板boost :: iostreams :: seek

混淆了