本文整理汇总了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);
}
示例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;
}
示例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;
}