yaml-cpp/src/value/valueevents.cpp

29 lines
648 B
C++
Raw Normal View History

2011-09-10 21:42:42 +04:00
#include "valueevents.h"
2011-09-10 23:36:10 +04:00
#include "yaml-cpp/value.h"
2011-09-10 21:42:42 +04:00
namespace YAML
{
ValueEvents::ValueEvents(const Value& value): m_pMemory(value.m_pMemory), m_root(*value.m_pNode)
{
Visit(m_root);
}
2011-09-10 23:36:10 +04:00
void ValueEvents::Visit(const detail::node& node)
2011-09-10 21:42:42 +04:00
{
int& refCount = m_refCount[node.ref()];
refCount++;
if(refCount > 1)
return;
if(node.type() == ValueType::Sequence) {
2011-09-10 23:36:10 +04:00
for(detail::const_node_iterator it=node.begin();it!=node.end();++it)
Visit(**it);
2011-09-10 21:42:42 +04:00
} else if(node.type() == ValueType::Map) {
2011-09-10 23:36:10 +04:00
for(detail::const_node_iterator it=node.begin();it!=node.end();++it) {
Visit(*it->first);
Visit(*it->second);
}
2011-09-10 21:42:42 +04:00
}
}
}