本文整理汇总了C++中VString::getSubstring方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::getSubstring方法的具体用法?C++ VString::getSubstring怎么用?C++ VString::getSubstring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VString
的用法示例。
在下文中一共展示了VString::getSubstring方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _lastNonTrailingIndexOfPathSeparator
static int _lastNonTrailingIndexOfPathSeparator(const VString& s, int& lengthWithoutTrailingSeparator) {
bool hasTrailingPathSeparator = s.endsWith(VFSNode::PATH_SEPARATOR_CHAR);
if (!hasTrailingPathSeparator) {
lengthWithoutTrailingSeparator = s.length();
return s.lastIndexOf(VFSNode::PATH_SEPARATOR_CHAR);
}
VString stripped;
s.getSubstring(stripped, s.begin(), s.end() - 1);
lengthWithoutTrailingSeparator = stripped.length();
return stripped.lastIndexOf(VFSNode::PATH_SEPARATOR_CHAR);
}
示例2: _testOverloadedStreamCopyAPIs
void VStreamsUnit::_testOverloadedStreamCopyAPIs() {
// Test the overloaded streamCopy APIs.
// 2 low-level VStream objects (VMemoryStream).
// 2 high-level VIOStream objects that use them (VTextIOStream).
VMemoryStream vstreamFrom;
VMemoryStream vstreamTo;
VTextIOStream viostreamFrom(vstreamFrom);
VTextIOStream viostreamTo(vstreamTo);
// Write a very long string into the source, and reset it.
const VString EXAMPLE_STRING("This is a very long string that we will copy from stream to stream using different overloaded APIs.");
viostreamFrom.writeString(EXAMPLE_STRING);
viostreamFrom.seek0();
// Copy 10 bytes at a time, using each of the 4 overloaded APIs.
// 1. VStream to VStream
VStream::streamCopy(vstreamFrom, vstreamTo, 10);
// 2. VIOStream to VIOStream
VStream::streamCopy(viostreamFrom, viostreamTo, 10);
// 3. VIOStream to VStream
VStream::streamCopy(viostreamFrom, vstreamTo, 10);
// 4. VStream to VIOStream
VStream::streamCopy(vstreamFrom, viostreamTo, 10);
// Verify that the data was correctly copied.
viostreamTo.seek0();
VUNIT_ASSERT_EQUAL_LABELED(viostreamTo.available(), CONST_S64(40), "all 40 bytes copied");
VString whatWasCopied;
viostreamTo.readAll(whatWasCopied);
VString whatShouldHaveBeenCopied;
EXAMPLE_STRING.getSubstring(whatShouldHaveBeenCopied, 0, 40);
VUNIT_ASSERT_EQUAL_LABELED(whatWasCopied, whatShouldHaveBeenCopied, "correct substring was copied");
}