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


C++ CL_DomNode::get_node_name方法代码示例

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


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

示例1: loadBoundsElement

void Level::loadBoundsElement(const CL_DomNode &p_boundsNode)
{
	const CL_DomNodeList boundList = p_boundsNode.get_child_nodes();
	const int boundListSize = boundList.get_length();

	for (int i = 0; i < boundListSize; ++i) {
		const CL_DomNode boundNode = boundList.item(i);

		if (boundNode.get_node_name() == "bound") {
			CL_DomNamedNodeMap attrs = boundNode.get_attributes();

			float x1 = CL_StringHelp::local8_to_float(attrs.get_named_item("x1").get_node_value());
			float y1 = CL_StringHelp::local8_to_float(attrs.get_named_item("y1").get_node_value());
			float x2 = CL_StringHelp::local8_to_float(attrs.get_named_item("x2").get_node_value());
			float y2 = CL_StringHelp::local8_to_float(attrs.get_named_item("y2").get_node_value());

			x1 *= Block::WIDTH;
			y1 *= Block::WIDTH;
			x2 *= Block::WIDTH;
			y2 *= Block::WIDTH;

			cl_log_event("debug", "Loading bound %1 x %2 -> %3 x %4", x1, y1, x2, y2);

			const CL_LineSegment2f segment(CL_Pointf(x1, y1), CL_Pointf(x2, y2));
			m_bounds.push_back(CL_SharedPtr<Bound>(new Bound(segment)));
		} else {
			cl_log_event("race", "Unknown node '%1', ignoring", boundNode.get_node_name());
		}
	}
}
开发者ID:ryba616,项目名称:ryba.racer,代码行数:30,代码来源:Level.cpp

示例2: process_resource

