/univalue.snippet.cpp Secret
Last active
August 21, 2018 09:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int UniValue::findKey(const std::string& key) const | |
{ | |
for (unsigned int i = 0; i < keys.size(); i++) { | |
if (keys[i] == key) | |
return (int) i; | |
} | |
return -1; | |
} | |
const UniValue& UniValue::operator[](const std::string& key) const | |
{ | |
if (typ != VOBJ) | |
return NullUniValue; | |
int index = findKey(key); | |
if (index < 0) | |
return NullUniValue; | |
return values.at(index); | |
} | |
const UniValue& find_value(const UniValue& obj, const std::string& name) | |
{ | |
for (unsigned int i = 0; i < obj.keys.size(); i++) | |
if (obj.keys[i] == name) | |
return obj.values.at(i); | |
return NullUniValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment