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
15
node.h
15
node.h
|
@ -50,9 +50,10 @@ namespace YAML
|
|||
|
||||
Iterator begin() const;
|
||||
Iterator end() const;
|
||||
unsigned size() const;
|
||||
|
||||
template <typename T>
|
||||
const Node& operator [] (const T& key) const {
|
||||
const Node& GetValue(const T& key) const {
|
||||
if(!m_pContent)
|
||||
throw BadDereference();
|
||||
|
||||
|
@ -69,10 +70,18 @@ namespace YAML
|
|||
throw BadDereference();
|
||||
}
|
||||
|
||||
const Node& operator [] (const char *key) const {
|
||||
return operator [] (std::string(key));
|
||||
template <typename T>
|
||||
const Node& operator [] (const T& key) const {
|
||||
return GetValue(key);
|
||||
}
|
||||
|
||||
const Node& operator [] (const char *key) const {
|
||||
return GetValue(std::string(key));
|
||||
}
|
||||
|
||||
const Node& operator [] (unsigned u) const;
|
||||
const Node& operator [] (int i) const;
|
||||
|
||||
// extraction
|
||||
friend void operator >> (const Node& node, std::string& s);
|
||||
friend void operator >> (const Node& node, int& i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue