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


C++ string_ref::starts_with方法代码示例

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


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

示例1: pdibuf

/* irc_inline() - 1 single line received from serv */
void
server::p_inline (const boost::string_ref& text)
{
	session *sess;
	char *type;
	char *word[PDIWORDS+1];
	char *word_eol[PDIWORDS+1];
	message_tags_data tags_data = message_tags_data();

	std::string pdibuf(text.size(), '\0');

	sess = this->front_session;

	/* Python relies on this */
	word[PDIWORDS] = NULL;
	word_eol[PDIWORDS] = NULL;
	std::string buf;
	if (text.starts_with('@'))
	{
		auto sep = text.find_first_of(' ');
		if (sep == boost::string_ref::npos)
			return;
		
		/* skip the '@' */
		auto tags = text.substr(1, sep - 1);
		
		buf = text.substr(sep + 1).to_string();

		handle_message_tags(*this, tags, tags_data);
	}
	else
	{
		buf = text.to_string();
	}

	url_check_line(buf.data(), buf.size());

	/* split line into words and words_to_end_of_line */
	process_data_init (&pdibuf[0], &buf[0], word, word_eol, false, false);

	if (buf[0] == ':')
	{
		/* find a context for this message */
		if (this->is_channel_name (word[3]))
		{
			auto tmp = find_channel (word[3]);
			if (tmp)
				sess = &(*tmp);
		}

		/* for server messages, the 2nd word is the "message type" */
		type = word[2];

		word[0] = type;
		word_eol[1] = &buf[0];	/* keep the ":" for plugins */

		if (plugin_emit_server(sess, type, word, word_eol,
			tags_data.timestamp))
		{
			return;
		}

		word[1]++;
		word_eol[1] = &buf[1];	/* but not for HexChat internally */

	} else
	{
		word[0] = type = word[1];

		if (plugin_emit_server(sess, type, word, word_eol,
			tags_data.timestamp))
		{
			return;
		}
	}

	if (buf[0] != ':')
	{
		process_named_servermsg (sess, &buf[0], word[0], word_eol, &tags_data);
		return;
	}

	/* see if the second word is a numeric */
	std::locale locale;
	if (std::isdigit (word[2][0], locale))
	{
		char* t = word_eol[4];
		if (*t == ':')
			t++;

		process_numeric (sess, atoi (word[2]), word, word_eol, t, &tags_data);
	} else
	{
		process_named_msg (sess, type, word, word_eol, &tags_data);
	}
}
开发者ID:sehe,项目名称:hexchat,代码行数:97,代码来源:proto-irc.cpp


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