How can I obtain similar functionality with 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);
Above code( QT based) finds the name of the file without extension , md is an object , filepath, title are QString . I have browsed boost’s string methods like find_last but it returns iterator_range. I m new to boost , thanks in advance .
If all you want to do is filename parsing then you’d be better off using the
boost::filesystem::pathclass. In particular the following methods:path filename() const;path stem() const;andpath extension() const;The class provides conversions to and from
std::stringandstd::wstring.