如何使用boost
获得类似的功能 int idx = md.filepath.lastIndexOf('/');
md.title = md.filepath.right(md.filepath.length() - idx -1);
md.title = md.title.left(md.title.length() - 4);
上面的代码(基于QT)查找没有扩展名的文件名,md是一个对象,filepath,title是QString。我浏览了像find_last这样的boost字符串方法,但它返回了iterator_range。我很想提升,谢谢你。
答案 0 :(得分:3)
如果您只想做文件名解析,那么最好使用boost::filesystem::path
类。特别是以下方法:
该课程提供与std::string
和std::wstring
之间的转化。