Exemplo n.º 1
0
	void Sequence::EmitEvents(AliasManager& am, EventHandler& eventHandler, const Mark& mark, const std::string& tag, anchor_t anchor) const
	{
		eventHandler.OnSequenceStart(mark, tag, anchor);
		for(std::size_t i=0;i<m_data.size();i++)
			m_data[i]->EmitEvents(am, eventHandler);
		eventHandler.OnSequenceEnd();
	}
Exemplo 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;
		}
	}