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


C++ stdString::assign方法代码示例

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


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

示例1: makeDataFileName

void DataWriter::makeDataFileName(int serial, stdString &name)
{
    int  len;
    char buffer[30];    

    if (data_file_name_base.length() > 0)
    {
	name = data_file_name_base;
        if (serial > 0)
        {
            len = snprintf(buffer, sizeof(buffer), "-%d", serial);
            if (len >= (int)sizeof(buffer))
                len = sizeof(buffer)-1;
            name.append(buffer, len);
        }
        return;
    }
    // Else: Create name based on  "<today>[-serial]"
    int year, month, day, hour, min, sec;
    unsigned long nano;
    epicsTime now = epicsTime::getCurrent();    
    epicsTime2vals(now, year, month, day, hour, min, sec, nano);
    if (serial > 0)
        len = snprintf(buffer, sizeof(buffer),
                       "%04d%02d%02d-%d", year, month, day, serial);
    else
        len = snprintf(buffer,sizeof(buffer),
                       "%04d%02d%02d", year, month, day);
    if (len >= (int)sizeof(buffer))
        len = sizeof(buffer)-1;
    name.assign(buffer, len);
}
开发者ID:epicsdeb,项目名称:channelarchiver,代码行数:32,代码来源:DataWriter.cpp

示例2: getState

void CtrlInfo::getState(size_t state, stdString &result) const
{
    size_t len;
    const char *text = getState(state, len);
    if (text)
    {
        result.assign(text, len);
        return;
    }

    char buffer[80];
    sprintf(buffer, "<Undef: %u>", (unsigned int)state);
    result = buffer;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:14,代码来源:CtrlInfo.cpp

示例3: getInfo

bool ArchiveDataClient::getInfo(int &version,
                                stdString &description,
                                stdVector<stdString> &how_strings,
                                stdVector<stdString> &stat_strings,
                                stdVector<SeverityInfo> &sevr_infos)
{
    xmlrpc_value *result, *hows, *stats, *sevrs, *element;
    xmlrpc_int32 num;
    xmlrpc_bool has_value, txt_stat;
    const char   *str;
    size_t       count, len, i;
    result = xmlrpc_client_call(&env, (char *)URL, "archiver.info", "()");
    if (log_fault())
        return false;
    xmlrpc_parse_value(&env, result, "{s:i,s:s#,s:A,s:A,s:A,*}",
                       "ver",  &num,
                       "desc", &str, &len,
                       "how",  &hows,
                       "stat", &stats,
                       "sevr", &sevrs);
    if (log_fault())
        return false;
    version = num;
    description.assign(str, len);
    // 'how' array
    count = xmlrpc_array_size(&env, hows);
    how_strings.reserve(count);
    for (i=0; i<count; ++i)
    {
        element = xmlrpc_array_get_item(&env, hows, i);
        if (log_fault())
            return false;
        xmlrpc_parse_value(&env, element, "s", &str);
        if (log_fault())
            return false;
        how_strings.push_back(stdString(str));
    }
    // 'stat' array
    count = xmlrpc_array_size(&env, stats);
    stat_strings.reserve(count);
    for (i=0; i<count; ++i)
    {
        element = xmlrpc_array_get_item(&env, stats, i);
        if (log_fault())
            return false;
        xmlrpc_parse_value(&env, element, "s", &str);
        if (log_fault())
            return false;
        stat_strings.push_back(stdString(str));
    }
    // 'sevr' array
    count = xmlrpc_array_size(&env, sevrs);
    stat_strings.reserve(count);
    SeverityInfo info;
    for (i=0; i<count; ++i)
    {
        element = xmlrpc_array_get_item(&env, sevrs, i);
        if (log_fault())
            return false;
        xmlrpc_parse_value(&env, element, "{s:i,s:s#,s:b,s:b,*}",
                           "num",  &num,
                           "sevr", &str, &len,
                           "has_value",  &has_value,
                           "txt_stat", &txt_stat);
        if (log_fault())
            return false;
        info.num = num;
        info.text.assign(str, len);
        info.has_value = has_value;
        info.txt_stat = txt_stat;
        sevr_infos.push_back(info);
    }
    xmlrpc_DECREF(result);
    return true;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:75,代码来源:ArchiveDataClient.cpp


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