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


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

本文整理汇总了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);
    }
}
开发者ID:niemyjski,项目名称:cli,代码行数:15,代码来源:utils.cpp

示例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;
}
开发者ID:krwq,项目名称:cli-1,代码行数:48,代码来源:tpafile.cpp


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