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


C++ string::size方法代码示例

本文整理汇总了C++中st::string::size方法的典型用法代码示例。如果您正苦于以下问题:C++ string::size方法的具体用法?C++ string::size怎么用?C++ string::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st::string的用法示例。


在下文中一共展示了string::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memcpy

void DS::Stream::writeSafeString(const ST::string& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        ST::utf16_buffer buffer = value.to_utf16();
        uint16_t length = value.size() & 0x0FFF;
        ST::utf16_buffer work;
        char16_t* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char16_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char16_t));
        write<char16_t>(0);
    } else {
        ST::char_buffer buffer = (format == e_StringUTF8) ? value.to_utf8()
                               : value.to_latin_1(ST::substitute_invalid);
        uint16_t length = value.size() & 0x0FFF;
        ST::char_buffer work;
        char* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char));
    }
}
开发者ID:zrax,项目名称:dirtsand,代码行数:26,代码来源:streams.cpp

示例2: cdUp

ST::string cdUp(ST::string path) {
    // Check for root paths, we can't go up from there!
#ifdef _WIN32
    if (path.substr(1) == ":\\")
        return path;
#else
    if (path == "/")
        return path;
#endif

    // Not very robust, but it works for one level of parent scanning
    if (path.is_empty())
        return ".." PATHSEPSTR;

    // Strip the ending slash, if necessary, and then go up one dir
    if (path.char_at(path.size()-1) == PATHSEP)
        path = path.left(path.size() - 1);
    ST::string up = path.before_last(PATHSEP);
    if (path.char_at(0) == PATHSEP) {
        // Absolute path specified -- make sure we keep it that way
        return up + PATHSEPSTR;
    } else {
        // Relative path specified
        return up.is_empty() ? "" : up + PATHSEPSTR;
    }
}
开发者ID:Lunanne,项目名称:libhsplasma,代码行数:26,代码来源:PlasmaSum.cpp

示例3: GetPassword

/*****************************************************************************
 ** pfMacPasswordStore                                                      **
 *****************************************************************************/
ST::string pfMacPasswordStore::GetPassword(const ST::string& username)
{
    ST::string service = GetServerDisplayName();

    void* passwd = nullptr;
    uint32_t passwd_len = 0;

    if (SecKeychainFindGenericPassword(nullptr,
                                       service.size(),
                                       service.c_str(),
                                       username.size(),
                                       username.c_str(),
                                       &passwd_len,
                                       &passwd,
                                       nullptr) != errSecSuccess)
    {
        return ST::null;
    }

    ST::string ret(reinterpret_cast<const char*>(passwd), size_t(passwd_len));

    SecKeychainItemFreeContent(nullptr, passwd);

    return ret;
}
开发者ID:Deledrius,项目名称:Plasma,代码行数:28,代码来源:pfPasswordStore_Mac.cpp

示例4: CleanFileName

ST::string CleanFileName(const ST::string& fname) {
    ST::char_buffer result;
    char* buf = result.create_writable_buffer(fname.size());
    memcpy(buf, fname.c_str(), fname.size() + 1);
    for (char* bp = buf; *bp; bp++) {
        if (*bp == '?' || *bp == '*' || *bp == '<' || *bp == '>' ||
            *bp == '"' || *bp == '|' || *bp < (char)0x20)
            *bp = '_';
        if (*bp == '/' || *bp == '\\' || *bp == ':')
            *bp = '_';
    }
    return result;
}
开发者ID:Deledrius,项目名称:libhsplasma,代码行数:13,代码来源:PrpPack.cpp

示例5: FixSlashes

ST::string FixSlashes(const ST::string& src) {
    if (src.is_empty())
        return src;

    ST::char_buffer dest;
    char* pbuf = dest.create_writable_buffer(src.size());
    memcpy(pbuf, src.c_str(), src.size() + 1);
    for (char* pc = pbuf; *pc != 0; pc++) {
        if (*pc == '/' || *pc == '\\')
            *pc = PATHSEP;
    }
    return dest;
}
开发者ID:Lunanne,项目名称:libhsplasma,代码行数:13,代码来源:PlasmaSum.cpp

示例6: SetPassword

bool pfMacPasswordStore::SetPassword(const ST::string& username, const ST::string& password)
{
    ST::string service = GetServerDisplayName();

    return SecKeychainAddGenericPassword(nullptr,
                                         service.size(),
                                         service.c_str(),
                                         username.size(),
                                         username.c_str(),
                                         password.size(),
                                         password.c_str(),
                                         nullptr) == errSecSuccess;
}
开发者ID:Deledrius,项目名称:Plasma,代码行数:13,代码来源:pfPasswordStore_Mac.cpp


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