本文整理汇总了C++中json::value::const_iterator::memberName方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::memberName方法的具体用法?C++ const_iterator::memberName怎么用?C++ const_iterator::memberName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::value::const_iterator
的用法示例。
在下文中一共展示了const_iterator::memberName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: push_json_value_helper
// Recursive function to convert JSON --> Lua table
static bool push_json_value_helper(lua_State *L, const Json::Value &value,
int nullindex)
{
switch(value.type()) {
case Json::nullValue:
default:
lua_pushvalue(L, nullindex);
break;
case Json::intValue:
lua_pushinteger(L, value.asInt());
break;
case Json::uintValue:
lua_pushinteger(L, value.asUInt());
break;
case Json::realValue:
lua_pushnumber(L, value.asDouble());
break;
case Json::stringValue:
{
const char *str = value.asCString();
lua_pushstring(L, str ? str : "");
}
break;
case Json::booleanValue:
lua_pushboolean(L, value.asInt());
break;
case Json::arrayValue:
lua_newtable(L);
for (Json::Value::const_iterator it = value.begin();
it != value.end(); ++it) {
push_json_value_helper(L, *it, nullindex);
lua_rawseti(L, -2, it.index() + 1);
}
break;
case Json::objectValue:
lua_newtable(L);
for (Json::Value::const_iterator it = value.begin();
it != value.end(); ++it) {
#ifndef JSONCPP_STRING
const char *str = it.memberName();
lua_pushstring(L, str ? str : "");
#else
std::string str = it.name();
lua_pushstring(L, str.c_str());
#endif
push_json_value_helper(L, *it, nullindex);
lua_rawset(L, -3);
}
break;
}
return true;
}
示例2: doAccountOffers
// {
// account: <account>|<account_public_key>
// account_index: <number> // optional, defaults to 0.
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// limit: integer // optional
// marker: opaque // optional, resume previous query
// }
Json::Value doAccountOffers (RPC::Context& context)
{
auto const& params (context.params);
if (! params.isMember (jss::account))
return RPC::missing_field_error (jss::account);
Ledger::pointer ledger;
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
if (! ledger)
return result;
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int const iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
DivvyAddress divvyAddress;
Json::Value const jv = RPC::accountFromString (
divvyAddress, bIndex, strIdent, iIndex, false);
if (! jv.empty ())
{
for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
return result;
}
// Get info on account.
result[jss::account] = divvyAddress.humanAccountID ();
if (bIndex)
result[jss::account_index] = iIndex;
if (! ledger->exists(getAccountRootIndex(
divvyAddress.getAccountID())))
return rpcError (rpcACT_NOT_FOUND);
unsigned int limit;
if (params.isMember (jss::limit))
{
auto const& jvLimit (params[jss::limit]);
if (! jvLimit.isIntegral ())
return RPC::expected_field_error (jss::limit, "unsigned integer");
limit = jvLimit.isUInt () ? jvLimit.asUInt () :
std::max (0, jvLimit.asInt ());
if (context.role != Role::ADMIN)
{
limit = std::max (RPC::Tuning::minOffersPerRequest,
std::min (limit, RPC::Tuning::maxOffersPerRequest));
}
}
else
{
limit = RPC::Tuning::defaultOffersPerRequest;
}
AccountID const& raAccount (divvyAddress.getAccountID ());
Json::Value& jsonOffers (result[jss::offers] = Json::arrayValue);
std::vector <std::shared_ptr<SLE const>> offers;
unsigned int reserve (limit);
uint256 startAfter;
std::uint64_t startHint;
if (params.isMember(jss::marker))
{
// We have a start point. Use limit - 1 from the result and use the
// very last one for the resume.
Json::Value const& marker (params[jss::marker]);
if (! marker.isString ())
return RPC::expected_field_error (jss::marker, "string");
startAfter.SetHex (marker.asString ());
auto const sleOffer = fetch (*ledger, startAfter,
getApp().getSLECache());
if (sleOffer == nullptr ||
sleOffer->getType () != ltOFFER ||
raAccount != sleOffer->getFieldAccount160 (sfAccount))
{
return rpcError (rpcINVALID_PARAMS);
}
startHint = sleOffer->getFieldU64(sfOwnerNode);
// Caller provided the first offer (startAfter), add it as first result
Json::Value& obj (jsonOffers.append (Json::objectValue));
sleOffer->getFieldAmount (sfTakerPays).setJson (obj[jss::taker_pays]);
sleOffer->getFieldAmount (sfTakerGets).setJson (obj[jss::taker_gets]);
obj[jss::seq] = sleOffer->getFieldU32 (sfSequence);
obj[jss::flags] = sleOffer->getFieldU32 (sfFlags);
//.........这里部分代码省略.........