QStringList alternative in STL or Boost

QStringList alternative in STL or Boost

本文关键字:or Boost STL in alternative QStringList      更新时间:2023-10-16

在 Boost 或 STL 中是否有 QStringList 的替代品。我想要实现的是拆分路径,例如。dvb://1.2.3.4/launchpad/dyn/index.htm 只需在QString List中即可分隔字符串:

QStringList path = objectPath.split(QChar('/'), QString::SkipEmptyParts);

谢谢。

>boost::split可以根据一个或多个分隔符将字符串拆分为std::vector<std::string>

#include <vector>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
std::vector<std::string> path_parts;
std::string s("some/file/path");
boost::split(path_parts, s, boost::is_any_of("/"));