diff options
author | Dan Klein <danklei@cisco.com> | 2015-08-26 15:05:58 +0300 |
---|---|---|
committer | Dan Klein <danklei@cisco.com> | 2015-08-26 15:05:58 +0300 |
commit | fc46f2618332037a8c1b58fbce5d616033bff1c9 (patch) | |
tree | bdb7ffdb92732438d540ef06622e570a3c60a8f4 /external_libs/yaml-cpp/src/iterator.cpp | |
parent | cecaf28ab61882d323cb5f3d813518523f7e836b (diff) |
Rearranged files and external libraries in two different locations, one for cpp (trex-core/external_libs) and one for python (trex-core/scripts/external_libs)
Diffstat (limited to 'external_libs/yaml-cpp/src/iterator.cpp')
-rw-r--r-- | external_libs/yaml-cpp/src/iterator.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/external_libs/yaml-cpp/src/iterator.cpp b/external_libs/yaml-cpp/src/iterator.cpp new file mode 100644 index 00000000..f4159e32 --- /dev/null +++ b/external_libs/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); + } +} |