Skip to content

Commit

Permalink
UniValue: export NullUniValue global constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Garzik authored and jonasschnelli committed Jun 4, 2015
1 parent efc7883 commit 5e3060c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/univalue/univalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using namespace std;

static const UniValue nullValue;
const UniValue NullUniValue;

void UniValue::clear()
{
Expand Down Expand Up @@ -175,21 +175,21 @@ bool UniValue::checkObject(const std::map<std::string,UniValue::VType>& t)
const UniValue& UniValue::operator[](const std::string& key) const
{
if (typ != VOBJ)
return nullValue;
return NullUniValue;

int index = findKey(key);
if (index < 0)
return nullValue;
return NullUniValue;

return values[index];
}

const UniValue& UniValue::operator[](unsigned int index) const
{
if (typ != VOBJ && typ != VARR)
return nullValue;
return NullUniValue;
if (index >= values.size())
return nullValue;
return NullUniValue;

return values[index];
}
Expand Down
2 changes: 2 additions & 0 deletions src/univalue/univalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ extern enum jtokentype getJsonToken(std::string& tokenVal,
unsigned int& consumed, const char *raw);
extern const char *uvTypeName(UniValue::VType t);

extern const UniValue NullUniValue;
#endif // BITCOIN_UNIVALUE_UNIVALUE_H

0 comments on commit 5e3060c

Please sign in to comment.