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


C++ Counter::AddCounterValues方法代码示例

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


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

示例1: AddCounterValues

OP_STATUS Counters::AddCounterValues(OpString& counter_str, HTML_Element* element, short counter_type, const uni_char* counter_value)
{
	if (counter_value)
	{
		const uni_char* name = counter_value;
		unsigned int name_length = 0;

		// The css parser should have stripped off the leading whitespaces.
		OP_ASSERT(!css_is_space(*name));

		const uni_char* style = name;
		unsigned int style_length = 0;

		/* 'delimiter' corresponds to the 'string' argument of the
		   counters function in the CSS 2.1. */
		const uni_char* delimiter = NULL;
		unsigned int delimiter_length = 0;

		if (counter_type == CSS_FUNCTION_COUNTERS)
		{
			delimiter = name;

			while (*delimiter && !css_is_space(*delimiter) && *delimiter != ',')
				delimiter++;

			BOOL comma_found = (*delimiter == ',');

			name_length = delimiter++ - name;

			while (css_is_space(*delimiter))
				delimiter++;

			if (!comma_found)
			{
				if (*delimiter && *delimiter != ',')
					return OpStatus::OK;

				while (css_is_space(*++delimiter))
					;
			}

			uni_char quote_char = *delimiter++;
			if (quote_char != '"' && quote_char != '\'')
				return OpStatus::OK;

			style = delimiter;
			while (*style && (*style != quote_char || *(style-1) == '\\'))
				style++;
			if (*style != quote_char)
				return OpStatus::OK;

			delimiter_length = style++ - delimiter;
		}
		else
		{
			while (*style && !css_is_space(*style) && *style != ',')
				style++;

			name_length = style - name;
		}

		while (*style && (css_is_space(*style) || *style == ','))
			style++;

		const uni_char* end = style;

		while (*end && !css_is_space(*end) && *end != ',')
			end++;

		OP_ASSERT(*end == 0);
		style_length = end - style;

		short style_type = CSS_VALUE_decimal;
		if (*style)
		{
			short keyword = CSS_GetKeyword(style, style_length);
			if (CSS_is_list_style_type_val(keyword) || keyword == CSS_VALUE_none)
				style_type = keyword;
		}

		Counter* counter = GetCounter(name, name_length);

		if (counter)
			return counter->AddCounterValues(counter_str, element, delimiter, delimiter_length, style_type, add_only);
		else
		{
			uni_char number_buf[TMPSTRING_SIZE]; /* ARRAY OK 2009-05-11 davve */

			MakeListNumberStr(0, style_type, NULL, number_buf, TMPSTRING_SIZE-1); //FIXME rtl??
			return counter_str.Append(number_buf);
		}
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:95,代码来源:counters.cpp


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