Switched the Iterator implementation to a dedicated helper class (to hide the specific implementation, since it's pretty messy and may change).

This commit is contained in:
Jesse Beder
2008-07-21 02:54:39 +00:00
parent 09d7ab365f
commit cc87c83b01
10 changed files with 143 additions and 68 deletions

View File

@@ -7,6 +7,7 @@
#include "scalar.h"
#include "sequence.h"
#include "map.h"
#include "iterpriv.h"
namespace YAML
{
@@ -145,36 +146,36 @@ namespace YAML
// begin
// Returns an iterator to the beginning of this (sequence or map).
Node::Iterator Node::begin() const
Iterator Node::begin() const
{
if(!m_pContent)
return Iterator();
std::vector <Node *>::const_iterator seqIter;
if(m_pContent->GetBegin(seqIter))
return Iterator(seqIter);
return Iterator(new IterPriv(seqIter));
std::map <Node *, Node *, ltnode>::const_iterator mapIter;
if(m_pContent->GetBegin(mapIter))
return Iterator(mapIter);
return Iterator(new IterPriv(mapIter));
return Iterator();
}
// end
// . Returns an iterator to the end of this (sequence or map).
Node::Iterator Node::end() const
Iterator Node::end() const
{
if(!m_pContent)
return Iterator();
std::vector <Node *>::const_iterator seqIter;
if(m_pContent->GetEnd(seqIter))
return Iterator(seqIter);
return Iterator(new IterPriv(seqIter));
std::map <Node *, Node *, ltnode>::const_iterator mapIter;
if(m_pContent->GetEnd(mapIter))
return Iterator(mapIter);
return Iterator(new IterPriv(mapIter));
return Iterator();
}