void TexturePacker::process_resource(CL_Resource &item_resource, std::vector<CL_Subtexture> &packed_sub_textures, std::map<CL_Texture, CL_String> &generated_texture_filenames, int &generated_texture_index, const CL_String &image_pathname )
{
	// Found a sprite resource, lets modify its content!
	CL_Resource resource = item_resource;

	// Iterate through all nodes, and remove all previous image tags
	CL_DomElement &element = resource.get_element();
	CL_DomNode cur = element.get_first_child();
	while (!cur.is_null())
	{
		CL_DomNode next = cur.get_next_sibling();
		CL_DomNode::NodeType nodeType = (CL_DomNode::NodeType)cur.get_node_type();

		// Only remove the <image> tag, as we want to keep the other sprite attributes
		if (cur.get_node_name() == "image")
			element.remove_child(cur);

		cur = next;
	}

	// Add new image tag to resource DOM
	std::vector<CL_Subtexture>::size_type index, size;
	size = packed_sub_textures.size();
	for(index = 0; index < size; ++index)
	{
		CL_Subtexture subtexture = packed_sub_textures[index];

		// Try to find out if we already have created a texture-on-disk for this subtexture
		CL_String texture_filename;
		CL_Texture texture = subtexture.get_texture();
		std::map<CL_Texture, CL_String>::iterator it;
		it = generated_texture_filenames.find(texture);
		if(it == generated_texture_filenames.end())
		{
			// Texture not found, generate a filename and dump texture to disk
			texture_filename = cl_format("texture%1.png", ++generated_texture_index);
			CL_PNGProvider::save(texture.get_pixeldata(), image_pathname + texture_filename);
			generated_texture_filenames[texture] = texture_filename;
		}
		else
		{
			// Previously dumped textures, lets reuse the filename
			texture_filename = (*it).second;
		}

		// Add <grid> DOM element
		CL_DomElement new_grid_element = element.get_owner_document().create_element("grid");
		new_grid_element.set_attribute("pos", cl_format("%1,%2", subtexture.get_geometry().left + last_border_size, subtexture.get_geometry().top + last_border_size));
		new_grid_element.set_attribute("size", cl_format("%1,%2", subtexture.get_geometry().get_width()- last_border_size*2, subtexture.get_geometry().get_height()- last_border_size*2));

		// Add <image> DOM element
		CL_DomElement new_image_element = element.get_owner_document().create_element("image");
		new_image_element.set_attribute("file", texture_filename);
		new_image_element.append_child(new_grid_element);

		// Add <image> element under <sprite> element
		element.append_child(new_image_element);
	}
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:59,代码来源:texture_packer.cpp

示例3: named_item

CL_DomNode CL_DomNode::named_item(const CL_DomString &name) const
{
	CL_DomNode node = get_first_child();
	while (node.is_null() == false)
	{
		if (node.get_node_name() == name) return node;
		node = node.get_next_sibling();
	}
	return CL_DomNode();
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:10,代码来源:dom_node.cpp

示例4: cloneElement

//рекурсивное клонирование XML-элемента
CL_DomElement cloneElement(CL_DomElement &element, CL_DomDocument &doc)
{
	//создаем элемент-клон
	CL_DomElement clone(doc, element.get_tag_name());

	//копируем атрибуты
	CL_DomNamedNodeMap attributes = element.get_attributes();
	unsigned long length = attributes.get_length();
	for (unsigned long i = 0; i < length; ++i)
	{
		CL_DomNode attr = attributes.item(i);
		clone.set_attribute(attr.get_node_name(), attr.get_node_value());
	}

	//рекурсивно копируем дочерние элементы
	for (CL_DomElement child = element.get_first_child_element(); !child.is_null(); child = child.get_next_sibling_element())
		clone.append_child(cloneElement(child, doc));

	//возвращаем клонированный элемент
	return clone;
}
开发者ID:ermachkov,项目名称:bmgui,代码行数:22,代码来源:main.cpp

示例5: main

int ConsoleProgram::main(const std::vector<CL_String> &args)
{
	// Setup clanCore:
	CL_SetupCore setup_core;

	// Initialize the ClanLib display component
	CL_SetupDisplay setup_display;

	// Create a console Window if one does not exist:
	CL_ConsoleWindow console_window("Console", 80, 600);

try
{	
	//получение параметра запуска
	for (std::vector<CL_String>::const_iterator iter_args = args.begin(); iter_args != args.end(); ++iter_args)
		CL_Console::write_line( *iter_args );

	//получение имени директории для сохранения
	CL_String workDirectoryName;
	if (args.size() > 1)
	{
		//полное имя рабочей директории
		workDirectoryName = args[1];
		//конвертирование из CP-1251 в UTF-8 имени рабочей директории
		workDirectoryName = decode(workDirectoryName);
	}
	else
	{
		//получение полного пути к текущему каталогу
		workDirectoryName = CL_Directory::get_current();
	}

	CL_Console::write_line("workDirectoryName: %1", workDirectoryName);
	//получение имени последней директории
	CL_String locationName = CL_PathHelp::remove_trailing_slash(workDirectoryName);
	locationName = CL_PathHelp::get_filename(locationName);
	CL_Console::write_line("locationName: %1", locationName);

	CL_String tempDir = CL_PathHelp::add_trailing_slash(workDirectoryName) + "temp\\";
	CL_DirectoryScanner directoryScanner;
	directoryScanner.scan(tempDir, "*.export");
	while (directoryScanner.next())
	{
		//имя обрабатываемого файла
		CL_String fileName;

		if (directoryScanner.is_directory())
			continue;
		//получение полного имени файла экспорта
		fileName = directoryScanner.get_pathname();
		//конвертирование из CP-1251 в UTF-8
		fileName = decode(fileName);
		CL_Console::write_line("find: %1", fileName);

		//открытие XML файла
		CL_File fileXML;
		bool is_opened = fileXML.open(fileName);
		if( !is_opened )
			return PrintError( CL_String("Can't open file: ") + fileName );

		//Создание объекта DOM парсера
		CL_DomDocument document(fileXML);
		//получение root узла
		CL_DomElement root = document.get_document_element();
		if( root.get_local_name() != "resources")
		{
			CL_Console::write_line("Root name can't be: %1", root.get_local_name().c_str());
			return PrintError("");
		}

		//цикл по потомкам "resources"
		for (CL_DomNode cur = root.get_first_child(); !cur.is_null(); cur = cur.get_next_sibling())
		{
			//загрузка только спрайтов
			if (cur.get_node_name() != "sprite")
				continue;

			CL_DomElement element = cur.to_element();

			//проверка на обязательные параметры
			if (!element.has_attribute("name"))
				return PrintError("Error: can't find parametr \"name\"");

			CL_DomString name = element.get_attribute("name");
			int x = element.get_attribute_int("x");
			int y = element.get_attribute_int("y");
			//добавление спрайта
			sprites.push_back( S_Sprite(name, CL_Vec2i(x, y) ) );

			//цикл по "image" (формирование списка имен файлов)
			for (CL_DomNode cur_image = cur.get_first_child(); !cur_image.is_null(); cur_image = cur_image.get_next_sibling())
			{
				//загрузка только image
				if (cur_image.get_node_name() != "image")
					continue;
				
				CL_DomElement element_image = cur_image.to_element();
				CL_DomString file = element_image.get_attribute("file");
				
				//конвертирование из CP-1251 в UTF-8 имени файла изображения
//.........这里部分代码省略.........
开发者ID:ermachkov,项目名称:bmgui,代码行数:101,代码来源:main.cpp

示例6: loadTrackElement

void Level::loadTrackElement(const CL_DomNode &p_trackNode)
{
	// build block type map
	typedef std::map<CL_String, Common::GroundBlockType> blockMap_t;
	blockMap_t blockMap;
	blockMap_t::iterator blockMapItor;

	blockMap["vert"] = Common::BT_STREET_VERT;
	blockMap["horiz"] = Common::BT_STREET_HORIZ;
	blockMap["turn_bottom_right"] = Common::BT_TURN_BOTTOM_RIGHT;
	blockMap["turn_bottom_left"] = Common::BT_TURN_BOTTOM_LEFT;
	blockMap["turn_top_right"] = Common::BT_TURN_TOP_RIGHT;
	blockMap["turn_top_left"] = Common::BT_TURN_TOP_LEFT;
	blockMap["start_line_up"] = Common::BT_START_LINE_UP;

	// prepare level blocks
	const int blocksCount = m_width * m_height;
	m_blocks.clear();
	m_blocks.reserve(blocksCount);

	for (int i = 0; i < blocksCount; ++i) {
		m_blocks.push_back(CL_SharedPtr<Block>(new Block(Common::BT_GRASS)));
	}

	// create global resistance geometry
	CL_SharedPtr<RaceResistance::Geometry> globalResGeom(new RaceResistance::Geometry());
	globalResGeom->addRectangle(CL_Rectf(real(0), real(0), real(m_width), real(m_height)));

	m_resistanceMap.addGeometry(globalResGeom, 0.3f);

	// add sand resistance
	foreach (const Sandpit &sandpit, m_sandpits) {
		const unsigned circleCount = sandpit.getCircleCount();

		CL_SharedPtr<RaceResistance::Geometry> sandpitGeometry(new RaceResistance::Geometry());

		for (unsigned i = 0; i < circleCount; ++i) {
			// sandpit values are real
			const Sandpit::Circle &circle = sandpit.circleAt(i);
			sandpitGeometry->addCircle(CL_Circlef(circle.getCenter().x, circle.getCenter().y, circle.getRadius()));
		}

		m_resistanceMap.addGeometry(sandpitGeometry, 0.8f);
	}

	// read blocks
	const CL_DomNodeList blockList = p_trackNode.get_child_nodes();
	const int blockListSize = blockList.get_length();

	cl_log_event("debug", "Track node child count: %1", blockListSize);

	CL_Pointf lastCP; // last checkpoint

	for (int i = 0; i < blockListSize; ++i) {
		const CL_DomNode blockNode = blockList.item(i);

		if (blockNode.get_node_name() == "block") {
			CL_DomNamedNodeMap attrs = blockNode.get_attributes();

			const int x = CL_StringHelp::local8_to_int(attrs.get_named_item("x").get_node_value());
			const int y = CL_StringHelp::local8_to_int(attrs.get_named_item("y").get_node_value());
			const CL_String typeStr = attrs.get_named_item("type").get_node_value();

			if (x < 0 || y < 0 || x >= m_width || y >= m_height) {
				cl_log_event("debug", "coords x=%1, y=%2", x, y);
				throw CL_Exception("Blocks coords out of bounds");
			}

			blockMapItor = blockMap.find(typeStr);

			if (blockMapItor != blockMap.end()) {

				const Common::GroundBlockType blockType = blockMapItor->second;
				m_blocks[m_width * y + x]->setType(blockType);

				// add checkpoint to track
				if (blockType == Common::BT_START_LINE_UP) {
					lastCP = CL_Pointf((x + 0.5f) * Block::WIDTH, (y + 0.2f) * Block::WIDTH);
					const CL_Pointf firstCP((x + 0.5f) * Block::WIDTH, (y + 0.2 - 0.01f) * Block::WIDTH);

					m_track.addCheckpointAtPosition(firstCP);
				} else {
					const CL_Pointf checkPosition((x + 0.5f) * Block::WIDTH, (y + 0.5f) * Block::WIDTH);

					m_track.addCheckpointAtPosition(checkPosition);
				}

				// add resistance geometry based on block
				CL_SharedPtr<RaceResistance::Geometry> resGeom = buildResistanceGeometry(x, y, blockType);
				m_resistanceMap.addGeometry(resGeom, 0.0f);

			} else {
				cl_log_event("race", "Unknown block type: %1", typeStr);
			}

		} else {
			cl_log_event("race", "Unknown node '%1', ignoring", blockNode.get_node_name());
		}

	}
//.........这里部分代码省略.........
开发者ID:ryba616,项目名称:ryba.racer,代码行数:101,代码来源:Level.cpp

示例7: import_node

CL_DomNode CL_DomDocument::import_node(const CL_DomNode &node, bool deep)
{
	CL_DomNode imported_node;
	switch (node.get_node_type())
	{
	case NULL_NODE:
		return imported_node;
	case ELEMENT_NODE:
		imported_node = create_element_ns(node.get_namespace_uri(), node.get_node_name());
		break;
	case ATTRIBUTE_NODE:
		imported_node = create_attribute_ns(node.get_namespace_uri(), node.get_node_name());
		imported_node.set_node_value(node.get_node_value());
		break;
	case TEXT_NODE:
		imported_node = create_text_node(node.get_node_value());
		break;
	case CDATA_SECTION_NODE:
		imported_node = create_cdata_section(node.get_node_value());
		break;
	case ENTITY_REFERENCE_NODE:
		imported_node = create_entity_reference(node.get_node_name());
		break;
	case ENTITY_NODE:
		return imported_node;
	case PROCESSING_INSTRUCTION_NODE:
		imported_node = create_processing_instruction(node.to_processing_instruction().get_target(), node.to_processing_instruction().get_data());
		break;
	case COMMENT_NODE:
		imported_node = create_comment(node.get_node_value());
		break;
	case DOCUMENT_NODE:
		imported_node = create_document_fragment();
		break;
	case DOCUMENT_TYPE_NODE:
		return imported_node;
	case DOCUMENT_FRAGMENT_NODE:
		imported_node = create_document_fragment();
		break;
	case NOTATION_NODE:
		return imported_node;
	}

	if (node.is_element())
	{
		CL_DomElement import_element = imported_node.to_element();
		CL_DomNamedNodeMap node_attributes = node.get_attributes();
		int size = node_attributes.get_length();
		for (int index = 0; index < size; index++)
		{
			CL_DomNode attr = node_attributes.item(index);
			import_element.set_attribute_node_ns(import_node(attr, deep).to_attr());
		}
	}

	if (deep)
	{
		CL_DomNode cur = node.get_first_child();
		while (!cur.is_null())
		{
			imported_node.append_child(import_node(cur, true));
			cur = cur.get_next_sibling();
		}
	}

	return imported_node;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:67,代码来源:dom_document.cpp


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