本文整理汇总了C++中StringView::split方法的典型用法代码示例。如果您正苦于以下问题:C++ StringView::split方法的具体用法?C++ StringView::split怎么用?C++ StringView::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringView
的用法示例。
在下文中一共展示了StringView::split方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolveRelativeVirtualPath
// https://wicg.github.io/entries-api/#resolve-a-relative-path
static String resolveRelativeVirtualPath(StringView baseVirtualPath, StringView relativeVirtualPath)
{
ASSERT(baseVirtualPath[0] == '/');
if (!relativeVirtualPath.isEmpty() && relativeVirtualPath[0] == '/')
return relativeVirtualPath.length() == 1 ? relativeVirtualPath.toString() : resolveRelativeVirtualPath("/", relativeVirtualPath.substring(1));
Vector<StringView> virtualPathSegments;
for (auto segment : baseVirtualPath.split('/'))
virtualPathSegments.append(segment);
for (auto segment : relativeVirtualPath.split('/')) {
ASSERT(!segment.isEmpty());
if (segment == ".")
continue;
if (segment == "..") {
if (!virtualPathSegments.isEmpty())
virtualPathSegments.removeLast();
continue;
}
virtualPathSegments.append(segment);
}
if (virtualPathSegments.isEmpty())
return "/"_s;
StringBuilder builder;
for (auto& segment : virtualPathSegments) {
builder.append('/');
builder.append(segment);
}
return builder.toString();
}
示例2: isZeroOrMorePathSegmentsSeparatedBySlashes
static bool isZeroOrMorePathSegmentsSeparatedBySlashes(StringView string)
{
auto segments = string.split('/');
for (auto segment : segments) {
if (!isValidPathSegment(segment))
return false;
}
return true;
}
示例3: evaluatePath
// https://wicg.github.io/entries-api/#evaluate-a-path
String DOMFileSystem::evaluatePath(StringView virtualPath)
{
ASSERT(virtualPath[0] == '/');
Vector<StringView> resolvedComponents;
for (auto component : virtualPath.split('/')) {
if (component == ".")
continue;
if (component == "..") {
if (!resolvedComponents.isEmpty())
resolvedComponents.removeLast();
continue;
}
resolvedComponents.append(component);
}
return FileSystem::pathByAppendingComponents(m_rootPath, resolvedComponents);
}