mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Specialized the overloaded [] operator for int/unsigned, and added a size() function, so that you can iterate through a sequence node like a vector.
This commit is contained in:
parent
2ccbfeff47
commit
2be40919de
8 changed files with 81 additions and 25 deletions
35
node.cpp
35
node.cpp
|
@ -173,6 +173,41 @@ namespace YAML
|
|||
return Iterator();
|
||||
}
|
||||
|
||||
// size
|
||||
// . Returns the size of this node, if it's a sequence node.
|
||||
// . Otherwise, returns zero.
|
||||
unsigned Node::size() const
|
||||
{
|
||||
if(!m_pContent)
|
||||
return 0;
|
||||
|
||||
return m_pContent->GetSize();
|
||||
}
|
||||
|
||||
const Node& Node::operator [] (unsigned u) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
throw BadDereference();
|
||||
|
||||
Node *pNode = m_pContent->GetNode(u);
|
||||
if(pNode)
|
||||
return *pNode;
|
||||
|
||||
return GetValue(u);
|
||||
}
|
||||
|
||||
const Node& Node::operator [] (int i) const
|
||||
{
|
||||
if(!m_pContent)
|
||||
throw BadDereference();
|
||||
|
||||
Node *pNode = m_pContent->GetNode(i);
|
||||
if(pNode)
|
||||
return *pNode;
|
||||
|
||||
return GetValue(i);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Extraction
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue