如何获取 boost::archive 正在保存/加载的文件名
我想知道如何从序列化函数或具有 template
语法的任何其他函数内的存档中获取文件名字符串。
谢谢! =)
I was wondering how I could get the file name string from an archive, inside the serialize function or any other function that has the template<class archive>
syntax.
Thanks! =)
没有可移植的方法来完成您所要求的操作。 归档概念不需要使用文件,甚至也不需要使用 C++ iostream 派生类。所有库存档类型都使用 iostream,但即使这些类型也不一定是文件流。
当然,您可以创建自己的存档类型。一种专门用于文件的。可能从现有类派生,将参数传递给基类。它将有一个额外的函数来获取用于创建它的文件的名称。
There is no portable way of doing what you ask. The archive concept does not require using a file, nor does it even require using a C++ iostream-derived class. All of the libraries archive types use an iostream, but even those don't have to be file streams.
You could create your own archive type of course. One specifically for files. Possibly derived from an existing one, passing arguments to the base class. It would have an extra function to get the name of the file that was used to create it.