Exemplo n.º 1
0
void
TextTrieMap::search(CharacterNode *node, const UnicodeString &text, int32_t start,
                  int32_t index, TextTrieMapSearchResultHandler *handler, UErrorCode &status) const {
    if (U_FAILURE(status)) {
        return;
    }
    if (node->hasValues()) {
        if (!handler->handleMatch(index - start, node, status)) {
            return;
        }
        if (U_FAILURE(status)) {
            return;
        }
    }
    UChar32 c = text.char32At(index);
    if (fIgnoreCase) {
        // size of character may grow after fold operation
        UnicodeString tmp(c);
        tmp.foldCase();
        int32_t tmpidx = 0;
        while (tmpidx < tmp.length()) {
            c = tmp.char32At(tmpidx);
            node = getChildNode(node, c);
            if (node == NULL) {
                break;
            }
            tmpidx = tmp.moveIndex32(tmpidx, 1);
        }
    } else {
        node = getChildNode(node, c);
    }
    if (node != NULL) {
        search(node, text, start, index+1, handler, status);
    }
}
void CXmlConfig::getNode(DOMNode* parentNode, const string& typeName, const string& typeValue, DomNodeArray& domNodeArray)
{
	if (parentNode != NULL && parentNode->getNodeType() == DOMNode::ELEMENT_NODE)
	{
		string type;
		getAttribute(parentNode, TypeTag, type);
		if (type != StructType) return getChildNode(parentNode, typeName, typeValue, domNodeArray);
		
		getAttribute(parentNode, typeName.c_str(), type);
		if (type != typeValue) return getChildNode(parentNode, typeName, typeValue, domNodeArray);
		
		domNodeArray.push_back(parentNode);
	}
}
Exemplo n.º 3
0
void KDTreeNode::deleteSubtree()
{
    for(int i = 0; i < getNumChildNodes(); i++)
        getChildNode(i)->deleteSubtree();

    delete this;
}
Exemplo n.º 4
0
NamespaceTypeNode* NamespaceTypeNode::addNamespace(NamespaceNode* node)
{
	TypeNode* child = getChildNode(node->m_name->m_str);
	if (0 == child)
	{
		NamespaceTypeNode* result = new NamespaceTypeNode;
		result->m_name = node->m_name->m_str;
		result->m_enclosing = this;
		result->m_identifyNode = node->m_name;
		result->m_sourceFile = g_compiler.m_currentSourceFile;
		m_children.insert(result);
		g_typeTree.m_allNamespaces.push_back(result);
		return result;
	}
	else if (child->isNamespace())
	{
		NamespaceTypeNode* result = static_cast<NamespaceTypeNode*>(child);
		assert(result->m_name == node->m_name->m_str);
		//result->m_syntaxInfos.push_back(std::make_pair(node, g_compiler.m_currentSourceFile));
		return result;
	}
	else
	{
		char buf[512];
		sprintf_s(buf, "\'%s\' : already defined in %s(%d,%d)",
			node->m_name->m_str.c_str(), child->m_sourceFile->m_fileName.c_str(),
			child->m_identifyNode->m_lineNo, child->m_identifyNode->m_columnNo);
		ErrorList_AddItem(getCurrentSourceFileName(), node->m_name->m_lineNo,
			node->m_name->m_columnNo, semantic_error_namespace_redefined, buf);
		return 0;
	}
}
void CXmlConfig::getNode(DOMNode* parentNode, DomNodeArray& domNodeArray, const string& parentName, const string& nodeName, const string& typeValue)
{
	if (parentNode != NULL && parentNode->getNodeType() == DOMNode::ELEMENT_NODE)
	{
		string name;
		DOMNode* parent = parentNode->getParentNode();
		if (parent != NULL) charArrayToString(parent->getNodeName(), name);
		if (name != parentName) return getChildNode(parentNode, domNodeArray, parentName, nodeName, typeValue);
		
		charArrayToString(parentNode->getNodeName(), name);
		if (name != nodeName) return getChildNode(parentNode, domNodeArray, parentName, nodeName, typeValue);

		string type;
		getAttribute(parentNode, TypeTag, type);
		if (type != typeValue) return getChildNode(parentNode, domNodeArray, parentName, nodeName, typeValue);
		
		domNodeArray.push_back(parentNode);
	}
}
Exemplo n.º 6
0
bool SerializerNew::deserializeFromDocument(Variant& v, SerializationDocument* doc)
{
	if (doc == nullptr)
		return false;

	auto rootNode = doc->getRootNode();
	auto objectRootNode = rootNode->getChildNode("object");

	return deserializeObject(v, objectRootNode);
}
Exemplo n.º 7
0
Arquivo: xml.cpp Projeto: dcdelia/mcvm
	/***************************************************************
	* Function: Element::getChildElement()
	* Purpose : Get a child node known to be an element
	* Initial : Maxime Chevalier-Boisvert on November 18, 2008
	****************************************************************
	Revisions and bug fixes:
	*/
	Element* Element::getChildElement(size_t index) const
	{
		// Get a pointer to the child element
		Node* pChild = getChildNode(index);

		// If this is not an element, throw an exception
		if (pChild->getType() != ELEMENT)
			throw ParseError(
				"Invalid node type for child #" + ::toString(index+1) + ", expected child element",
				m_textPos
			);

		// Return a pointer to an XML element
		return (Element*)pChild;
	}
Exemplo n.º 8
0
int KDTreeNode::getSubtreeSize(KDTREE_STAT stat) const
{
	int cnt;
    switch(stat)
    {
        default: FW_ASSERT(0);  // unknown mode
        case KDTREE_STAT_NODE_COUNT:      cnt = 1; break;
        case KDTREE_STAT_LEAF_COUNT:      cnt = isLeaf() ? 1 : 0; break;
        case KDTREE_STAT_INNER_COUNT:     cnt = isLeaf() ? 0 : 1; break;
        case KDTREE_STAT_TRIANGLE_COUNT:  cnt = isLeaf() ? reinterpret_cast<const KDTLeafNode*>(this)->getNumTriangles() : 0; break;
        case KDTREE_STAT_CHILDNODE_COUNT: cnt = getNumChildNodes(); break;
		case KDTREE_STAT_EMPTYLEAF_COUNT: cnt = isLeaf() ? ((reinterpret_cast<const KDTLeafNode*>(this)->getNumTriangles() == 0) ? 1 : 0) : 0; break;
    }

    if(!isLeaf())
    {
        for(int i=0;i<getNumChildNodes();i++)
            cnt += getChildNode(i)->getSubtreeSize(stat);
    }

    return cnt;
}