mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Added a (recursive) ordering, so we have a canonical output that we can compare.
This commit is contained in:
22
sequence.cpp
22
sequence.cpp
@@ -151,4 +151,26 @@ namespace YAML
|
||||
if(m_data.empty())
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
int Sequence::Compare(Content *pContent)
|
||||
{
|
||||
return -pContent->Compare(this);
|
||||
}
|
||||
|
||||
int Sequence::Compare(Sequence *pSeq)
|
||||
{
|
||||
unsigned n = m_data.size(), m = pSeq->m_data.size();
|
||||
if(n < m)
|
||||
return -1;
|
||||
else if(n > m)
|
||||
return 1;
|
||||
|
||||
for(unsigned i=0;i<n;i++) {
|
||||
int cmp = m_data[i]->Compare(*pSeq->m_data[i]);
|
||||
if(cmp != 0)
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user