本文整理汇总了C++中pal::string_t::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ string_t::assign方法的具体用法?C++ string_t::assign怎么用?C++ string_t::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal::string_t
的用法示例。
在下文中一共展示了string_t::assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: append_path
void append_path(pal::string_t& path1, const pal::char_t* path2)
{
if (pal::is_path_rooted(path2))
{
path1.assign(path2);
}
else
{
if (path1.back() != DIR_SEPARATOR)
{
path1.push_back(DIR_SEPARATOR);
}
path1.append(path2);
}
}
示例2: read_field
bool read_field(pal::string_t line, int& offset, pal::string_t& value_recv)
{
// The first character should be a '"'
if (line[offset] != '"')
{
trace::error(_X("error reading TPA file"));
return false;
}
offset++;
// Set up destination buffer (it can't be bigger than the original line)
pal::char_t buf[PATH_MAX];
auto buf_offset = 0;
// Iterate through characters in the string
for (; offset < line.length(); offset++)
{
// Is this a '\'?
if (line[offset] == '\\')
{
// Skip this character and read the next character into the buffer
offset++;
buf[buf_offset] = line[offset];
}
// Is this a '"'?
else if (line[offset] == '\"')
{
// Done! Advance to the pointer after the input
offset++;
break;
}
else
{
// Take the character
buf[buf_offset] = line[offset];
}
buf_offset++;
}
buf[buf_offset] = '\0';
value_recv.assign(buf);
// Consume the ',' if we have one
if (line[offset] == ',')
{
offset++;
}
return true;
}