当前位置: 首页>>代码示例>>C++>>正文


C++ VString::getSubstring方法代码示例

本文整理汇总了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);
}
开发者ID:trygve-isaacson,项目名称:code-vault,代码行数:12,代码来源:vfsnode.cpp

示例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");
}
开发者ID:JohnChristman,项目名称:code-vault,代码行数:36,代码来源:vstreamsunit.cpp


注:本文中的VString::getSubstring方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。