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


C++ CL_StringRef类代码示例

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


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

示例1: next_line

void CL_SpanLayout_Impl::next_line(CurrentLine &current_line)
{
	current_line.cur_line.width = current_line.x_position;
	for (std::vector<LineSegment>::reverse_iterator it = current_line.cur_line.segments.rbegin(); it != current_line.cur_line.segments.rend(); ++it)
	{
		LineSegment &segment = *it;
		if (segment.type == object_text)
		{
			CL_StringRef s = text.substr(segment.start, segment.end-segment.start);
			if (s.find_first_not_of(" \t\r\n") != CL_StringRef::npos)
			{
				current_line.cur_line.width = segment.x_position + segment.width;
				break;
			}
		}
		else
		{
			current_line.cur_line.width = segment.x_position + segment.width;
			break;
		}
	}

	int height = current_line.cur_line.height;
	lines.push_back(current_line.cur_line);
	current_line.cur_line = Line();
	current_line.x_position = 0;
	current_line.y_position += height;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:28,代码来源:span_layout_impl.cpp

示例2: while

CL_DomString CL_DomElement::get_attribute_ns(
	const CL_DomString &namespace_uri,
	const CL_DomString &local_name,
	const CL_DomString &default_value) const
{
	if (impl)
	{
		CL_DomDocument_Generic *doc_impl = (CL_DomDocument_Generic *) impl->owner_document.lock().get();
		const CL_DomTreeNode *tree_node = impl->get_tree_node();
		unsigned int cur_index = tree_node->first_attribute;
		const CL_DomTreeNode *cur_attribute = tree_node->get_first_attribute(doc_impl);
		while (cur_attribute)
		{
			CL_StringRef lname = cur_attribute->get_node_name();
			CL_StringRef::size_type lpos = lname.find_first_of(':');
			if (lpos != CL_StringRef::npos)
				lname = lname.substr(lpos + 1);

			if (cur_attribute->get_namespace_uri() == namespace_uri && lname == local_name)
				return cur_attribute->get_node_value();

			cur_index = cur_attribute->next_sibling;
			cur_attribute = cur_attribute->get_next_sibling(doc_impl);
		}
		return default_value;
	}
	return default_value;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:28,代码来源:dom_element.cpp

示例3: get_type

CL_StringRef CL_CSSSelector::get_type(const CL_StringRef &path_element)
{
	CL_StringRef::size_type pos = path_element.find_first_of(".#:");
	if (pos == CL_StringRef::npos)
		return path_element;
	else
		return path_element.substr(0, pos);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:8,代码来源:css_selector.cpp

示例4: CL_StringRef

CL_StringRef CL_CSSSelector::get_state(const CL_StringRef &path_element)
{
	CL_StringRef::size_type pos1 = path_element.find_first_of(':');
	if (pos1 == CL_StringRef::npos)
		return CL_StringRef();
	CL_StringRef::size_type pos2 = path_element.find_first_of(".#", pos1);
	if (pos2 == CL_StringRef::npos)
		return path_element.substr(pos1);
	else
		return path_element.substr(pos1, pos2 - pos1);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:11,代码来源:css_selector.cpp

示例5: get_name_index

int CL_PgsqlReaderProvider::get_name_index(const CL_StringRef &name) const
{
	int index = PQfnumber(result, name.c_str());
	if (index < 0)
		throw CL_Exception(cl_format("No such column name %1", name));
	return index;
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:7,代码来源:pgsql_reader_provider.cpp

示例6: set_value_int

void CL_RegistryKey::set_value_int(const CL_StringRef &name, int value)
{
	DWORD v = value;
	LONG result = RegSetValueEx(impl->key, name.empty() ? 0 : CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, REG_DWORD, (const BYTE *) &v, sizeof(DWORD));
	if (result != ERROR_SUCCESS)
		throw CL_Exception(cl_format("Unable to set registry key value %1", name));
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:7,代码来源:registry_key.cpp

示例7: insert_glyph

void CL_GlyphCache::insert_glyph(CL_FontEngine *font_engine, CL_GraphicContext &gc, const CL_StringRef &text)
{
	for (CL_String::size_type p = 0; p < text.length(); ++p)
	{
		insert_glyph(font_engine, gc, text[p]);
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:7,代码来源:glyph_cache.cpp

示例8: begin_file

void CL_ZipWriter::begin_file(const CL_StringRef &filename, bool compress)
{
	if (impl->file_begun)
		throw CL_Exception("CL_ZipWriter already writing a file");
	impl->file_begun = true;

	impl->uncompressed_length = 0;
	impl->compressed_length = 0;
	impl->compress = compress;
	impl->crc32 = CL_ZIP_CRC_START_VALUE;

	impl->local_header_offset = impl->output.get_position();
	impl->local_header = CL_ZipLocalFileHeader();
	impl->local_header.version_needed_to_extract = 20;
	if (impl->storeFilenamesAsUTF8)
		impl->local_header.general_purpose_bit_flag = CL_ZIP_USE_UTF8;
	else
		impl->local_header.general_purpose_bit_flag = 0;
	impl->local_header.compression_method = compress ? zip_compress_deflate : zip_compress_store;
	CL_ZipArchive_Impl::calc_time_and_date(
		impl->local_header.last_mod_file_date,
		impl->local_header.last_mod_file_time);
	impl->local_header.crc32 = 0;
	impl->local_header.uncompressed_size = 0;
	impl->local_header.compressed_size = 0;
	impl->local_header.file_name_length = filename.length();
	impl->local_header.filename = filename;

	if (!impl->storeFilenamesAsUTF8) // Add UTF-8 as extra field if we aren't storing normal UTF-8 filenames
	{
		// -Info-ZIP Unicode Path Extra Field (0x7075)
		CL_String8 filename_cp437 = CL_StringHelp::text_to_cp437(filename);
		CL_String8 filename_utf8 = CL_StringHelp::text_to_utf8(filename);
		CL_DataBuffer unicode_path(9 + filename_utf8.length());
		cl_ubyte16 *extra_id = (cl_ubyte16 *) (unicode_path.get_data());
		cl_ubyte16 *extra_len = (cl_ubyte16 *) (unicode_path.get_data() + 2);
		cl_ubyte8 *extra_version = (cl_ubyte8 *) (unicode_path.get_data() + 4);
		cl_ubyte32 *extra_crc32 = (cl_ubyte32 *) (unicode_path.get_data() + 5);
		*extra_id = 0x7075;
		*extra_len = 5 + filename_utf8.length();
		*extra_version = 1;
		*extra_crc32 = CL_ZipArchive_Impl::calc_crc32(filename_cp437.data(), filename_cp437.size());
		memcpy(unicode_path.get_data() + 9, filename_utf8.data(), filename_utf8.length());
		impl->local_header.extra_field_length = unicode_path.get_size();
		impl->local_header.extra_field = unicode_path;
	}

	impl->local_header.save(impl->output);

	if (compress)
	{
		memset(&impl->zs, 0, sizeof(z_stream));
		int result = deflateInit2(&impl->zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); // Undocumented: if wbits is negative, zlib skips header check
		if (result != Z_OK)
			throw CL_Exception("Zlib deflateInit failed for zip index!");
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:57,代码来源:zip_writer.cpp

示例9: CL_StringRef

inline CL_StringRef CL_XMLTokenizer_Generic::trim_whitespace(const CL_StringRef &text)
{
	CL_StringRef::size_type pos_start = text.find_first_not_of(" \t\r\n");
	if (pos_start == CL_StringRef::npos)
		return CL_StringRef();
	CL_StringRef::size_type pos_end = text.find_last_not_of(" \t\r\n", pos_start);
	if (pos_end == CL_StringRef::npos)
	{
		if (pos_start == 0)
			return text;
		else
			return string_allocator.alloc(text.substr(pos_start));
	}
	else
	{
		return string_allocator.alloc(text.substr(pos_start, pos_end - pos_start + 1));
	}
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:18,代码来源:xml_tokenizer.cpp

示例10: amp

CL_StringRef CL_XMLWriter_Generic::insert_escapes_fast(const CL_StringRef &str)
{
	static CL_StringRef const amp("&amp;");
	static CL_StringRef const quot("&quot;");
	static CL_StringRef const apos("&apos;");
	static CL_StringRef const lt("&lt;");
	static CL_StringRef const gt("&gt;");

	escaped_string = str;
	CL_StringRef::size_type pos = 0;
	while (pos < escaped_string.size())
	{
		switch(escaped_string[pos])
		{
		case '&':
			escaped_string.replace(pos, 1, amp);
			pos += amp.size();
			break;
		case '\'':
			escaped_string.replace(pos, 1, apos);
			pos += apos.size();
			break;
		case '\"':
			escaped_string.replace(pos, 1, quot);
			pos += quot.size();
			break;
		case '<':
			escaped_string.replace(pos, 1, lt);
			pos += lt.size();
			break;
		case '>':
			escaped_string.replace(pos, 1, gt);
			pos += gt.size();
			break;
		default:
			++pos;
			break;
		}
	}
	return escaped_string;
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:41,代码来源:xml_writer.cpp

示例11: set_arg

void CL_StringFormat::set_arg(int index, const CL_StringRef &text)
{
	if (index >= (int) args.size())
		return;
		
	ArgPosition pos = args[index];
	if (pos.length == 0)
		return;
		
	int delta_size = ((int) text.length()) - pos.length;
	string = string.substr(0, pos.start) + text + string.substr(pos.start + pos.length);
	args[index].length = text.length();
	
	std::vector<ArgPosition>::size_type i, size;
	size = args.size();
	for (i = 0; i < size; i++)
	{
		if (args[i].start > pos.start)
			args[i].start += delta_size;
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:21,代码来源:string_format.cpp

示例12: while

inline void CL_XMLTokenizer_Generic::unescape(CL_StringRef &text, const CL_StringRef &search, CL_String::char_type replace)
{
	CL_StringRef::size_type read_pos = 0;
	CL_StringRef::size_type length = text.length();
	CL_StringRef::size_type search_length = search.length();
	CL_StringRef::char_type *data = text.data();
	while (true)
	{
		CL_StringRef::size_type next_match = text.find(search, read_pos);
		if (next_match == CL_StringRef::npos)
			break;

		CL_StringRef::size_type copy_size = length - (next_match + search_length);
		memcpy(data + next_match + 1, data + next_match + search_length, copy_size * sizeof(CL_StringRef::char_type));
		data[next_match] = replace;
		length -= search_length - 1;
		read_pos = next_match + 1;
		if (read_pos > length)
			break;
	}
	text.set_length(length);
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:22,代码来源:xml_tokenizer.cpp

示例13: write

void CL_Console::write(const CL_StringRef &text)
{
#ifdef WIN32
    /*
    	Do not replace WriteConsole with the commented WriteFile code unless you
    	really know what you are doing and understand when ANSI code pages are used and
    	when OEM code pages are used.  -- mbn 29. jan 2008

    CL_String8 t = CL_StringHelp::text_to_local8(text);
    DWORD written = 0;
    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), t.data(), t.length(), &written, 0);
    */

    DWORD written = 0;

    CL_String16 str = CL_StringHelp::utf8_to_ucs2(text);
    WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str.c_str(), str.length(), &written, 0);

#else
    ::write(1, text.data(), text.length());
#endif
}
开发者ID:andrew889,项目名称:proton_cm_open,代码行数:22,代码来源:console.cpp

示例14: RegQueryValueEx

std::vector<CL_String> CL_RegistryKey::get_value_multi_string(const CL_StringRef &name, const std::vector<CL_String> &default_value) const
{
	DWORD type = 0, size_data = 0;
	LONG result = RegQueryValueEx(impl->key, CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, &type, 0, &size_data);
	if (result != ERROR_SUCCESS || type != REG_MULTI_SZ)
		return default_value;

	CL_DataBuffer buffer(size_data);
	size_data = buffer.get_size();
	result = RegQueryValueEx(impl->key, CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, &type, (LPBYTE) buffer.get_data(), &size_data);
	if (result != ERROR_SUCCESS || type != REG_MULTI_SZ)
		return default_value;

	std::vector<CL_String> results;
	TCHAR *pos = (TCHAR *) buffer.get_data();
	while (*pos != 0)
	{
		CL_StringRef s = pos;
		results.push_back(s);
		pos += s.length()+1;
	}

	return results;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:24,代码来源:registry_key.cpp

示例15: style_load_until

unsigned int CL_CSSDocument_Impl::style_load_until(const CL_StringRef::char_type *chars, const CL_StringRef &style_text, unsigned int pos)
{
	bool quotes1 = false;
	bool quotes2 = false;
	int level = 0;
	while (pos < style_text.length())
	{
		if (level == 0 && quotes1 == false && quotes2 == false)
		{
			for (int i = 0; chars[i] != 0; i++)
			{
				if (style_text[pos] == chars[i])
					return pos;
			}
		}

		switch (style_text[pos++])
		{
		case '"':
			quotes1 = !quotes1;
			break;
		case '\'':
			quotes2 = !quotes2;
			break;
		case '(':
		case '{':
		case '[':
			if (quotes1 || quotes2)
				break;
			level++;
			break;
		case ')':
		case '}':
		case ']':
			if (quotes1 || quotes2)
				break;
			level--;
			break;
		case '\\':
			pos++;
			break;
		}
	}
	return pos;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:45,代码来源:css_document_impl.cpp


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