Ejemplo n.º 1
0
	void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const
	{
		anchor_t anchor = NullAnchor;
		if(m_referenced || m_alias) {
			if(const Node *pOther = am.LookupReference(*this)) {
				eventHandler.OnAlias(m_mark, am.LookupAnchor(*pOther));
				return;
			}
			
			am.RegisterReference(*this);
			anchor = am.LookupAnchor(*this);
		}
		
		if(m_pContent)
			m_pContent->EmitEvents(am, eventHandler, m_mark, GetTag(), anchor);
		else
			eventHandler.OnNull(GetTag(), anchor);
	}
Ejemplo n.º 2
0
	void Node::EmitEvents(AliasManager& am, EventHandler& eventHandler) const
	{
		anchor_t anchor = NullAnchor;
		if(IsAliased()) {
			anchor = am.LookupAnchor(*this);
			if(anchor) {
				eventHandler.OnAlias(m_mark, anchor);
				return;
			}
			
			am.RegisterReference(*this);
			anchor = am.LookupAnchor(*this);
		}
		
		switch(m_type) {
			case NodeType::Null:
				eventHandler.OnNull(m_mark, anchor);
				break;
			case NodeType::Scalar:
				eventHandler.OnScalar(m_mark, m_tag, anchor, m_scalarData);
				break;
			case NodeType::Sequence:
				eventHandler.OnSequenceStart(m_mark, m_tag, anchor);
				for(std::size_t i=0;i<m_seqData.size();i++)
					m_seqData[i]->EmitEvents(am, eventHandler);
				eventHandler.OnSequenceEnd();
				break;
			case NodeType::Map:
				eventHandler.OnMapStart(m_mark, m_tag, anchor);
				for(node_map::const_iterator it=m_mapData.begin();it!=m_mapData.end();++it) {
					it->first->EmitEvents(am, eventHandler);
					it->second->EmitEvents(am, eventHandler);
				}
				eventHandler.OnMapEnd();
				break;
		}
	}