mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
Added an iterator class that can iterate through both sequence and map nodes.
This commit is contained in:
parent
f7358701f2
commit
d56b54b34f
16 changed files with 393 additions and 105 deletions
95
node.cpp
95
node.cpp
|
@ -136,4 +136,99 @@ namespace YAML
|
|||
m_pContent->Write(out, indent);
|
||||
}
|
||||
}
|
||||
|
||||
// begin
|
||||
// Returns an iterator to the beginning of this (sequence or map).
|
||||
Node::Iterator Node::begin() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return Iterator();
|
||||
|
||||
std::vector <Node *>::const_iterator seqIter;
|
||||
if(m_pContent->GetBegin(seqIter))
|
||||
return Iterator(seqIter);
|
||||
|
||||
std::map <Node *, Node *>::const_iterator mapIter;
|
||||
if(m_pContent->GetBegin(mapIter))
|
||||
return Iterator(mapIter);
|
||||
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
// end
|
||||
// . Returns an iterator to the end of this (sequence or map).
|
||||
Node::Iterator Node::end() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return Iterator();
|
||||
|
||||
std::vector <Node *>::const_iterator seqIter;
|
||||
if(m_pContent->GetEnd(seqIter))
|
||||
return Iterator(seqIter);
|
||||
|
||||
std::map <Node *, Node *>::const_iterator mapIter;
|
||||
if(m_pContent->GetEnd(mapIter))
|
||||
return Iterator(mapIter);
|
||||
|
||||
return Iterator();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Extraction
|
||||
|
||||
void operator >> (const Node& node, std::string& s)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(s);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, int& i)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(i);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, unsigned& u)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(u);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, long& l)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(l);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, float& f)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(f);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, double& d)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(d);
|
||||
}
|
||||
|
||||
void operator >> (const Node& node, char& c)
|
||||
{
|
||||
if(!node.m_pContent)
|
||||
throw;
|
||||
|
||||
node.m_pContent->Read(c);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue