diff options
author | 2015-08-24 18:44:56 +0300 | |
---|---|---|
committer | 2015-08-24 18:44:56 +0300 | |
commit | 98bc71b1c21452c3d868c4a4d418a8aeaa5a43af (patch) | |
tree | 2e66b9a775f0a5c545caa76f62890f5a5546e231 /external_libs/cpp/yaml-cpp/src/iterator.cpp | |
parent | 20eb7d362f9bce1951bd61ad3f78cf8f4267d1d5 (diff) | |
parent | 36c6c87fe4380b214f8ff8a45dc0213fa109821c (diff) |
Merge branch 'master' into dan_stateless
Diffstat (limited to 'external_libs/cpp/yaml-cpp/src/iterator.cpp')
-rwxr-xr-x | external_libs/cpp/yaml-cpp/src/iterator.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/external_libs/cpp/yaml-cpp/src/iterator.cpp b/external_libs/cpp/yaml-cpp/src/iterator.cpp new file mode 100755 index 00000000..f4159e32 --- /dev/null +++ b/external_libs/cpp/yaml-cpp/src/iterator.cpp @@ -0,0 +1,103 @@ +#include "yaml-cpp/node.h" +#include "yaml-cpp/exceptions.h" +#include "iterpriv.h" + +namespace YAML +{ + Iterator::Iterator(): m_pData(new IterPriv) + { + } + + Iterator::Iterator(std::auto_ptr<IterPriv> pData): m_pData(pData) + { + } + + Iterator::Iterator(const Iterator& rhs): m_pData(new IterPriv(*rhs.m_pData)) + { + } + + Iterator& Iterator::operator = (const Iterator& rhs) + { + if(this == &rhs) + return *this; + + m_pData.reset(new IterPriv(*rhs.m_pData)); + return *this; + } + + Iterator::~Iterator() + { + } + + Iterator& Iterator::operator ++ () + { + if(m_pData->type == IterPriv::IT_SEQ) + ++m_pData->seqIter; + else if(m_pData->type == IterPriv::IT_MAP) + ++m_pData->mapIter; + + return *this; + } + + Iterator Iterator::operator ++ (int) + { + Iterator temp = *this; + + if(m_pData->type == IterPriv::IT_SEQ) + ++m_pData->seqIter; + else if(m_pData->type == IterPriv::IT_MAP) + ++m_pData->mapIter; + + return temp; + } + + const Node& Iterator::operator * () const + { + if(m_pData->type == IterPriv::IT_SEQ) + return **m_pData->seqIter; + + throw BadDereference(); + } + + const Node *Iterator::operator -> () const + { + if(m_pData->type == IterPriv::IT_SEQ) + return *m_pData->seqIter; + + throw BadDereference(); + } + + const Node& Iterator::first() const + { + if(m_pData->type == IterPriv::IT_MAP) + return *m_pData->mapIter->first; + + throw BadDereference(); + } + + const Node& Iterator::second() const + { + if(m_pData->type == IterPriv::IT_MAP) + return *m_pData->mapIter->second; + + throw BadDereference(); + } + + bool operator == (const Iterator& it, const Iterator& jt) + { + if(it.m_pData->type != jt.m_pData->type) + return false; + + if(it.m_pData->type == IterPriv::IT_SEQ) + return it.m_pData->seqIter == jt.m_pData->seqIter; + else if(it.m_pData->type == IterPriv::IT_MAP) + return it.m_pData->mapIter == jt.m_pData->mapIter; + + return true; + } + + bool operator != (const Iterator& it, const Iterator& jt) + { + return !(it == jt); + } +} |