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


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

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


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

示例1: parser

TEST(plCmdParser, wchar_argv_parsing)
{
    const plCmdArgDef cmds[] = {
        { kCmdArgRequired | kCmdTypeString, "path", 0}
    };

    plCmdParser parser(cmds, arrsize(cmds));

    const wchar_t* args[] = {L"plCmdParser", L"~/.plasma/config.dat"};
    int argc = 2;

    std::vector<ST::string> tokens(argc);
    for (int i = 0; i < argc; i++) {
        tokens.push_back(ST::string::from_wchar(args[i]));
    }

    bool success = parser.Parse(tokens);

    ST::string prog = parser.GetProgramName();
    ST::string path = parser.GetString(0);

    EXPECT_EQ(success, true);
    EXPECT_STREQ(prog.c_str(), "plCmdParser");
    EXPECT_STREQ(path.c_str(), "~/.plasma/config.dat");
    EXPECT_EQ(parser.GetError(), kCmdErrorSuccess);
}
开发者ID:H-uru,项目名称:Plasma,代码行数:26,代码来源:test_plCmdParser.cpp

示例2: 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

示例3: 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

示例4: ICreateLocation

plLocation plPluginResManager::ICreateLocation(const ST::string& age, const ST::string& page, int32_t seqNum, bool itinerant)
{
    bool willBeReserved = age.compare_i("global") == 0;

    int32_t oldNum = seqNum;
    seqNum = VerifySeqNumber(seqNum, age, page);
    if (seqNum != oldNum)
    {
        hsAssert(false, "Conflicting page sequence number. Somebody called NameToLoc without verifying their seq# first!"); 
    }

    if (seqNum < 0)
    {
        willBeReserved = true;
        seqNum = -seqNum;
    }

    plLocation newLoc;
    if (willBeReserved)
        newLoc = plLocation::MakeReserved(seqNum);
    else
        newLoc = plLocation::MakeNormal(seqNum);

    // Flag common pages
    for (int i = 0; i < plAgeDescription::kNumCommonPages; i++)
    {
        if (page.compare(plAgeDescription::GetCommonPage(i)) == 0)
        {
            newLoc.SetFlags(plLocation::kBuiltIn);
            break;
        }
    }

    // If we have an age description file for the age we're creating a location
    // for, grab some extra flags from it
    plAgeDescription* ageDesc = plPageInfoUtils::GetAgeDesc(age.c_str());
    plAgePage* agePage = ageDesc ? ageDesc->FindPage(page.c_str()) : nil;
    if (agePage)
    {
        if (agePage->GetFlags() & plAgePage::kIsLocalOnly)
            newLoc.SetFlags(plLocation::kLocalOnly);

        if (agePage->GetFlags() & plAgePage::kIsVolatile)
            newLoc.SetFlags(plLocation::kVolatile);
    }
    if (itinerant)
        newLoc.SetFlags(plLocation::kItinerant);

    delete ageDesc;
    return newLoc;
}
开发者ID:Hoikas,项目名称:Plasma,代码行数:51,代码来源:plPluginResManager.cpp

示例5: ILog

void plResponderModifier::ILog(uint32_t color, const char* format, ...)
{
#ifdef STATUS_LOG
    if (!gLog)
        gLog = plStatusLogMgr::GetInstance().CreateStatusLog(15, "Responder", plStatusLog::kFilledBackground | plStatusLog::kDeleteForMe | plStatusLog::kDontWriteFile | plStatusLog::kAlignToTop);

    if (!format || *format == '\0')
        return;

    ST::string keyName = GetKeyName();

    // Make sure this key isn't in our list of keys to deny
    for (const auto& it : gNoLogStrings) {
        if (keyName.starts_with(it))
            return;
    }

    // Format the log text
    char buf[256];
    va_list args;
    va_start(args, format);
    int numWritten = hsVsnprintf(buf, sizeof(buf), format, args);
    hsAssert(numWritten > 0, "Buffer too small");
    va_end(args);

    // Strip the redundant part off the key name
    ST_ssize_t modPos = keyName.find("_ResponderModifier");
    if (modPos != -1)
        keyName = keyName.left(modPos);

    ST::string logLine = ST::format("{}: {}", keyName, buf);
    gLog->AddLine(logLine.c_str(), color);
#endif // STATUS_LOG
}
开发者ID:H-uru,项目名称:Plasma,代码行数:34,代码来源:plResponderModifier.cpp

示例6: LoadPythonFiles

void plPythonMgr::LoadPythonFiles()
{
    plFileName clientPath = plMaxConfig::GetClientPath(false, true);
    if (clientPath.IsValid())
    {
        plFileName oldCwd = plFileSystem::GetCWD();
        plFileSystem::SetCWD(clientPath);

        // Get the path to the Python subdirectory of the client
        plFileName pythonPath = plFileName::Join(clientPath, "Python");

        PythonInterface::initPython();

        // Iterate through all the Python files in the folder
        std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py");
        for (auto iter = pys.begin(); iter != pys.end(); ++iter)
        {
            // Get the filename without the ".py" (module name)
            ST::string fileName = iter->GetFileNameNoExt();

            IQueryPythonFile(fileName.c_str());
        }

        PythonInterface::finiPython();

        plFileSystem::SetCWD(oldCwd);
    }
}
开发者ID:Hoikas,项目名称:Plasma,代码行数:28,代码来源:plPythonMgr.cpp

示例7: INewPage

void plAgeDescInterface::INewPage()
{
    ST::string name = ST_LITERAL("New Page Name");

    // Get the name of the new age from the user
    int ret = DialogBoxParam(hInstance,
                            MAKEINTRESOURCE(IDD_AGE_NAME),
                            GetCOREInterface()->GetMAXHWnd(),
                            NewAgeDlgProc,
                            (LPARAM)&name);
    if (ret != 1)
        return;

    HWND hPages = GetDlgItem(fhDlg, IDC_PAGE_LIST);

    // Make sure this page doesn't already exist
    int count = ListBox_GetCount(hPages);
    for (int i = 0; i < count; i++)
    {
        char pageName[256];
        ListBox_GetText(hPages, i, pageName);
        if (!name.compare_i(pageName))
            return;
    }

    // Add the new page and select it
    int idx = ListBox_AddString(hPages, name.c_str());

    // Choose a new sequence suffix for it
    plAgePage *newPage = new plAgePage( name, IGetFreePageSeqSuffix( hPages ), 0 );
    ListBox_SetItemData( hPages, idx, (LPARAM)newPage );
   
    fDirty = true;
}
开发者ID:Hoikas,项目名称:Plasma,代码行数:34,代码来源:plAgeDescInterface.cpp

示例8: SetPassword

bool pfUnixPasswordStore::SetPassword(const ST::string& username,
                                      const ST::string& password)
{
    GError *error = nullptr;
    ST::string server = GetServerDisplayName();
    secret_password_store_sync(&pfPasswordStore_Schema, SECRET_COLLECTION_DEFAULT,
                               ST::format("Myst Online Password for {}", server).c_str(),
                               password.c_str(), nullptr, &error,
                               "username", username.c_str(),
                               "server", server.c_str(),
                               nullptr);
    if (error) {
        g_error_free(error);
        return false;
    } else {
        return true;
    }
}
开发者ID:Deledrius,项目名称:Plasma,代码行数:18,代码来源:pfPasswordStore_Unix.cpp

示例9: DebugMsg

void plSDLParser::DebugMsg(const ST::string& msg) const
{
    return;
    plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();

    if (netApp)
        hsLogEntry(netApp->DebugMsg(msg));
    else
        hsStatusMessage(msg.c_str());
}
开发者ID:H-uru,项目名称:Plasma,代码行数:10,代码来源:plSDLParser.cpp

示例10: 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

示例11: 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

示例12: ILoadUser

void plMtlEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb)
{
    HWND hList = GetDlgItem(hWnd, IDC_EVENT_LIST);
    ListBox_ResetContent(hList);

    //
    // If we don't have a valid material, we should be disabled
    //
    Mtl* mtl = pb->GetMtl(kMtlMtl);
    if (!mtl)
    {
        EnableWindow(hList, FALSE);
        return;
    }
    else
        EnableWindow(hList, TRUE);

    //
    // Load the events
    //
    int idx;

    idx = ListBox_AddStringData(hList, "(Begin)", kAnimEventBegin);
    if (pb->GetInt(kMtlBegin))
        ListBox_SetSel(hList, TRUE, idx);

    idx = ListBox_AddStringData(hList, "(End)", kAnimEventEnd);
    if (pb->GetInt(kMtlEnd))
        ListBox_SetSel(hList, TRUE, idx);

    if (mtl)
    {
        ST::string mtlAnim = ST::string::from_utf8(pb->GetStr(kMtlAnim));

        // Get the shared animations for all the nodes this component is applied to
        plNotetrackAnim anim(mtl, nil);
        plAnimInfo info = anim.GetAnimInfo(mtlAnim);

        RemoveDeadMarkers(pb, kMtlMarkers, info);

        // Get all the markers in this animation
        ST::string marker;
        while (!(marker = info.GetNextMarkerName()).is_empty())
        {
            idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker);

            if (IsMarkerSelected(pb, kMtlMarkers, marker))
                ListBox_SetSel(hList, TRUE, idx);
        }
    }
}
开发者ID:H-uru,项目名称:Plasma,代码行数:51,代码来源:plAnimEventComponent.cpp

示例13: SendBasic

static void SendBasic(unsigned char*& buf, const msgparm_t& data,
                      unsigned int size, unsigned int count)
{
    // Also works for floats and doubles
    if (count == 0) {
        if (size == 1) {
            *(uint8_t*)buf = (uint8_t)data.fUint;
            buf += sizeof(uint8_t);
        } else if (size == 2) {
            *(uint16_t*)buf = (uint16_t)data.fUint;
            buf += sizeof(uint16_t);
        } else if (size == 4) {
            *(uint32_t*)buf = data.fUint;
            buf += sizeof(uint32_t);
        }

#ifdef COMMDEBUG
        plDebug::Debug("     -> Int{}: {}", size * 8, data.fUint);
#endif
    } else {
        if (size == 1) {
            memcpy(buf, data.fData, count * sizeof(uint8_t));
            buf += count * sizeof(uint8_t);
        } else if (size == 2) {
            memcpy(buf, data.fData, count * sizeof(uint16_t));
            buf += count * sizeof(uint16_t);
        } else if (size == 4) {
            memcpy(buf, data.fData, count * sizeof(uint32_t));
            buf += count * sizeof(uint32_t);
        }

#ifdef COMMDEBUG
        ST::string ln = ST::format("     -> Int{}[{}]: ", size * 8, count);
        size_t lnbufSize = count * ((size * 2) + 1);
        char* lnbuf = new char[lnbufSize + 1];
        for (size_t i=0; i<count; i++) {
            if (size == 1)
                sprintf(lnbuf + (i * 3), "%02X ", ((uint8_t*)data.fData)[i]);
            else if (size == 2)
                sprintf(lnbuf + (i * 5), "%04X ", ((uint16_t*)data.fData)[i]);
            else if (size == 4)
                sprintf(lnbuf + (i * 9), "%08X ", ((uint32_t*)data.fData)[i]);
        }
        lnbuf[lnbufSize] = 0;
        ln += lnbuf;
        delete[] lnbuf;
        plDebug::Debug(ln.c_str());
#endif
    }
}
开发者ID:Lunanne,项目名称:libhsplasma,代码行数:50,代码来源:pnSocket.cpp

示例14: RecvBasic

static void RecvBasic(pnSocket* sock, msgparm_t& data,
                      unsigned int size, unsigned int count)
{
    // Also works for floats
    if (count == 0) {
        if (size == 1) {
            uint8_t v;
            sock->recv(&v, sizeof(uint8_t));
            data.fUint = v;
        } else if (size == 2) {
            uint16_t v;
            sock->recv(&v, sizeof(uint16_t));
            data.fUint = v;
        } else if (size == 4) {
            uint32_t v;
            sock->recv(&v, sizeof(uint32_t));
            data.fUint = v;
        }

#ifdef COMMDEBUG
        plDebug::Debug("     <- Int{}: {}", size * 8, data.fUint);
#endif
    } else {
        if (size == 1)
            sock->recv(data.fData, count * sizeof(uint8_t));
        else if (size == 2)
            sock->recv(data.fData, count * sizeof(uint16_t));
        else if (size == 4)
            sock->recv(data.fData, count * sizeof(uint32_t));

#ifdef COMMDEBUG
        ST::string ln = ST::format("     <- Int{}[{}]: ", size * 8, count);
        size_t lnbufSize = count * ((size * 2) + 1);
        char* lnbuf = new char[lnbufSize + 1];
        for (size_t i=0; i<count; i++) {
            if (size == 1)
                sprintf(lnbuf + (i * 3), "%02X ", ((uint8_t*)data.fData)[i]);
            else if (size == 2)
                sprintf(lnbuf + (i * 5), "%04X ", ((uint16_t*)data.fData)[i]);
            else if (size == 4)
                sprintf(lnbuf + (i * 9), "%08X ", ((uint32_t*)data.fData)[i]);
        }
        lnbuf[lnbufSize] = 0;
        ln += lnbuf;
        delete[] lnbuf;
        plDebug::Debug(ln.c_str());
#endif
    }
}
开发者ID:Lunanne,项目名称:libhsplasma,代码行数:49,代码来源:pnSocket.cpp

示例15: GetPassword

/*****************************************************************************
 ** pfUnixPasswordStore                                                     **
 *****************************************************************************/
ST::string pfUnixPasswordStore::GetPassword(const ST::string& username)
{
    GError *error = nullptr;
    gchar *password = secret_password_lookup_sync(&pfPasswordStore_Schema,
                            nullptr, &error,
                            "username", username.c_str(),
                            "server", GetServerDisplayName().c_str(),
                            nullptr);

    ST::string result;
    if (error) {
        // Throw away the error and treat it as if no password was found...
        g_error_free(error);
    } else if (password) {
        result = ST::string::from_utf8(password);
        secret_password_free(password);
    }

    return result;
}
开发者ID:Deledrius,项目名称:Plasma,代码行数:23,代码来源:pfPasswordStore_Unix.cpp


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