コード例 #1
0
void Region::mergeRegion(Region *src)
{
    assert(src != NULL);

    if (src == _left)
    {
        pairHor(src->_left, this);
        _bbox.a.x = src->_bbox.a.x;
    }
    else if (src == _right)
    {
        pairHor(this, src->_right);
        _bbox.b.x = src->_bbox.b.x;
    }
    else if (src == _up)
    {
        pairVer(src->_up, this);
        _bbox.a.y = src->_bbox.a.y;
    }
    else if (src == _down)
    {
        pairVer(this, src->_down);
        _bbox.b.y = src->_bbox.b.y;
    }
    else
    {
        fprintf(stderr, "Error: Avoid::Region::merge(): "
                "Argument not adjoining region.\n");
        abort();
    }
    mergeAttributes(src);
    printf("DEL %p\n", src);
    delete src;
}
コード例 #2
0
ファイル: SettingsManager.cpp プロジェクト: chhawk/MyGUI
	void SettingsManager::mergeNodes(pugi::xml_node _nodeTarget, pugi::xml_node _nodeSource)
	{
		bool listElement = MyGUI::utility::endWith(_nodeTarget.name(), ".List");

		// затираем текст у цели потому что любое значение текста источника является конечным
		pugi::xml_node targetTextNode = _nodeTarget.first_child();
		if (!targetTextNode.empty() && targetTextNode.type() == pugi::node_pcdata)
			targetTextNode.set_value("");

		pugi::xml_node sourceTextNode = _nodeSource.first_child();
		if (!sourceTextNode.empty() && sourceTextNode.type() == pugi::node_pcdata)
		{
			targetTextNode = _nodeTarget.first_child();
			if (targetTextNode.empty())
				targetTextNode = _nodeTarget.append_child(pugi::node_pcdata);
			targetTextNode.set_value(sourceTextNode.value());
		}

		for (pugi::xml_node::iterator child = _nodeSource.begin(); child != _nodeSource.end(); child ++)
		{
			if ((*child).type() != pugi::node_element)
				continue;

			pugi::xml_node targetChildNode;

			if (listElement)
			{
				targetChildNode = _nodeTarget.append_child((*child).name());
			}
			else
			{
				targetChildNode = _nodeTarget.child((*child).name());
				if (targetChildNode.empty())
					targetChildNode = _nodeTarget.append_child((*child).name());
			}

			mergeAttributes(targetChildNode, (*child));
			mergeNodes(targetChildNode, (*child));
		}
	}